Skip to content

Commit

Permalink
[ConstraintElimination] Transfer info from SLT to unsigned system.
Browse files Browse the repository at this point in the history
If A s< B holds, then A u< also holds, if A s>= 0.

https://alive2.llvm.org/ce/z/J4JZuN
  • Loading branch information
fhahn committed Jun 23, 2022
1 parent 30e49a3 commit 9a33f39
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
Expand Up @@ -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),
Expand Down
Expand Up @@ -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]]
Expand Down Expand Up @@ -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]]
Expand Down

0 comments on commit 9a33f39

Please sign in to comment.