[llvm] 9a33f39 - [ConstraintElimination] Transfer info from SLT to unsigned system.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 23 06:58:13 PDT 2022
Author: Florian Hahn
Date: 2022-06-23T15:57:59+02:00
New Revision: 9a33f3975e1a0cbfcfa3e5455b0d1429b98fabf4
URL: https://github.com/llvm/llvm-project/commit/9a33f3975e1a0cbfcfa3e5455b0d1429b98fabf4
DIFF: https://github.com/llvm/llvm-project/commit/9a33f3975e1a0cbfcfa3e5455b0d1429b98fabf4.diff
LOG: [ConstraintElimination] Transfer info from SLT to unsigned system.
If A s< B holds, then A u< also holds, if A s>= 0.
https://alive2.llvm.org/ce/z/J4JZuN
Added:
Modified:
llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
llvm/test/Transforms/ConstraintElimination/transfer-signed-facts-to-unsigned.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
index 9d047640bffbc..6508744e28c04 100644
--- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
@@ -403,6 +403,10 @@ void ConstraintInfo::transferToOtherSystem(
switch (Pred) {
default:
break;
+ case CmpInst::ICMP_SLT:
+ if (doesHold(CmpInst::ICMP_SGE, A, ConstantInt::get(B->getType(), 0)))
+ addFact(CmpInst::ICMP_ULT, A, B, IsNegated, NumIn, NumOut, DFSInStack);
+ break;
case CmpInst::ICMP_SGT:
if (doesHold(CmpInst::ICMP_SGE, B, ConstantInt::get(B->getType(), -1)))
addFact(CmpInst::ICMP_UGE, A, ConstantInt::get(B->getType(), 0),
diff --git a/llvm/test/Transforms/ConstraintElimination/transfer-signed-facts-to-unsigned.ll b/llvm/test/Transforms/ConstraintElimination/transfer-signed-facts-to-unsigned.ll
index e953615a3e848..28f4aa8e5460b 100644
--- a/llvm/test/Transforms/ConstraintElimination/transfer-signed-facts-to-unsigned.ll
+++ b/llvm/test/Transforms/ConstraintElimination/transfer-signed-facts-to-unsigned.ll
@@ -13,7 +13,7 @@ define i1 @len_known_positive_via_idx_1(i8 %len, i8 %idx) {
; CHECK-NEXT: [[T_2:%.*]] = icmp sge i8 [[LEN]], 0
; CHECK-NEXT: [[C_1:%.*]] = icmp sge i8 [[LEN]], 2
; CHECK-NEXT: [[C_2:%.*]] = icmp sge i8 [[LEN]], 2
-; CHECK-NEXT: [[RES_1:%.*]] = xor i1 [[T_1]], true
+; CHECK-NEXT: [[RES_1:%.*]] = xor i1 true, true
; CHECK-NEXT: [[RES_2:%.*]] = xor i1 [[RES_1]], [[C_1]]
; CHECK-NEXT: [[RES_3:%.*]] = xor i1 [[RES_2]], [[C_2]]
; CHECK-NEXT: ret i1 [[RES_3]]
@@ -609,7 +609,7 @@ define i1 @slt_first_op_known_pos(i8 %idx) {
; CHECK-NEXT: call void @llvm.assume(i1 [[CMP]])
; CHECK-NEXT: [[T_1:%.*]] = icmp ult i8 2, [[IDX]]
; CHECK-NEXT: [[T_2:%.*]] = icmp ult i8 1, [[IDX]]
-; CHECK-NEXT: [[RES_1:%.*]] = xor i1 [[T_1]], [[T_2]]
+; CHECK-NEXT: [[RES_1:%.*]] = xor i1 true, true
; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 3, [[IDX]]
; CHECK-NEXT: [[RES_2:%.*]] = xor i1 [[RES_1]], [[C_1]]
; CHECK-NEXT: ret i1 [[RES_2]]
More information about the llvm-commits
mailing list