Index: lib/Transforms/InstCombine/InstCombineCalls.cpp =================================================================== --- lib/Transforms/InstCombine/InstCombineCalls.cpp +++ lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -2049,6 +2049,10 @@ Constant *ShAmtC; if (match(II->getArgOperand(2), m_Constant(ShAmtC)) && !isa(ShAmtC) && !ShAmtC->containsConstantExpression()) { + // Left or right might be masked + if (SimplifyDemandedBits(II)) + return &CI; + // Canonicalize a shift amount constant operand to modulo the bit-width. Constant *WidthC = ConstantInt::get(Ty, BitWidth); Constant *ModuloC = ConstantExpr::getURem(ShAmtC, WidthC);