summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2018-10-31 17:55:40 +0000
committerSanjay Patel <spatel@rotateright.com>2018-10-31 17:55:40 +0000
commit5bcec66c554c1d9a5255bc6763c216ff44dae4c4 (patch)
tree8fc95b90c22ab861397b91ee3dbad212a025aa93
parent3ca146d08315ca197686b9f251c131295b812139 (diff)
downloadbcm5719-llvm-5bcec66c554c1d9a5255bc6763c216ff44dae4c4.tar.gz
bcm5719-llvm-5bcec66c554c1d9a5255bc6763c216ff44dae4c4.zip
[InstCombine] add tests for fcmp with -0.0; NFC
From IEEE754: "Comparisons shall ignore the sign of zero (so +0 = −0)." llvm-svn: 345752
-rw-r--r--llvm/test/Transforms/InstCombine/fcmp-special.ll57
1 files changed, 57 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/fcmp-special.ll b/llvm/test/Transforms/InstCombine/fcmp-special.ll
index 8d131b3c2a6..5d4cc9a8616 100644
--- a/llvm/test/Transforms/InstCombine/fcmp-special.ll
+++ b/llvm/test/Transforms/InstCombine/fcmp-special.ll
@@ -161,6 +161,7 @@ define <2 x i1> @ord_vec_with_undef(<2 x double> %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, float %y) {
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
+}
+
OpenPOWER on IntegriCloud