Skip to content

Commit c3b2111

Browse files
committed
Fix PR3874 by restoring a condition I removed, but making it more
precise than it used to be. llvm-svn: 67662
1 parent a6e85a1 commit c3b2111

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

llvm/lib/Transforms/Scalar/InstructionCombining.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6582,7 +6582,8 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
65826582
// preferable because it allows the C<<Y expression to be hoisted out
65836583
// of a loop if Y is invariant and X is not.
65846584
if (Shift && Shift->hasOneUse() && RHSV == 0 &&
6585-
ICI.isEquality() && !Shift->isArithmeticShift()) {
6585+
ICI.isEquality() && !Shift->isArithmeticShift() &&
6586+
!isa<Constant>(Shift->getOperand(0))) {
65866587
// Compute C << Y.
65876588
Value *NS;
65886589
if (Shift->getOpcode() == Instruction::LShr) {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
; PR3874
2+
; RUN: llvm-as < %s | opt -instcombine | llvm-dis
3+
define i1 @test(i32 %x) {
4+
%A = lshr i32 3968, %x
5+
%B = and i32 %A, 1
6+
%C = icmp eq i32 %B, 0
7+
ret i1 %C
8+
}
9+

0 commit comments

Comments
 (0)