diff options
author | Sanjay Patel <spatel@rotateright.com> | 2015-01-12 19:29:48 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2015-01-12 19:29:48 +0000 |
commit | 5f1d9eaad35ee3fa9f474e58d90a9708711c5726 (patch) | |
tree | 1507915bac665ec52d23763d6c6e573b8e790362 /llvm/test/Transforms | |
parent | a0c32e9310993f59937c43914dea42701cb152ee (diff) | |
download | bcm5719-llvm-5f1d9eaad35ee3fa9f474e58d90a9708711c5726.tar.gz bcm5719-llvm-5f1d9eaad35ee3fa9f474e58d90a9708711c5726.zip |
GVN: propagate equalities for floating point compares
Allow optimizations based on FP comparison values in the same way
as integers.
This resolves PR17713:
http://llvm.org/bugs/show_bug.cgi?id=17713
Differential Revision: http://reviews.llvm.org/D6911
llvm-svn: 225660
Diffstat (limited to 'llvm/test/Transforms')
-rw-r--r-- | llvm/test/Transforms/GVN/condprop.ll | 48 | ||||
-rw-r--r-- | llvm/test/Transforms/GVN/edge.ll | 35 |
2 files changed, 83 insertions, 0 deletions
diff --git a/llvm/test/Transforms/GVN/condprop.ll b/llvm/test/Transforms/GVN/condprop.ll index 708e4b23cb5..845f88e1589 100644 --- a/llvm/test/Transforms/GVN/condprop.ll +++ b/llvm/test/Transforms/GVN/condprop.ll @@ -144,6 +144,22 @@ different: ret i1 %cmp3 } +; CHECK-LABEL: @test6_fp( +define i1 @test6_fp(float %x, float %y) { + %cmp2 = fcmp une float %x, %y + %cmp = fcmp oeq float %x, %y + %cmp3 = fcmp oeq float %x, %y + br i1 %cmp, label %same, label %different + +same: +; CHECK: ret i1 false + ret i1 %cmp2 + +different: +; CHECK: ret i1 false + ret i1 %cmp3 +} + ; CHECK-LABEL: @test7( define i1 @test7(i32 %x, i32 %y) { %cmp = icmp sgt i32 %x, %y @@ -160,6 +176,22 @@ different: ret i1 %cmp3 } +; CHECK-LABEL: @test7_fp( +define i1 @test7_fp(float %x, float %y) { + %cmp = fcmp ogt float %x, %y + br i1 %cmp, label %same, label %different + +same: + %cmp2 = fcmp ule float %x, %y +; CHECK: ret i1 false + ret i1 %cmp2 + +different: + %cmp3 = fcmp ogt float %x, %y +; CHECK: ret i1 false + ret i1 %cmp3 +} + ; CHECK-LABEL: @test8( define i1 @test8(i32 %x, i32 %y) { %cmp2 = icmp sle i32 %x, %y @@ -176,6 +208,22 @@ different: ret i1 %cmp3 } +; CHECK-LABEL: @test8_fp( +define i1 @test8_fp(float %x, float %y) { + %cmp2 = fcmp ule float %x, %y + %cmp = fcmp ogt float %x, %y + %cmp3 = fcmp ogt float %x, %y + br i1 %cmp, label %same, label %different + +same: +; CHECK: ret i1 false + ret i1 %cmp2 + +different: +; CHECK: ret i1 false + ret i1 %cmp3 +} + ; PR1768 ; CHECK-LABEL: @test9( define i32 @test9(i32 %i, i32 %j) { diff --git a/llvm/test/Transforms/GVN/edge.ll b/llvm/test/Transforms/GVN/edge.ll index 646e10c0cdf..1dc285ec3d7 100644 --- a/llvm/test/Transforms/GVN/edge.ll +++ b/llvm/test/Transforms/GVN/edge.ll @@ -58,3 +58,38 @@ bb2: ; CHECK: call void @g(i1 %y) ret void } + +define double @fcmp_oeq(double %x, double %y) { +entry: + %cmp = fcmp oeq double %y, 2.0 + br i1 %cmp, label %if, label %return + +if: + %div = fdiv double %x, %y + br label %return + +return: + %retval.0 = phi double [ %div, %if ], [ %x, %entry ] + ret double %retval.0 + +; CHECK-LABEL: define double @fcmp_oeq( +; CHECK: %div = fdiv double %x, 2.000000e+00 +} + +define double @fcmp_une(double %x, double %y) { +entry: + %cmp = fcmp une double %y, 2.0 + br i1 %cmp, label %return, label %else + +else: + %div = fdiv double %x, %y + br label %return + +return: + %retval.0 = phi double [ %div, %else ], [ %x, %entry ] + ret double %retval.0 + +; CHECK-LABEL: define double @fcmp_une( +; CHECK: %div = fdiv double %x, 2.000000e+00 +} + |