[llvm] 24a9888 - [ConstraintElimination] Transfer info from SGT to unsigned system.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 23 02:05:02 PDT 2022
Author: Florian Hahn
Date: 2022-06-23T11:04:51+02:00
New Revision: 24a98881cdb458376fc23ace6247b62084b4ad38
URL: https://github.com/llvm/llvm-project/commit/24a98881cdb458376fc23ace6247b62084b4ad38
DIFF: https://github.com/llvm/llvm-project/commit/24a98881cdb458376fc23ace6247b62084b4ad38.diff
LOG: [ConstraintElimination] Transfer info from SGT to unsigned system.
If A >s B then A >=u 0, if B >=s -1.
https://alive2.llvm.org/ce/z/cncGKi
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 f3bbc77084778..9d047640bffbc 100644
--- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
@@ -403,6 +403,11 @@ void ConstraintInfo::transferToOtherSystem(
switch (Pred) {
default:
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),
+ IsNegated, NumIn, NumOut, DFSInStack);
+ break;
case CmpInst::ICMP_SGE:
if (doesHold(CmpInst::ICMP_SGE, B, ConstantInt::get(B->getType(), 0))) {
addFact(CmpInst::ICMP_UGE, A, B, IsNegated, NumIn, NumOut, DFSInStack);
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 0eb95323a4d61..e953615a3e848 100644
--- a/llvm/test/Transforms/ConstraintElimination/transfer-signed-facts-to-unsigned.ll
+++ b/llvm/test/Transforms/ConstraintElimination/transfer-signed-facts-to-unsigned.ll
@@ -164,7 +164,7 @@ define i1 @cnt_positive_sgt_against_base(ptr %p, i32 %cnt) {
; CHECK-NEXT: tail call void @llvm.assume(i1 [[CMP]])
; CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i32, ptr [[P:%.*]], i32 [[CNT]]
; CHECK-NEXT: [[CMP_1:%.*]] = icmp uge ptr [[ADD_PTR]], [[P]]
-; CHECK-NEXT: br i1 [[CMP_1]], label [[THEN:%.*]], label [[ELSE:%.*]]
+; CHECK-NEXT: br i1 true, label [[THEN:%.*]], label [[ELSE:%.*]]
; CHECK: then:
; CHECK-NEXT: ret i1 false
; CHECK: else:
@@ -246,7 +246,7 @@ define i1 @cnt_positive_sgt_against_base_with_zext(ptr %p, i32 %cnt) {
; CHECK-NEXT: [[EXT:%.*]] = zext i32 [[CNT]] to i64
; CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i32, ptr [[P:%.*]], i64 [[EXT]]
; CHECK-NEXT: [[CMP_1:%.*]] = icmp uge ptr [[ADD_PTR]], [[P]]
-; CHECK-NEXT: br i1 [[CMP_1]], label [[THEN:%.*]], label [[ELSE:%.*]]
+; CHECK-NEXT: br i1 true, label [[THEN:%.*]], label [[ELSE:%.*]]
; CHECK: then:
; CHECK-NEXT: ret i1 false
; CHECK: else:
@@ -563,7 +563,7 @@ define i1 @sgt_known_neg(i8 %idx) {
; CHECK-NEXT: call void @llvm.assume(i1 [[CMP]])
; CHECK-NEXT: [[T_1:%.*]] = icmp uge i8 [[IDX]], 0
; CHECK-NEXT: [[T_2:%.*]] = icmp uge i8 [[IDX]], 1
-; CHECK-NEXT: [[RES_1:%.*]] = xor i1 [[T_1]], [[T_2]]
+; CHECK-NEXT: [[RES_1:%.*]] = xor i1 true, [[T_2]]
; CHECK-NEXT: [[C_1:%.*]] = icmp ugt i8 [[IDX]], -1
; CHECK-NEXT: [[RES_2:%.*]] = xor i1 [[RES_1]], [[C_1]]
; CHECK-NEXT: ret i1 [[RES_2]]
More information about the llvm-commits
mailing list