[llvm] 681315d - [ConstraintElimination] Introduce tests for PR66173
Antonio Frighetto via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 23 01:55:45 PDT 2023
Author: Antonio Frighetto
Date: 2023-09-23T08:54:08Z
New Revision: 681315d1139d2a3ea7e8bb55d0a8de961af8761f
URL: https://github.com/llvm/llvm-project/commit/681315d1139d2a3ea7e8bb55d0a8de961af8761f
DIFF: https://github.com/llvm/llvm-project/commit/681315d1139d2a3ea7e8bb55d0a8de961af8761f.diff
LOG: [ConstraintElimination] Introduce tests for PR66173
Introduce test cases for extending
unsigned-to-signed transfer logic.
Added:
Modified:
llvm/test/Transforms/ConstraintElimination/transfer-unsigned-facts-to-signed.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/ConstraintElimination/transfer-unsigned-facts-to-signed.ll b/llvm/test/Transforms/ConstraintElimination/transfer-unsigned-facts-to-signed.ll
index 34b27dd42e338aa..45dc73a9cc11bbb 100644
--- a/llvm/test/Transforms/ConstraintElimination/transfer-unsigned-facts-to-signed.ll
+++ b/llvm/test/Transforms/ConstraintElimination/transfer-unsigned-facts-to-signed.ll
@@ -228,3 +228,108 @@ then:
else:
ret i1 0
}
+
+define i1 @ule_signed_pos_constant_1(i8 %a, i8 %b) {
+; CHECK-LABEL: @ule_signed_pos_constant_1(
+; CHECK-NEXT: [[B_NON_NEG:%.*]] = icmp sge i8 [[B:%.*]], 0
+; CHECK-NEXT: call void @llvm.assume(i1 [[B_NON_NEG]])
+; CHECK-NEXT: [[A_ULE_B:%.*]] = icmp ule i8 [[A:%.*]], [[B]]
+; CHECK-NEXT: call void @llvm.assume(i1 [[A_ULE_B]])
+; CHECK-NEXT: [[SLE_TEST:%.*]] = icmp sle i8 [[A]], [[B]]
+; CHECK-NEXT: [[SLT_TEST:%.*]] = icmp slt i8 [[A]], [[B]]
+; CHECK-NEXT: [[RESULT_XOR:%.*]] = xor i1 [[SLE_TEST]], [[SLT_TEST]]
+; CHECK-NEXT: ret i1 [[RESULT_XOR]]
+;
+ %b_non_neg = icmp sge i8 %b, 0
+ call void @llvm.assume(i1 %b_non_neg)
+ %a_ule_b = icmp ule i8 %a, %b
+ call void @llvm.assume(i1 %a_ule_b)
+
+ %sle_test = icmp sle i8 %a, %b
+ %slt_test = icmp slt i8 %a, %b
+ %result_xor = xor i1 %sle_test, %slt_test
+
+ ret i1 %result_xor
+}
+
+define i1 @ule_signed_pos_constant_2(i8 %a) {
+; CHECK-LABEL: @ule_signed_pos_constant_2(
+; CHECK-NEXT: [[A_ULT_4:%.*]] = icmp ule i8 [[A:%.*]], 4
+; CHECK-NEXT: br i1 [[A_ULT_4]], label [[THEN:%.*]], label [[ELSE:%.*]]
+; CHECK: then:
+; CHECK-NEXT: [[T_0:%.*]] = icmp sge i8 [[A]], 0
+; CHECK-NEXT: [[T_1:%.*]] = icmp sle i8 [[A]], 4
+; CHECK-NEXT: [[RES_1:%.*]] = xor i1 [[T_0]], [[T_1]]
+; CHECK-NEXT: [[C_0:%.*]] = icmp sle i8 [[A]], 5
+; CHECK-NEXT: [[RES_2:%.*]] = xor i1 [[RES_1]], [[C_0]]
+; CHECK-NEXT: ret i1 [[RES_2]]
+; CHECK: else:
+; CHECK-NEXT: [[C_2:%.*]] = icmp sge i8 [[A]], 0
+; CHECK-NEXT: [[C_3:%.*]] = icmp sle i8 [[A]], 4
+; CHECK-NEXT: [[RES_3:%.*]] = xor i1 [[C_2]], [[C_3]]
+; CHECK-NEXT: [[C_4:%.*]] = icmp sle i8 [[A]], 5
+; CHECK-NEXT: [[RES_4:%.*]] = xor i1 [[RES_3]], [[C_4]]
+; CHECK-NEXT: ret i1 [[RES_4]]
+;
+ %a.ult.4 = icmp ule i8 %a, 4
+ br i1 %a.ult.4, label %then, label %else
+
+then:
+ %t.0 = icmp sge i8 %a, 0
+ %t.1 = icmp sle i8 %a, 4
+ %res.1 = xor i1 %t.0, %t.1
+
+ %c.0 = icmp sle i8 %a, 5
+ %res.2 = xor i1 %res.1, %c.0
+ ret i1 %res.2
+
+else:
+ %c.2 = icmp sge i8 %a, 0
+ %c.3 = icmp sle i8 %a, 4
+ %res.3 = xor i1 %c.2, %c.3
+
+ %c.4 = icmp sle i8 %a, 5
+ %res.4 = xor i1 %res.3, %c.4
+
+ ret i1 %res.4
+}
+
+define i1 @uge_assumed_positive_values(i8 %a, i8 %b) {
+; CHECK-LABEL: @uge_assumed_positive_values(
+; CHECK-NEXT: [[A_NON_NEG:%.*]] = icmp sge i8 [[A:%.*]], 0
+; CHECK-NEXT: call void @llvm.assume(i1 [[A_NON_NEG]])
+; CHECK-NEXT: [[A_UGT_B:%.*]] = icmp uge i8 [[A]], [[B:%.*]]
+; CHECK-NEXT: call void @llvm.assume(i1 [[A_UGT_B]])
+; CHECK-NEXT: [[RESULT:%.*]] = icmp sge i8 [[A]], [[B]]
+; CHECK-NEXT: ret i1 [[RESULT]]
+;
+ %a_non_neg = icmp sge i8 %a, 0
+ call void @llvm.assume(i1 %a_non_neg)
+ %a_ugt_b = icmp uge i8 %a, %b
+ call void @llvm.assume(i1 %a_ugt_b)
+
+ %result = icmp sge i8 %a, %b
+
+ ret i1 %result
+}
+
+define i1 @ugt_assumed_positive_values(i8 %a, i8 %b) {
+; CHECK-LABEL: @ugt_assumed_positive_values(
+; CHECK-NEXT: [[A_NON_NEG:%.*]] = icmp sge i8 [[A:%.*]], 0
+; CHECK-NEXT: call void @llvm.assume(i1 [[A_NON_NEG]])
+; CHECK-NEXT: [[A_UGT_B:%.*]] = icmp ugt i8 [[A]], [[B:%.*]]
+; CHECK-NEXT: call void @llvm.assume(i1 [[A_UGT_B]])
+; CHECK-NEXT: [[RESULT:%.*]] = icmp sgt i8 [[A]], [[B]]
+; CHECK-NEXT: ret i1 [[RESULT]]
+;
+ %a_non_neg = icmp sge i8 %a, 0
+ call void @llvm.assume(i1 %a_non_neg)
+ %a_ugt_b = icmp ugt i8 %a, %b
+ call void @llvm.assume(i1 %a_ugt_b)
+
+ %result = icmp sgt i8 %a, %b
+
+ ret i1 %result
+}
+
+declare void @llvm.assume(i1)
More information about the llvm-commits
mailing list