[llvm] 721ecc9 - [ConstraintElimination] Transfer info from sgt %a, %b to ugt %a, %b if %b > 0
Zain Jaffal via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 17 01:28:46 PDT 2023
Author: Zain Jaffal
Date: 2023-04-17T09:27:33+01:00
New Revision: 721ecc9d413c1043c28924bcec700b4dd46ca2f4
URL: https://github.com/llvm/llvm-project/commit/721ecc9d413c1043c28924bcec700b4dd46ca2f4
DIFF: https://github.com/llvm/llvm-project/commit/721ecc9d413c1043c28924bcec700b4dd46ca2f4.diff
LOG: [ConstraintElimination] Transfer info from sgt %a, %b to ugt %a, %b if %b > 0
Differential Revision: https://reviews.llvm.org/D148326
Added:
Modified:
llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
llvm/test/Transforms/ConstraintElimination/gep-sub.ll
llvm/test/Transforms/ConstraintElimination/signed-query-unsigned-system.ll
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 762061b1435de..f87839e15a586 100644
--- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
@@ -582,11 +582,15 @@ void ConstraintInfo::transferToOtherSystem(
if (doesHold(CmpInst::ICMP_SGE, A, ConstantInt::get(B->getType(), 0)))
addFact(CmpInst::ICMP_ULT, A, B, NumIn, NumOut, DFSInStack);
break;
- case CmpInst::ICMP_SGT:
+ 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), NumIn,
NumOut, DFSInStack);
+ if (doesHold(CmpInst::ICMP_SGE, B, ConstantInt::get(B->getType(), 0)))
+ addFact(CmpInst::ICMP_UGT, A, B, 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, NumIn, NumOut, DFSInStack);
diff --git a/llvm/test/Transforms/ConstraintElimination/gep-sub.ll b/llvm/test/Transforms/ConstraintElimination/gep-sub.ll
index b499e280c1e37..3effb6a20d0ca 100644
--- a/llvm/test/Transforms/ConstraintElimination/gep-sub.ll
+++ b/llvm/test/Transforms/ConstraintElimination/gep-sub.ll
@@ -195,7 +195,7 @@ define i1 @gep_sub_ult_var_idx_sgt_1(ptr %dst, ptr %upper, i8 %idx) {
; CHECK-NEXT: [[CMP_SUB_1:%.*]] = icmp ult ptr [[DST_SUB_1]], [[UPPER]]
; CHECK-NEXT: [[DST_SUB_2:%.*]] = getelementptr inbounds i8, ptr [[DST_ADD_IDX]], i64 -2
; CHECK-NEXT: [[CMP_SUB_2:%.*]] = icmp ult ptr [[DST_SUB_2]], [[UPPER]]
-; CHECK-NEXT: [[RES_1:%.*]] = xor i1 [[CMP_SUB_1]], [[CMP_SUB_2]]
+; CHECK-NEXT: [[RES_1:%.*]] = xor i1 true, true
; CHECK-NEXT: [[DST_SUB_3:%.*]] = getelementptr inbounds i8, ptr [[DST_ADD_IDX]], i64 -3
; CHECK-NEXT: [[CMP_SUB_3:%.*]] = icmp ult ptr [[DST_SUB_3]], [[UPPER]]
; CHECK-NEXT: [[RES_2:%.*]] = xor i1 [[RES_1]], [[CMP_SUB_3]]
diff --git a/llvm/test/Transforms/ConstraintElimination/signed-query-unsigned-system.ll b/llvm/test/Transforms/ConstraintElimination/signed-query-unsigned-system.ll
index a78f175541587..104002886bfae 100644
--- a/llvm/test/Transforms/ConstraintElimination/signed-query-unsigned-system.ll
+++ b/llvm/test/Transforms/ConstraintElimination/signed-query-unsigned-system.ll
@@ -39,7 +39,7 @@ define i1 @sgt_0_unsigned_a_sgt_0(i8 %a) {
; CHECK-NEXT: call void @llvm.assume(i1 [[A_SGT_0]])
; CHECK-NEXT: [[EXT:%.*]] = zext i8 [[A]] to i16
; CHECK-NEXT: [[T:%.*]] = icmp sgt i16 [[EXT]], 0
-; CHECK-NEXT: ret i1 [[T]]
+; CHECK-NEXT: ret i1 true
;
%a.sgt.0 = icmp sgt i8 %a, 0
call void @llvm.assume(i1 %a.sgt.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 6e130aaf32c6d..a2d40ab26c554 100644
--- a/llvm/test/Transforms/ConstraintElimination/transfer-signed-facts-to-unsigned.ll
+++ b/llvm/test/Transforms/ConstraintElimination/transfer-signed-facts-to-unsigned.ll
@@ -580,7 +580,7 @@ define i1 @sgt_known_pos(i8 %idx) {
; CHECK-NEXT: call void @llvm.assume(i1 [[CMP]])
; CHECK-NEXT: [[T_1:%.*]] = icmp ugt i8 [[IDX]], 2
; CHECK-NEXT: [[T_2:%.*]] = icmp ugt i8 [[IDX]], 1
-; CHECK-NEXT: [[RES_1:%.*]] = xor i1 [[T_1]], [[T_2]]
+; CHECK-NEXT: [[RES_1:%.*]] = xor i1 true, true
; CHECK-NEXT: [[C_1:%.*]] = icmp ugt i8 [[IDX]], 3
; CHECK-NEXT: [[RES_2:%.*]] = xor i1 [[RES_1]], [[C_1]]
; CHECK-NEXT: ret i1 [[RES_2]]
@@ -602,7 +602,7 @@ define i1 @sgt_to_ugt(i8 %a) {
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[A:%.*]], 2
; CHECK-NEXT: call void @llvm.assume(i1 [[CMP]])
; CHECK-NEXT: [[T_1:%.*]] = icmp ugt i8 [[A]], 2
-; CHECK-NEXT: ret i1 [[T_1]]
+; CHECK-NEXT: ret i1 true
;
entry:
%cmp = icmp sgt i8 %a, 2
@@ -617,7 +617,7 @@ define i1 @sgt_to_ugt_less(i8 %a) {
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[A:%.*]], 2
; CHECK-NEXT: call void @llvm.assume(i1 [[CMP]])
; CHECK-NEXT: [[T_1:%.*]] = icmp ugt i8 [[A]], 1
-; CHECK-NEXT: ret i1 [[T_1]]
+; CHECK-NEXT: ret i1 true
;
entry:
%cmp = icmp sgt i8 %a, 2
@@ -634,7 +634,7 @@ define i1 @sgt_to_ugt_var(i8 %a, i8 %b) {
; CHECK-NEXT: call void @llvm.assume(i1 [[CMP]])
; CHECK-NEXT: call void @llvm.assume(i1 [[CMP_2]])
; CHECK-NEXT: [[T_1:%.*]] = icmp ugt i8 [[A]], [[B]]
-; CHECK-NEXT: ret i1 [[T_1]]
+; CHECK-NEXT: ret i1 true
;
entry:
%cmp = icmp sgt i8 %a, %b
More information about the llvm-commits
mailing list