diff --git a/llvm/lib/CodeGen/TypePromotion.cpp b/llvm/lib/CodeGen/TypePromotion.cpp --- a/llvm/lib/CodeGen/TypePromotion.cpp +++ b/llvm/lib/CodeGen/TypePromotion.cpp @@ -359,11 +359,8 @@ return false; // Now check that the result can't wrap on itself. - APInt Total = ICmpConst->getValue().getBitWidth() < 32 ? - ICmpConst->getValue().zext(32) : ICmpConst->getValue(); - - Total += OverflowConst->getValue().getBitWidth() < 32 ? - OverflowConst->getValue().abs().zext(32) : OverflowConst->getValue().abs(); + APInt Total = ICmpConst->getValue().zextOrSelf(RegisterBitWidth); + Total += OverflowConst->getValue().abs().zextOrSelf(RegisterBitWidth); APInt Max = APInt::getAllOnes(TypePromotion::TypeSize);