Skip to content

Commit aa257b2

Browse files
committed
Ignore bit-widths of 2 or lower
1 parent ad4cef7 commit aa257b2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,11 +1411,11 @@ Instruction *InstCombinerImpl::visitLShr(BinaryOperator &I) {
14111411

14121412
const APInt *MulC;
14131413
if (match(Op0, m_NUWMul(m_Value(X), m_APInt(MulC)))) {
1414-
if ((*MulC - 1).isPowerOf2() && MulC->logBase2() == ShAmtC) {
1414+
if ((*MulC - 1).isPowerOf2() && MulC->logBase2() == ShAmtC && BitWidth > 2) {
14151415
// Look for a "splat" mul pattern - it replicates bits across each half
14161416
// of a value, so a right shift is just a mask of the low bits:
14171417
// lshr i[2N] (mul nuw X, (2^N)+1), N --> and iN X, (2^N)-1
1418-
if (BitWidth > 2 && ShAmtC * 2 == BitWidth)
1418+
if (ShAmtC * 2 == BitWidth)
14191419
return BinaryOperator::CreateAnd(X, ConstantInt::get(Ty, *MulC - 2));
14201420

14211421
// lshr (mul nuw (X, 2^N + 1)), N -> add nuw (X, lshr(X, N))

0 commit comments

Comments
 (0)