[PATCH] D148326: [ConstraintElimination] Transfer info from sgt %a, %b to ugt %a, %b if %b > 0
Zain Jaffal via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 17 01:28:47 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG721ecc9d413c: [ConstraintElimination] Transfer info from sgt %a, %b to ugt %a, %b if %b > 0 (authored by zjaffal).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148326/new/
https://reviews.llvm.org/D148326
Files:
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
Index: llvm/test/Transforms/ConstraintElimination/transfer-signed-facts-to-unsigned.ll
===================================================================
--- llvm/test/Transforms/ConstraintElimination/transfer-signed-facts-to-unsigned.ll
+++ llvm/test/Transforms/ConstraintElimination/transfer-signed-facts-to-unsigned.ll
@@ -580,7 +580,7 @@
; 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 @@
; 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 @@
; 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 @@
; 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
Index: llvm/test/Transforms/ConstraintElimination/signed-query-unsigned-system.ll
===================================================================
--- llvm/test/Transforms/ConstraintElimination/signed-query-unsigned-system.ll
+++ llvm/test/Transforms/ConstraintElimination/signed-query-unsigned-system.ll
@@ -39,7 +39,7 @@
; 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)
Index: llvm/test/Transforms/ConstraintElimination/gep-sub.ll
===================================================================
--- llvm/test/Transforms/ConstraintElimination/gep-sub.ll
+++ llvm/test/Transforms/ConstraintElimination/gep-sub.ll
@@ -195,7 +195,7 @@
; 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]]
Index: llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
+++ llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
@@ -582,11 +582,15 @@
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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148326.514135.patch
Type: text/x-patch
Size: 4120 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230417/c0bcd904/attachment.bin>
More information about the llvm-commits
mailing list