Skip to content

Commit

Permalink
[InstCombine] Address comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
dtcxzyw committed Sep 18, 2024
1 parent ebf3de7 commit 01366ef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2239,8 +2239,8 @@ static Instruction *foldICmpShlLHSC(ICmpInst &Cmp, Instruction *Shl,
unsigned TypeBits = C.getBitWidth();
ICmpInst::Predicate Pred = Cmp.getPredicate();
if (Cmp.isUnsigned()) {
assert(!C2->isZero() && C2->ule(C) &&
"Should be simplified by InstSimplify");
if (C2->isZero() || C2->ugt(C))
return nullptr;
APInt Div, Rem;
APInt::udivrem(C, *C2, Div, Rem);
bool CIsPowerOf2 = Rem.isZero() && Div.isPowerOf2();
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/Transforms/InstCombine/icmp-shl-nuw.ll
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,6 @@ define i1 @fold_icmp_shl_nuw_c3(i32 %x) {
ret i1 %cmp
}

; Negative tests

define i1 @fold_icmp_shl_nuw_c2_indivisible(i32 %x) {
; CHECK-LABEL: @fold_icmp_shl_nuw_c2_indivisible(
; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[X:%.*]], 2
Expand All @@ -156,6 +154,8 @@ define i1 @fold_icmp_shl_nuw_c2_indivisible(i32 %x) {
ret i1 %cmp
}

; Negative tests

define i1 @fold_icmp_shl_c2_without_nuw(i32 %x) {
; CHECK-LABEL: @fold_icmp_shl_c2_without_nuw(
; CHECK-NEXT: [[SHL:%.*]] = shl i32 16, [[X:%.*]]
Expand Down

0 comments on commit 01366ef

Please sign in to comment.