Skip to content

Commit e1c281d

Browse files
committed
[InstCombine] Drop samesign in InstCombinerImpl::foldICmpAndConstConst
1 parent d179463 commit e1c281d

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1844,6 +1844,7 @@ Instruction *InstCombinerImpl::foldICmpAndConstConst(ICmpInst &Cmp,
18441844
/*HasNUW=*/true),
18451845
One, Or->getName());
18461846
Value *NewAnd = Builder.CreateAnd(A, NewOr, And->getName());
1847+
Cmp.setSameSign(false);
18471848
return replaceOperand(Cmp, 0, NewAnd);
18481849
}
18491850
}

llvm/test/Transforms/InstCombine/icmp.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3208,7 +3208,7 @@ define i1 @icmp_and_or_lshr_samesign(i32 %x, i32 %y) {
32083208
; CHECK-NEXT: [[SHF1:%.*]] = shl nuw i32 1, [[Y:%.*]]
32093209
; CHECK-NEXT: [[OR2:%.*]] = or i32 [[SHF1]], 1
32103210
; CHECK-NEXT: [[AND3:%.*]] = and i32 [[X:%.*]], [[OR2]]
3211-
; CHECK-NEXT: [[RET:%.*]] = icmp samesign ne i32 [[AND3]], 0
3211+
; CHECK-NEXT: [[RET:%.*]] = icmp ne i32 [[AND3]], 0
32123212
; CHECK-NEXT: ret i1 [[RET]]
32133213
;
32143214
%shf = lshr i32 %x, %y

0 commit comments

Comments
 (0)