summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms
diff options
context:
space:
mode:
authorMehdi Amini <mehdi.amini@apple.com>2015-03-09 03:20:25 +0000
committerMehdi Amini <mehdi.amini@apple.com>2015-03-09 03:20:25 +0000
commiteb242a504161f86f3a1e059732a0c4bf91c35735 (patch)
tree5d0bbc099d952d01d41a31b9aebff8fdcd92125c /llvm/test/Transforms
parentce90329824037c89af64a5ee852e4c86f0c62cc7 (diff)
downloadbcm5719-llvm-eb242a504161f86f3a1e059732a0c4bf91c35735.tar.gz
bcm5719-llvm-eb242a504161f86f3a1e059732a0c4bf91c35735.zip
InstCombine: fix fold "fcmp x, undef" to account for NaN
Summary: See the two test cases. ; Can fold fcmp with undef on one side by choosing NaN for the undef ; Can fold fcmp with undef on both side ; fcmp u_pred undef, undef -> true ; fcmp o_pred undef, undef -> false ; because whatever you choose for the first undef ; you can choose NaN for the other undef Reviewers: hfinkel, chandlerc, majnemer Reviewed By: majnemer Subscribers: majnemer, llvm-commits Differential Revision: http://reviews.llvm.org/D7617 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 231626
Diffstat (limited to 'llvm/test/Transforms')
-rw-r--r--llvm/test/Transforms/InstCombine/fcmp.ll35
1 files changed, 35 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/fcmp.ll b/llvm/test/Transforms/InstCombine/fcmp.ll
index ee39d1084eb..7fd46f22818 100644
--- a/llvm/test/Transforms/InstCombine/fcmp.ll
+++ b/llvm/test/Transforms/InstCombine/fcmp.ll
@@ -240,3 +240,38 @@ define i32 @test17(double %a, double (double)* %p) nounwind {
%conv = zext i1 %cmp to i32
ret i32 %conv
}
+
+; Can fold fcmp with undef on one side by choosing NaN for the undef
+define i32 @test18_undef_unordered(float %a) nounwind {
+; CHECK-LABEL: @test18_undef_unordered
+; CHECK: ret i32 1
+ %cmp = fcmp ueq float %a, undef
+ %conv = zext i1 %cmp to i32
+ ret i32 %conv
+}
+; Can fold fcmp with undef on one side by choosing NaN for the undef
+define i32 @test18_undef_ordered(float %a) nounwind {
+; CHECK-LABEL: @test18_undef_ordered
+; CHECK: ret i32 0
+ %cmp = fcmp oeq float %a, undef
+ %conv = zext i1 %cmp to i32
+ ret i32 %conv
+}
+
+; Can fold fcmp with undef on both side
+; fcmp u_pred undef, undef -> true
+; fcmp o_pred undef, undef -> false
+; because whatever you choose for the first undef
+; you can choose NaN for the other undef
+define i1 @test19_undef_unordered() nounwind {
+; CHECK-LABEL: @test19_undef
+; CHECK: ret i1 true
+ %cmp = fcmp ueq float undef, undef
+ ret i1 %cmp
+}
+define i1 @test19_undef_ordered() nounwind {
+; CHECK-LABEL: @test19_undef
+; CHECK: ret i1 false
+ %cmp = fcmp oeq float undef, undef
+ ret i1 %cmp
+}
OpenPOWER on IntegriCloud