[llvm] 2fc67af - [InstCombine] Add test for fold fcmp-of-copysign. nfc
Chenbing Zheng via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 24 02:30:15 PDT 2022
Author: Chenbing Zheng
Date: 2022-04-24T17:26:15+08:00
New Revision: 2fc67af487aa3c2915797a6f2abd4c06e6c1eb08
URL: https://github.com/llvm/llvm-project/commit/2fc67af487aa3c2915797a6f2abd4c06e6c1eb08
DIFF: https://github.com/llvm/llvm-project/commit/2fc67af487aa3c2915797a6f2abd4c06e6c1eb08.diff
LOG: [InstCombine] Add test for fold fcmp-of-copysign. nfc
Add more tests with differert predicates.
Added:
Modified:
llvm/test/Transforms/InstCombine/fcmp.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/fcmp.ll b/llvm/test/Transforms/InstCombine/fcmp.ll
index 7ababebe3b0dd..731174e87c716 100644
--- a/llvm/test/Transforms/InstCombine/fcmp.ll
+++ b/llvm/test/Transforms/InstCombine/fcmp.ll
@@ -592,6 +592,39 @@ define i1 @is_signbit_set(double %x) {
ret i1 %r
}
+define i1 @is_signbit_set_1(double %x) {
+; CHECK-LABEL: @is_signbit_set_1(
+; CHECK-NEXT: [[S:%.*]] = call double @llvm.copysign.f64(double 1.000000e+00, double [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = fcmp ult double [[S]], 0.000000e+00
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %s = call double @llvm.copysign.f64(double 1.0, double %x)
+ %r = fcmp ult double %s, 0.0
+ ret i1 %r
+}
+
+define i1 @is_signbit_set_2(double %x) {
+; CHECK-LABEL: @is_signbit_set_2(
+; CHECK-NEXT: [[S:%.*]] = call double @llvm.copysign.f64(double 1.000000e+00, double [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = fcmp ole double [[S]], 0.000000e+00
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %s = call double @llvm.copysign.f64(double 1.0, double %x)
+ %r = fcmp ole double %s, 0.0
+ ret i1 %r
+}
+
+define i1 @is_signbit_set_3(double %x) {
+; CHECK-LABEL: @is_signbit_set_3(
+; CHECK-NEXT: [[S:%.*]] = call double @llvm.copysign.f64(double 1.000000e+00, double [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = fcmp ule double [[S]], 0.000000e+00
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %s = call double @llvm.copysign.f64(double 1.0, double %x)
+ %r = fcmp ule double %s, 0.0
+ ret i1 %r
+}
+
; Vectors are ok; the sign of zero in the compare doesn't matter; the copysign constant can be any non-zero number.
define <2 x i1> @is_signbit_set_anyzero(<2 x double> %x) {
@@ -618,6 +651,39 @@ define i1 @is_signbit_clear(double %x) {
ret i1 %r
}
+define i1 @is_signbit_clear_1(double %x) {
+; CHECK-LABEL: @is_signbit_clear_1(
+; CHECK-NEXT: [[S:%.*]] = call double @llvm.copysign.f64(double -4.200000e+01, double [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = fcmp ugt double [[S]], 0.000000e+00
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %s = call double @llvm.copysign.f64(double -42.0, double %x)
+ %r = fcmp ugt double %s, 0.0
+ ret i1 %r
+}
+
+define i1 @is_signbit_clear_2(double %x) {
+; CHECK-LABEL: @is_signbit_clear_2(
+; CHECK-NEXT: [[S:%.*]] = call double @llvm.copysign.f64(double -4.200000e+01, double [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = fcmp oge double [[S]], 0.000000e+00
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %s = call double @llvm.copysign.f64(double -42.0, double %x)
+ %r = fcmp oge double %s, 0.0
+ ret i1 %r
+}
+
+define i1 @is_signbit_clear_3(double %x) {
+; CHECK-LABEL: @is_signbit_clear_3(
+; CHECK-NEXT: [[S:%.*]] = call double @llvm.copysign.f64(double -4.200000e+01, double [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = fcmp uge double [[S]], 0.000000e+00
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %s = call double @llvm.copysign.f64(double -42.0, double %x)
+ %r = fcmp uge double %s, 0.0
+ ret i1 %r
+}
+
; Negative test - uses
define i1 @is_signbit_set_extra_use(double %x, double* %p) {
More information about the llvm-commits
mailing list