Skip to content

Commit

Permalink
[CVP] Flip signedness icmp predicate in use level
Browse files Browse the repository at this point in the history
  • Loading branch information
XChy committed Oct 24, 2023
1 parent befcd38 commit 89f8ce7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,9 @@ static bool processICmp(ICmpInst *Cmp, LazyValueInfo *LVI) {

ICmpInst::Predicate UnsignedPred =
ConstantRange::getEquivalentPredWithFlippedSignedness(
Cmp->getPredicate(), LVI->getConstantRange(Cmp->getOperand(0), Cmp),
LVI->getConstantRange(Cmp->getOperand(1), Cmp));
Cmp->getPredicate(),
LVI->getConstantRangeAtUse(Cmp->getOperandUse(0)),
LVI->getConstantRangeAtUse(Cmp->getOperandUse(1)));

if (UnsignedPred == ICmpInst::Predicate::BAD_ICMP_PREDICATE)
return false;
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/Transforms/CorrelatedValuePropagation/icmp.ll
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,7 @@ define i1 @pr69928(i64 noundef %arg, i64 noundef %arg1) {
; CHECK-NEXT: entry:
; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i64 [[ARG:%.*]], 64424509440
; CHECK-NEXT: [[AND:%.*]] = and i64 [[ARG1:%.*]], 4294967295
; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i64 [[ARG]], [[AND]]
; CHECK-NEXT: [[CMP2:%.*]] = icmp ult i64 [[ARG]], [[AND]]
; CHECK-NEXT: [[SELECT:%.*]] = select i1 [[CMP1]], i1 [[CMP2]], i1 false
; CHECK-NEXT: ret i1 [[SELECT]]
;
Expand All @@ -1268,7 +1268,7 @@ define i1 @test_select_flip(i64 noundef %arg) {
; CHECK-LABEL: @test_select_flip(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i64 [[ARG:%.*]], 1000
; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i64 [[ARG]], 100
; CHECK-NEXT: [[CMP2:%.*]] = icmp ult i64 [[ARG]], 100
; CHECK-NEXT: [[SELECT:%.*]] = select i1 [[CMP1]], i1 [[CMP2]], i1 false
; CHECK-NEXT: ret i1 [[SELECT]]
;
Expand Down

0 comments on commit 89f8ce7

Please sign in to comment.