Index: lib/Transforms/InstCombine/InstCombineMulDivRem.cpp =================================================================== --- lib/Transforms/InstCombine/InstCombineMulDivRem.cpp +++ lib/Transforms/InstCombine/InstCombineMulDivRem.cpp @@ -171,14 +171,13 @@ if (match(&I, m_Mul(m_Value(NewOp), m_Constant(C1)))) { // Replace X*(2^C) with X << C, where C is either a scalar or a vector. if (Constant *NewCst = getLogBase2(NewOp->getType(), C1)) { - unsigned Width = NewCst->getType()->getPrimitiveSizeInBits(); BinaryOperator *Shl = BinaryOperator::CreateShl(NewOp, NewCst); if (I.hasNoUnsignedWrap()) Shl->setHasNoUnsignedWrap(); if (I.hasNoSignedWrap()) { const APInt *V; - if (match(NewCst, m_APInt(V)) && *V != Width - 1) + if (match(NewCst, m_APInt(V)) && *V != V->getBitWidth() - 1) Shl->setHasNoSignedWrap(); } Index: test/Transforms/InstCombine/mul.ll =================================================================== --- test/Transforms/InstCombine/mul.ll +++ test/Transforms/InstCombine/mul.ll @@ -409,7 +409,7 @@ define <2 x i32> @test32vec(<2 x i32> %X) { ; CHECK-LABEL: @test32vec( -; CHECK-NEXT: [[MUL:%.*]] = shl nsw <2 x i32> [[X:%.*]], +; CHECK-NEXT: [[MUL:%.*]] = shl <2 x i32> [[X:%.*]], ; CHECK-NEXT: ret <2 x i32> [[MUL]] ; %mul = mul nsw <2 x i32> %X,