[llvm] r345752 - [InstCombine] add tests for fcmp with -0.0; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 31 10:55:41 PDT 2018


Author: spatel
Date: Wed Oct 31 10:55:40 2018
New Revision: 345752

URL: http://llvm.org/viewvc/llvm-project?rev=345752&view=rev
Log:
[InstCombine] add tests for fcmp with -0.0; NFC

>From IEEE754: "Comparisons shall ignore the sign of zero (so +0 = −0)."

Modified:
    llvm/trunk/test/Transforms/InstCombine/fcmp-special.ll

Modified: llvm/trunk/test/Transforms/InstCombine/fcmp-special.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/fcmp-special.ll?rev=345752&r1=345751&r2=345752&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/fcmp-special.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/fcmp-special.ll Wed Oct 31 10:55:40 2018
@@ -161,6 +161,7 @@ define <2 x i1> @ord_vec_with_undef(<2 x
   %f = fcmp ord <2 x double> %x, <double 0.0, double undef>
   ret <2 x i1> %f
 }
+
 ; TODO: This could be handled in InstSimplify.
 
 define i1 @nnan_ops_to_fcmp_ord(float %x, float %y) {
@@ -185,3 +186,59 @@ define i1 @nnan_ops_to_fcmp_uno(float %x
   ret i1 %cmp
 }
 
+; TODO: For any predicate/type/FMF, comparison to -0.0 is the same as comparison to +0.0.
+
+define i1 @negative_zero_oeq(float %x) {
+; CHECK-LABEL: @negative_zero_oeq(
+; CHECK-NEXT:    [[R:%.*]] = fcmp oeq float [[X:%.*]], -0.000000e+00
+; CHECK-NEXT:    ret i1 [[R]]
+;
+  %r = fcmp oeq float %x, -0.0
+  ret i1 %r
+}
+
+define i1 @negative_zero_oge(double %x) {
+; CHECK-LABEL: @negative_zero_oge(
+; CHECK-NEXT:    [[R:%.*]] = fcmp nnan oge double [[X:%.*]], -0.000000e+00
+; CHECK-NEXT:    ret i1 [[R]]
+;
+  %r = fcmp nnan oge double %x, -0.0
+  ret i1 %r
+}
+
+define i1 @negative_zero_uge(half %x) {
+; CHECK-LABEL: @negative_zero_uge(
+; CHECK-NEXT:    [[R:%.*]] = fcmp fast uge half [[X:%.*]], 0xH8000
+; CHECK-NEXT:    ret i1 [[R]]
+;
+  %r = fcmp fast uge half %x, -0.0
+  ret i1 %r
+}
+
+define <2 x i1> @negative_zero_olt_vec(<2 x float> %x) {
+; CHECK-LABEL: @negative_zero_olt_vec(
+; CHECK-NEXT:    [[R:%.*]] = fcmp reassoc ninf olt <2 x float> [[X:%.*]], <float -0.000000e+00, float -0.000000e+00>
+; CHECK-NEXT:    ret <2 x i1> [[R]]
+;
+  %r = fcmp reassoc ninf olt <2 x float> %x, <float -0.0, float -0.0>
+  ret <2 x i1> %r
+}
+
+define <2 x i1> @negative_zero_une_vec_undef(<2 x double> %x) {
+; CHECK-LABEL: @negative_zero_une_vec_undef(
+; CHECK-NEXT:    [[R:%.*]] = fcmp nnan une <2 x double> [[X:%.*]], <double -0.000000e+00, double undef>
+; CHECK-NEXT:    ret <2 x i1> [[R]]
+;
+  %r = fcmp nnan une <2 x double> %x, <double -0.0, double undef>
+  ret <2 x i1> %r
+}
+
+define <2 x i1> @negative_zero_ule_vec_mixed(<2 x float> %x) {
+; CHECK-LABEL: @negative_zero_ule_vec_mixed(
+; CHECK-NEXT:    [[R:%.*]] = fcmp ule <2 x float> [[X:%.*]], <float 0.000000e+00, float -0.000000e+00>
+; CHECK-NEXT:    ret <2 x i1> [[R]]
+;
+  %r = fcmp ule <2 x float> %x, <float 0.0, float -0.0>
+  ret <2 x i1> %r
+}
+




More information about the llvm-commits mailing list