Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp =================================================================== --- llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -6129,10 +6129,14 @@ // truncating it to the width of the bitmask is safe. Value *ShiftAmt = Builder.CreateZExtOrTrunc(Index, MapTy, "switch.cast"); - // Multiply the shift amount by the element width. + // Multiply the shift amount by the element width. NUW/NSW can always be + // set, because WouldFitInRegister guarantees Index * ShiftAmt is in + // BitMap's bit width. ShiftAmt = Builder.CreateMul( ShiftAmt, ConstantInt::get(MapTy, BitMapElementTy->getBitWidth()), - "switch.shiftamt"); + "switch.shiftamt", + /*HasNUW =*/true, + /*HasNSW =*/true); // Shift down. Value *DownShifted =