[llvm] 912e9e5 - [InstSimplify] add tests for fcmp with infinity constant; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 26 06:04:49 PDT 2020
Author: Sanjay Patel
Date: 2020-07-26T09:04:36-04:00
New Revision: 912e9e526233c54aa08b082c957499fa9124eece
URL: https://github.com/llvm/llvm-project/commit/912e9e526233c54aa08b082c957499fa9124eece
DIFF: https://github.com/llvm/llvm-project/commit/912e9e526233c54aa08b082c957499fa9124eece.diff
LOG: [InstSimplify] add tests for fcmp with infinity constant; NFC
Added:
Modified:
llvm/test/Transforms/InstSimplify/floating-point-compare.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstSimplify/floating-point-compare.ll b/llvm/test/Transforms/InstSimplify/floating-point-compare.ll
index 718a4427e15e..6ce5c5e67b08 100644
--- a/llvm/test/Transforms/InstSimplify/floating-point-compare.ll
+++ b/llvm/test/Transforms/InstSimplify/floating-point-compare.ll
@@ -1070,6 +1070,28 @@ define i1 @is_infinite_or_nan(float %x) {
ret i1 %r
}
+define i1 @is_infinite_or_nan2(float %x) {
+; CHECK-LABEL: @is_infinite_or_nan2(
+; CHECK-NEXT: [[XABS:%.*]] = call nnan ninf float @llvm.fabs.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = fcmp ueq float [[XABS]], 0x7FF0000000000000
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %xabs = call nnan ninf float @llvm.fabs.f32(float %x)
+ %r = fcmp ueq float %xabs, 0x7FF0000000000000
+ ret i1 %r
+}
+
+define <2 x i1> @is_infinite_neg_or_nan(<2 x float> %x) {
+; CHECK-LABEL: @is_infinite_neg_or_nan(
+; CHECK-NEXT: [[X42:%.*]] = fadd nnan ninf <2 x float> [[X:%.*]], <float 4.200000e+01, float 4.200000e+01>
+; CHECK-NEXT: [[R:%.*]] = fcmp ueq <2 x float> [[X42]], <float 0xFFF0000000000000, float 0xFFF0000000000000>
+; CHECK-NEXT: ret <2 x i1> [[R]]
+;
+ %x42 = fadd nnan ninf <2 x float> %x, <float 42.0, float 42.0>
+ %r = fcmp ueq <2 x float> %x42, <float 0xFFF0000000000000, float 0xFFF0000000000000>
+ ret <2 x i1> %r
+}
+
define i1 @is_finite_or_nan(i1 %c, double %x) {
; CHECK-LABEL: @is_finite_or_nan(
; CHECK-NEXT: ret i1 true
@@ -1101,3 +1123,27 @@ define i1 @is_finite_and_ordered(double %x) {
%r = fcmp one double %xx, 0x7FF0000000000000
ret i1 %r
}
+
+define i1 @is_finite(i1 %c, double %x) {
+; CHECK-LABEL: @is_finite(
+; CHECK-NEXT: [[XX:%.*]] = fmul nnan ninf double [[X:%.*]], [[X]]
+; CHECK-NEXT: [[S:%.*]] = select i1 [[C:%.*]], double 4.200000e+01, double [[XX]]
+; CHECK-NEXT: [[R:%.*]] = fcmp one double [[S]], 0x7FF0000000000000
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %xx = fmul nnan ninf double %x, %x
+ %s = select i1 %c, double 42.0, double %xx
+ %r = fcmp one double %s, 0x7FF0000000000000
+ ret i1 %r
+}
+
+define <2 x i1> @is_finite_commute(<2 x i8> %x) {
+; CHECK-LABEL: @is_finite_commute(
+; CHECK-NEXT: [[CAST:%.*]] = uitofp <2 x i8> [[X:%.*]] to <2 x float>
+; CHECK-NEXT: [[R:%.*]] = fcmp one <2 x float> <float 0x7FF0000000000000, float 0x7FF0000000000000>, [[CAST]]
+; CHECK-NEXT: ret <2 x i1> [[R]]
+;
+ %cast = uitofp <2 x i8> %x to <2 x float>
+ %r = fcmp one <2 x float> <float 0x7FF0000000000000, float 0x7FF0000000000000>, %cast
+ ret <2 x i1> %r
+}
More information about the llvm-commits
mailing list