[llvm] 9c928d0 - [InstCombine] Add tests for reassoc of and/or of fcmps (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 13 07:12:51 PST 2024
Author: Nikita Popov
Date: 2024-11-13T16:12:43+01:00
New Revision: 9c928d0308eb75f52e570d61330975a67e0be71c
URL: https://github.com/llvm/llvm-project/commit/9c928d0308eb75f52e570d61330975a67e0be71c
DIFF: https://github.com/llvm/llvm-project/commit/9c928d0308eb75f52e570d61330975a67e0be71c.diff
LOG: [InstCombine] Add tests for reassoc of and/or of fcmps (NFC)
Added:
Modified:
llvm/test/Transforms/InstCombine/and-fcmp.ll
llvm/test/Transforms/InstCombine/or-fcmp.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/and-fcmp.ll b/llvm/test/Transforms/InstCombine/and-fcmp.ll
index c03c9d69051edd..30b9fca6e97ada 100644
--- a/llvm/test/Transforms/InstCombine/and-fcmp.ll
+++ b/llvm/test/Transforms/InstCombine/and-fcmp.ll
@@ -5042,6 +5042,66 @@ define i1 @isnormal_logical_select_0_fmf1(half %x) {
ret i1 %and
}
+define i1 @and_fcmp_reassoc1(i1 %x, double %a, double %b) {
+; CHECK-LABEL: @and_fcmp_reassoc1(
+; CHECK-NEXT: [[TMP1:%.*]] = fcmp ult double [[A:%.*]], [[B:%.*]]
+; CHECK-NEXT: [[CMP1:%.*]] = fcmp ugt double [[A]], [[B]]
+; CHECK-NEXT: [[RETVAL:%.*]] = and i1 [[TMP1]], [[X:%.*]]
+; CHECK-NEXT: [[RETVAL1:%.*]] = and i1 [[RETVAL]], [[CMP1]]
+; CHECK-NEXT: ret i1 [[RETVAL1]]
+;
+ %cmp = fcmp ult double %a, %b
+ %cmp1 = fcmp ugt double %a, %b
+ %and = and i1 %cmp, %x
+ %retval = and i1 %and, %cmp1
+ ret i1 %retval
+}
+
+define i1 @and_fcmp_reassoc2(i1 %x, double %a, double %b) {
+; CHECK-LABEL: @and_fcmp_reassoc2(
+; CHECK-NEXT: [[TMP1:%.*]] = fcmp ult double [[A:%.*]], [[B:%.*]]
+; CHECK-NEXT: [[CMP1:%.*]] = fcmp ugt double [[A]], [[B]]
+; CHECK-NEXT: [[RETVAL:%.*]] = and i1 [[X:%.*]], [[TMP1]]
+; CHECK-NEXT: [[RETVAL1:%.*]] = and i1 [[RETVAL]], [[CMP1]]
+; CHECK-NEXT: ret i1 [[RETVAL1]]
+;
+ %cmp = fcmp ult double %a, %b
+ %cmp1 = fcmp ugt double %a, %b
+ %and = and i1 %x, %cmp
+ %retval = and i1 %and, %cmp1
+ ret i1 %retval
+}
+
+define i1 @and_fcmp_reassoc3(i1 %x, double %a, double %b) {
+; CHECK-LABEL: @and_fcmp_reassoc3(
+; CHECK-NEXT: [[TMP1:%.*]] = fcmp ult double [[A:%.*]], [[B:%.*]]
+; CHECK-NEXT: [[CMP1:%.*]] = fcmp ugt double [[A]], [[B]]
+; CHECK-NEXT: [[RETVAL:%.*]] = and i1 [[TMP1]], [[X:%.*]]
+; CHECK-NEXT: [[RETVAL1:%.*]] = and i1 [[CMP1]], [[RETVAL]]
+; CHECK-NEXT: ret i1 [[RETVAL1]]
+;
+ %cmp = fcmp ult double %a, %b
+ %cmp1 = fcmp ugt double %a, %b
+ %and = and i1 %cmp, %x
+ %retval = and i1 %cmp1, %and
+ ret i1 %retval
+}
+
+define i1 @and_fcmp_reassoc4(i1 %x, double %a, double %b) {
+; CHECK-LABEL: @and_fcmp_reassoc4(
+; CHECK-NEXT: [[TMP1:%.*]] = fcmp ult double [[A:%.*]], [[B:%.*]]
+; CHECK-NEXT: [[CMP1:%.*]] = fcmp ugt double [[A]], [[B]]
+; CHECK-NEXT: [[RETVAL:%.*]] = and i1 [[X:%.*]], [[TMP1]]
+; CHECK-NEXT: [[RETVAL1:%.*]] = and i1 [[CMP1]], [[RETVAL]]
+; CHECK-NEXT: ret i1 [[RETVAL1]]
+;
+ %cmp = fcmp ult double %a, %b
+ %cmp1 = fcmp ugt double %a, %b
+ %and = and i1 %x, %cmp
+ %retval = and i1 %cmp1, %and
+ ret i1 %retval
+}
+
declare half @llvm.fabs.f16(half)
declare <2 x half> @llvm.fabs.v2f16(<2 x half>)
declare half @llvm.copysign.f16(half, half)
diff --git a/llvm/test/Transforms/InstCombine/or-fcmp.ll b/llvm/test/Transforms/InstCombine/or-fcmp.ll
index 285b2d958abd8c..a2842f7a45f597 100644
--- a/llvm/test/Transforms/InstCombine/or-fcmp.ll
+++ b/llvm/test/Transforms/InstCombine/or-fcmp.ll
@@ -4605,3 +4605,63 @@ define i1 @intersect_fmf_4(double %a, double %b) {
%retval = or i1 %cmp, %cmp1
ret i1 %retval
}
+
+define i1 @or_fcmp_reassoc1(i1 %x, double %a, double %b) {
+; CHECK-LABEL: @or_fcmp_reassoc1(
+; CHECK-NEXT: [[OR:%.*]] = fcmp olt double [[A:%.*]], [[B:%.*]]
+; CHECK-NEXT: [[CMP2:%.*]] = fcmp ogt double [[A]], [[B]]
+; CHECK-NEXT: [[RETVAL:%.*]] = or i1 [[OR]], [[CMP1:%.*]]
+; CHECK-NEXT: [[RETVAL1:%.*]] = or i1 [[RETVAL]], [[CMP2]]
+; CHECK-NEXT: ret i1 [[RETVAL1]]
+;
+ %cmp = fcmp olt double %a, %b
+ %cmp1 = fcmp ogt double %a, %b
+ %or = or i1 %cmp, %x
+ %retval = or i1 %or, %cmp1
+ ret i1 %retval
+}
+
+define i1 @or_fcmp_reassoc2(i1 %x, double %a, double %b) {
+; CHECK-LABEL: @or_fcmp_reassoc2(
+; CHECK-NEXT: [[TMP1:%.*]] = fcmp olt double [[A:%.*]], [[B:%.*]]
+; CHECK-NEXT: [[CMP1:%.*]] = fcmp ogt double [[A]], [[B]]
+; CHECK-NEXT: [[RETVAL:%.*]] = or i1 [[X:%.*]], [[TMP1]]
+; CHECK-NEXT: [[RETVAL1:%.*]] = or i1 [[RETVAL]], [[CMP1]]
+; CHECK-NEXT: ret i1 [[RETVAL1]]
+;
+ %cmp = fcmp olt double %a, %b
+ %cmp1 = fcmp ogt double %a, %b
+ %or = or i1 %x, %cmp
+ %retval = or i1 %or, %cmp1
+ ret i1 %retval
+}
+
+define i1 @or_fcmp_reassoc3(i1 %x, double %a, double %b) {
+; CHECK-LABEL: @or_fcmp_reassoc3(
+; CHECK-NEXT: [[TMP1:%.*]] = fcmp olt double [[A:%.*]], [[B:%.*]]
+; CHECK-NEXT: [[CMP1:%.*]] = fcmp ogt double [[A]], [[B]]
+; CHECK-NEXT: [[RETVAL:%.*]] = or i1 [[TMP1]], [[X:%.*]]
+; CHECK-NEXT: [[RETVAL1:%.*]] = or i1 [[CMP1]], [[RETVAL]]
+; CHECK-NEXT: ret i1 [[RETVAL1]]
+;
+ %cmp = fcmp olt double %a, %b
+ %cmp1 = fcmp ogt double %a, %b
+ %or = or i1 %cmp, %x
+ %retval = or i1 %cmp1, %or
+ ret i1 %retval
+}
+
+define i1 @or_fcmp_reassoc4(i1 %x, double %a, double %b) {
+; CHECK-LABEL: @or_fcmp_reassoc4(
+; CHECK-NEXT: [[TMP1:%.*]] = fcmp olt double [[A:%.*]], [[B:%.*]]
+; CHECK-NEXT: [[CMP1:%.*]] = fcmp ogt double [[A]], [[B]]
+; CHECK-NEXT: [[RETVAL:%.*]] = or i1 [[X:%.*]], [[TMP1]]
+; CHECK-NEXT: [[RETVAL1:%.*]] = or i1 [[CMP1]], [[RETVAL]]
+; CHECK-NEXT: ret i1 [[RETVAL1]]
+;
+ %cmp = fcmp olt double %a, %b
+ %cmp1 = fcmp ogt double %a, %b
+ %or = or i1 %x, %cmp
+ %retval = or i1 %cmp1, %or
+ ret i1 %retval
+}
More information about the llvm-commits
mailing list