[x86] Fix disassembly of callw instruction
[oota-llvm.git] / test / Transforms / InstCombine / sqrt.ll
index 69e511bfb3bd48734bf98c7082af785cf6af20c5..650b10c6e96692085bcf4dfad95a8cea44e0b553 100644 (file)
@@ -1,8 +1,8 @@
-; RUN: opt -S -instcombine %s | FileCheck %s
+; RUN: opt -S -instcombine %s | FileCheck %s
 
 define float @test1(float %x) nounwind readnone ssp {
 entry:
-; CHECK: @test1
+; CHECK-LABEL: @test1(
 ; CHECK-NOT: fpext
 ; CHECK-NOT: sqrt(
 ; CHECK: sqrtf(
@@ -14,12 +14,10 @@ entry:
   ret float %conv1
 }
 
-declare double @sqrt(double)
-
 ; PR8096
 define float @test2(float %x) nounwind readnone ssp {
 entry:
-; CHECK: @test2
+; CHECK-LABEL: @test2(
 ; CHECK-NOT: fpext
 ; CHECK-NOT: sqrt(
 ; CHECK: sqrtf(
@@ -30,3 +28,27 @@ entry:
 ; CHECK: ret float
   ret float %conv1
 }
+
+; rdar://9763193
+; Can't fold (fptrunc (sqrt (fpext x))) -> (sqrtf x) since there is another
+; use of sqrt result.
+define float @test3(float* %v) nounwind uwtable ssp {
+entry:
+; CHECK-LABEL: @test3(
+; CHECK: sqrt(
+; CHECK-NOT: sqrtf(
+; CHECK: fptrunc
+  %arrayidx13 = getelementptr inbounds float* %v, i64 2
+  %tmp14 = load float* %arrayidx13
+  %mul18 = fmul float %tmp14, %tmp14
+  %add19 = fadd float undef, %mul18
+  %conv = fpext float %add19 to double
+  %call34 = call double @sqrt(double %conv) readnone
+  %call36 = call i32 (double)* @foo(double %call34) nounwind
+  %conv38 = fptrunc double %call34 to float
+  ret float %conv38
+}
+
+declare i32 @foo(double)
+
+declare double @sqrt(double) readnone