InstCombine: Detect when llvm.umul.with.overflow always overflows

We know overflow always occurs if both ~LHSKnownZero * ~RHSKnownZero
and LHSKnownOne * RHSKnownOne overflow.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225077 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Majnemer
2015-01-02 07:29:47 +00:00
parent 25e8e79fab
commit 5e9c6212a8
3 changed files with 31 additions and 7 deletions

View File

@@ -443,6 +443,8 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
OverflowResult OR = computeOverflowForUnsignedMul(LHS, RHS, II);
if (OR == OverflowResult::NeverOverflows) {
return CreateOverflowTuple(II, Builder->CreateNUWMul(LHS, RHS), false);
} else if (OR == OverflowResult::AlwaysOverflows) {
return CreateOverflowTuple(II, Builder->CreateMul(LHS, RHS), true);
}
} // FALL THROUGH
case Intrinsic::smul_with_overflow: