summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2017-09-03 15:35:10 +0000
committerSanjay Patel <spatel@rotateright.com>2017-09-03 15:35:10 +0000
commit661beccdd93365a41979abfa742675c293ef1dd6 (patch)
treec1a0b1955fbba9d9c19c4a7ed8e3f8765498a69a /llvm/test
parent2c3bbe44352fe0011cb75d3cc8e59d5630e4ceb0 (diff)
downloadbcm5719-llvm-661beccdd93365a41979abfa742675c293ef1dd6.tar.gz
bcm5719-llvm-661beccdd93365a41979abfa742675c293ef1dd6.zip
[InstCombine] add tests for fcmp ord/uno canonicalization; NFC
Currently, we canonicalize some cases to use 0.0, but we miss others. llvm-svn: 312445
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Transforms/InstCombine/and-fcmp.ll24
-rw-r--r--llvm/test/Transforms/InstCombine/fcmp-special.ll123
-rw-r--r--llvm/test/Transforms/InstCombine/or-fcmp.ll24
3 files changed, 171 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/and-fcmp.ll b/llvm/test/Transforms/InstCombine/and-fcmp.ll
index 553533392c1..7bf300d9a14 100644
--- a/llvm/test/Transforms/InstCombine/and-fcmp.ll
+++ b/llvm/test/Transforms/InstCombine/and-fcmp.ll
@@ -28,6 +28,30 @@ define <2 x i1> @t9(<2 x float> %a, <2 x double> %b) {
ret <2 x i1> %and
}
+define i1 @fcmp_ord_nonzero(float %x, float %y) {
+; CHECK-LABEL: @fcmp_ord_nonzero(
+; CHECK-NEXT: [[TMP1:%.*]] = fcmp ord float %x, %y
+; CHECK-NEXT: ret i1 [[TMP1]]
+;
+ %cmp1 = fcmp ord float %x, 1.0
+ %cmp2 = fcmp ord float %y, 2.0
+ %and = and i1 %cmp1, %cmp2
+ ret i1 %and
+}
+
+define <3 x i1> @fcmp_ord_nonzero_vec(<3 x float> %x, <3 x float> %y) {
+; CHECK-LABEL: @fcmp_ord_nonzero_vec(
+; CHECK-NEXT: [[CMP1:%.*]] = fcmp ord <3 x float> %x, <float 1.000000e+00, float 2.000000e+00, float 3.000000e+00>
+; CHECK-NEXT: [[CMP2:%.*]] = fcmp ord <3 x float> %y, <float 3.000000e+00, float 2.000000e+00, float 1.000000e+00>
+; CHECK-NEXT: [[AND:%.*]] = and <3 x i1> [[CMP1]], [[CMP2]]
+; CHECK-NEXT: ret <3 x i1> [[AND]]
+;
+ %cmp1 = fcmp ord <3 x float> %x, <float 1.0, float 2.0, float 3.0>
+ %cmp2 = fcmp ord <3 x float> %y, <float 3.0, float 2.0, float 1.0>
+ %and = and <3 x i1> %cmp1, %cmp2
+ ret <3 x i1> %and
+}
+
define i1 @auto_gen_0(double %a, double %b) {
; CHECK-LABEL: @auto_gen_0(
; CHECK-NEXT: ret i1 false
diff --git a/llvm/test/Transforms/InstCombine/fcmp-special.ll b/llvm/test/Transforms/InstCombine/fcmp-special.ll
index bef71ef67f3..dcb88832323 100644
--- a/llvm/test/Transforms/InstCombine/fcmp-special.ll
+++ b/llvm/test/Transforms/InstCombine/fcmp-special.ll
@@ -21,3 +21,126 @@ define i1 @une_self(double %x) {
ret i1 %tmp
}
+; When just checking for a NaN (ORD/UNO), canonicalize constants.
+; Float/double are alternated for additional coverage.
+
+define i1 @ord_zero(float %x) {
+; CHECK-LABEL: @ord_zero(
+; CHECK-NEXT: [[F:%.*]] = fcmp ord float %x, 0.000000e+00
+; CHECK-NEXT: ret i1 [[F]]
+;
+ %f = fcmp ord float %x, 0.0
+ ret i1 %f
+}
+
+define i1 @ord_nonzero(double %x) {
+; CHECK-LABEL: @ord_nonzero(
+; CHECK-NEXT: [[F:%.*]] = fcmp ord double %x, 3.000000e+00
+; CHECK-NEXT: ret i1 [[F]]
+;
+ %f = fcmp ord double %x, 3.0
+ ret i1 %f
+}
+
+define i1 @ord_self(float %x) {
+; CHECK-LABEL: @ord_self(
+; CHECK-NEXT: [[F:%.*]] = fcmp ord float %x, 0.000000e+00
+; CHECK-NEXT: ret i1 [[F]]
+;
+ %f = fcmp ord float %x, %x
+ ret i1 %f
+}
+
+define i1 @uno_zero(double %x) {
+; CHECK-LABEL: @uno_zero(
+; CHECK-NEXT: [[F:%.*]] = fcmp uno double %x, 0.000000e+00
+; CHECK-NEXT: ret i1 [[F]]
+;
+ %f = fcmp uno double %x, 0.0
+ ret i1 %f
+}
+
+define i1 @uno_nonzero(float %x) {
+; CHECK-LABEL: @uno_nonzero(
+; CHECK-NEXT: [[F:%.*]] = fcmp uno float %x, 3.000000e+00
+; CHECK-NEXT: ret i1 [[F]]
+;
+ %f = fcmp uno float %x, 3.0
+ ret i1 %f
+}
+
+define i1 @uno_self(double %x) {
+; CHECK-LABEL: @uno_self(
+; CHECK-NEXT: [[F:%.*]] = fcmp uno double %x, 0.000000e+00
+; CHECK-NEXT: ret i1 [[F]]
+;
+ %f = fcmp uno double %x, %x
+ ret i1 %f
+}
+
+define <2 x i1> @ord_zero_vec(<2 x double> %x) {
+; CHECK-LABEL: @ord_zero_vec(
+; CHECK-NEXT: [[F:%.*]] = fcmp ord <2 x double> %x, zeroinitializer
+; CHECK-NEXT: ret <2 x i1> [[F]]
+;
+ %f = fcmp ord <2 x double> %x, zeroinitializer
+ ret <2 x i1> %f
+}
+
+define <2 x i1> @ord_nonzero_vec(<2 x float> %x) {
+; CHECK-LABEL: @ord_nonzero_vec(
+; CHECK-NEXT: [[F:%.*]] = fcmp ord <2 x float> %x, <float 3.000000e+00, float 5.000000e+00>
+; CHECK-NEXT: ret <2 x i1> [[F]]
+;
+ %f = fcmp ord <2 x float> %x, <float 3.0, float 5.0>
+ ret <2 x i1> %f
+}
+
+define <2 x i1> @ord_self_vec(<2 x double> %x) {
+; CHECK-LABEL: @ord_self_vec(
+; CHECK-NEXT: [[F:%.*]] = fcmp ord <2 x double> %x, zeroinitializer
+; CHECK-NEXT: ret <2 x i1> [[F]]
+;
+ %f = fcmp ord <2 x double> %x, %x
+ ret <2 x i1> %f
+}
+
+define <2 x i1> @uno_zero_vec(<2 x float> %x) {
+; CHECK-LABEL: @uno_zero_vec(
+; CHECK-NEXT: [[F:%.*]] = fcmp uno <2 x float> %x, zeroinitializer
+; CHECK-NEXT: ret <2 x i1> [[F]]
+;
+ %f = fcmp uno <2 x float> %x, zeroinitializer
+ ret <2 x i1> %f
+}
+
+define <2 x i1> @uno_nonzero_vec(<2 x double> %x) {
+; CHECK-LABEL: @uno_nonzero_vec(
+; CHECK-NEXT: [[F:%.*]] = fcmp uno <2 x double> %x, <double 3.000000e+00, double 5.000000e+00>
+; CHECK-NEXT: ret <2 x i1> [[F]]
+;
+ %f = fcmp uno <2 x double> %x, <double 3.0, double 5.0>
+ ret <2 x i1> %f
+}
+
+define <2 x i1> @uno_self_vec(<2 x float> %x) {
+; CHECK-LABEL: @uno_self_vec(
+; CHECK-NEXT: [[F:%.*]] = fcmp uno <2 x float> %x, zeroinitializer
+; CHECK-NEXT: ret <2 x i1> [[F]]
+;
+ %f = fcmp uno <2 x float> %x, %x
+ ret <2 x i1> %f
+}
+
+; If a scalar constant is NaN in any of the above tests, it would have been eliminated by InstSimplify.
+; If a vector has a NaN element, we don't do anything with it.
+
+define <2 x i1> @uno_vec_with_nan(<2 x double> %x) {
+; CHECK-LABEL: @uno_vec_with_nan(
+; CHECK-NEXT: [[F:%.*]] = fcmp uno <2 x double> %x, <double 3.000000e+00, double 0x7FF00000FFFFFFFF>
+; CHECK-NEXT: ret <2 x i1> [[F]]
+;
+ %f = fcmp uno <2 x double> %x, <double 3.0, double 0x7FF00000FFFFFFFF>
+ ret <2 x i1> %f
+}
+
diff --git a/llvm/test/Transforms/InstCombine/or-fcmp.ll b/llvm/test/Transforms/InstCombine/or-fcmp.ll
index 848e2c5d40f..ede6853b657 100644
--- a/llvm/test/Transforms/InstCombine/or-fcmp.ll
+++ b/llvm/test/Transforms/InstCombine/or-fcmp.ll
@@ -1,6 +1,30 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instcombine -S | FileCheck %s
+define i1 @fcmp_uno_nonzero(float %x, float %y) {
+; CHECK-LABEL: @fcmp_uno_nonzero(
+; CHECK-NEXT: [[TMP1:%.*]] = fcmp uno float %x, %y
+; CHECK-NEXT: ret i1 [[TMP1]]
+;
+ %cmp1 = fcmp uno float %x, 1.0
+ %cmp2 = fcmp uno float %y, 2.0
+ %or = or i1 %cmp1, %cmp2
+ ret i1 %or
+}
+
+define <3 x i1> @fcmp_uno_nonzero_vec(<3 x float> %x, <3 x float> %y) {
+; CHECK-LABEL: @fcmp_uno_nonzero_vec(
+; CHECK-NEXT: [[CMP1:%.*]] = fcmp uno <3 x float> %x, <float 1.000000e+00, float 2.000000e+00, float 3.000000e+00>
+; CHECK-NEXT: [[CMP2:%.*]] = fcmp uno <3 x float> %y, <float 3.000000e+00, float 2.000000e+00, float 1.000000e+00>
+; CHECK-NEXT: [[OR:%.*]] = or <3 x i1> [[CMP1]], [[CMP2]]
+; CHECK-NEXT: ret <3 x i1> [[OR]]
+;
+ %cmp1 = fcmp uno <3 x float> %x, <float 1.0, float 2.0, float 3.0>
+ %cmp2 = fcmp uno <3 x float> %y, <float 3.0, float 2.0, float 1.0>
+ %or = or <3 x i1> %cmp1, %cmp2
+ ret <3 x i1> %or
+}
+
define i1 @auto_gen_0(double %a, double %b) {
; CHECK-LABEL: @auto_gen_0(
; CHECK-NEXT: ret i1 false
OpenPOWER on IntegriCloud