Skip to content

Commit d5e7c27

Browse files
committed
[SCEVExp] Remove special-case handling umul_with_overflow by 1 (NFCI).
b50ad94 added umul_with_overflow simplifications to InstSimplifyFolder (used by SCEVExpander) and 9b1b937 added dead instruction cleanup to SCEVExpander. Remove special handling of umul by 1, handled automatically due to the changes above.
1 parent 770cd43 commit d5e7c27

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2222,20 +2222,11 @@ Value *SCEVExpander::generateOverflowCheck(const SCEVAddRecExpr *AR,
22222222
// Get the backedge taken count and truncate or extended to the AR type.
22232223
Value *TruncTripCount = Builder.CreateZExtOrTrunc(TripCountVal, Ty);
22242224

2225-
Value *MulV, *OfMul;
2226-
if (Step->isOne()) {
2227-
// Special-case Step of one. Potentially-costly `umul_with_overflow` isn't
2228-
// needed, there is never an overflow, so to avoid artificially inflating
2229-
// the cost of the check, directly emit the optimized IR.
2230-
MulV = TruncTripCount;
2231-
OfMul = ConstantInt::getFalse(MulV->getContext());
2232-
} else {
2233-
CallInst *Mul = Builder.CreateIntrinsic(Intrinsic::umul_with_overflow, Ty,
2234-
{AbsStep, TruncTripCount},
2235-
/*FMFSource=*/nullptr, "mul");
2236-
MulV = Builder.CreateExtractValue(Mul, 0, "mul.result");
2237-
OfMul = Builder.CreateExtractValue(Mul, 1, "mul.overflow");
2238-
}
2225+
CallInst *Mul = Builder.CreateIntrinsic(Intrinsic::umul_with_overflow, Ty,
2226+
{AbsStep, TruncTripCount},
2227+
/*FMFSource=*/nullptr, "mul");
2228+
Value *MulV = Builder.CreateExtractValue(Mul, 0, "mul.result");
2229+
Value *OfMul = Builder.CreateExtractValue(Mul, 1, "mul.overflow");
22392230

22402231
Value *Add = nullptr, *Sub = nullptr;
22412232
bool NeedPosCheck = !SE.isKnownNegative(Step);

0 commit comments

Comments
 (0)