Skip to content

Commit 01366ef

Browse files
committed
[InstCombine] Address comments.
1 parent ebf3de7 commit 01366ef

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2239,8 +2239,8 @@ static Instruction *foldICmpShlLHSC(ICmpInst &Cmp, Instruction *Shl,
22392239
unsigned TypeBits = C.getBitWidth();
22402240
ICmpInst::Predicate Pred = Cmp.getPredicate();
22412241
if (Cmp.isUnsigned()) {
2242-
assert(!C2->isZero() && C2->ule(C) &&
2243-
"Should be simplified by InstSimplify");
2242+
if (C2->isZero() || C2->ugt(C))
2243+
return nullptr;
22442244
APInt Div, Rem;
22452245
APInt::udivrem(C, *C2, Div, Rem);
22462246
bool CIsPowerOf2 = Rem.isZero() && Div.isPowerOf2();

llvm/test/Transforms/InstCombine/icmp-shl-nuw.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,6 @@ define i1 @fold_icmp_shl_nuw_c3(i32 %x) {
144144
ret i1 %cmp
145145
}
146146

147-
; Negative tests
148-
149147
define i1 @fold_icmp_shl_nuw_c2_indivisible(i32 %x) {
150148
; CHECK-LABEL: @fold_icmp_shl_nuw_c2_indivisible(
151149
; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[X:%.*]], 2
@@ -156,6 +154,8 @@ define i1 @fold_icmp_shl_nuw_c2_indivisible(i32 %x) {
156154
ret i1 %cmp
157155
}
158156

157+
; Negative tests
158+
159159
define i1 @fold_icmp_shl_c2_without_nuw(i32 %x) {
160160
; CHECK-LABEL: @fold_icmp_shl_c2_without_nuw(
161161
; CHECK-NEXT: [[SHL:%.*]] = shl i32 16, [[X:%.*]]

0 commit comments

Comments
 (0)