summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/InstCombine/fast-math.ll
diff options
context:
space:
mode:
authorShuxin Yang <shuxin.llvm@gmail.com>2012-12-14 18:46:06 +0000
committerShuxin Yang <shuxin.llvm@gmail.com>2012-12-14 18:46:06 +0000
commitf8e9a5a061734115bbf43a1e859a5da9d7b6ea1d (patch)
tree6d149624c98e332b0f24bd9a525d97dfd250c86e /llvm/test/Transforms/InstCombine/fast-math.ll
parent92eb254c3cd5376bc8a8c412bdd8c36d833a4e15 (diff)
downloadbcm5719-llvm-f8e9a5a061734115bbf43a1e859a5da9d7b6ea1d.tar.gz
bcm5719-llvm-f8e9a5a061734115bbf43a1e859a5da9d7b6ea1d.zip
rdar://12753946
Implement rule : "x * (select cond 1.0, 0.0) -> select cond x, 0.0" llvm-svn: 170226
Diffstat (limited to 'llvm/test/Transforms/InstCombine/fast-math.ll')
-rw-r--r--llvm/test/Transforms/InstCombine/fast-math.ll40
1 files changed, 34 insertions, 6 deletions
diff --git a/llvm/test/Transforms/InstCombine/fast-math.ll b/llvm/test/Transforms/InstCombine/fast-math.ll
index b6a15677bb7..0b87cd95d9c 100644
--- a/llvm/test/Transforms/InstCombine/fast-math.ll
+++ b/llvm/test/Transforms/InstCombine/fast-math.ll
@@ -3,19 +3,17 @@
; testing-case "float fold(float a) { return 1.2f * a * 2.3f; }"
; 1.2f and 2.3f is supposed to be fold.
define float @fold(float %a) {
-fold:
%mul = fmul fast float %a, 0x3FF3333340000000
%mul1 = fmul fast float %mul, 0x4002666660000000
ret float %mul1
-; CHECK: fold
+; CHECK: @fold
; CHECK: fmul float %a, 0x4006147AE0000000
}
; Same testing-case as the one used in fold() except that the operators have
; fixed FP mode.
define float @notfold(float %a) {
-notfold:
-; CHECK: notfold
+; CHECK: @notfold
; CHECK: %mul = fmul fast float %a, 0x3FF3333340000000
%mul = fmul fast float %a, 0x3FF3333340000000
%mul1 = fmul float %mul, 0x4002666660000000
@@ -23,10 +21,40 @@ notfold:
}
define float @fold2(float %a) {
-fold2:
-; CHECK: fold2
+; CHECK: @fold2
; CHECK: fmul float %a, 0x4006147AE0000000
%mul = fmul float %a, 0x3FF3333340000000
%mul1 = fmul fast float %mul, 0x4002666660000000
ret float %mul1
}
+
+; rdar://12753946: x * cond ? 1.0 : 0.0 => cond ? x : 0.0
+define double @select1(i32 %cond, double %x, double %y) {
+ %tobool = icmp ne i32 %cond, 0
+ %cond1 = select i1 %tobool, double 1.000000e+00, double 0.000000e+00
+ %mul = fmul nnan nsz double %cond1, %x
+ %add = fadd double %mul, %y
+ ret double %add
+; CHECK: @select1
+; CHECK: select i1 %tobool, double %x, double 0.000000e+00
+}
+
+define double @select2(i32 %cond, double %x, double %y) {
+ %tobool = icmp ne i32 %cond, 0
+ %cond1 = select i1 %tobool, double 0.000000e+00, double 1.000000e+00
+ %mul = fmul nnan nsz double %cond1, %x
+ %add = fadd double %mul, %y
+ ret double %add
+; CHECK: @select2
+; CHECK: select i1 %tobool, double 0.000000e+00, double %x
+}
+
+define double @select3(i32 %cond, double %x, double %y) {
+ %tobool = icmp ne i32 %cond, 0
+ %cond1 = select i1 %tobool, double 0.000000e+00, double 2.000000e+00
+ %mul = fmul nnan nsz double %cond1, %x
+ %add = fadd double %mul, %y
+ ret double %add
+; CHECK: @select3
+; CHECK: fmul nnan nsz double %cond1, %x
+}
OpenPOWER on IntegriCloud