Skip to content

Commit 67f1e8d

Browse files
committed
[Transforms] Remove FactorOutConstant to fix -Wunneeded-internal-declaration (NFC)
/Users/jiefu/llvm-project/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp:293:13: error: function 'FactorOutConstant' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration] static bool FactorOutConstant(const SCEV *&S, const SCEV *&Remainder, ^ 1 error generated.
1 parent 91f886a commit 67f1e8d

File tree

1 file changed

+0
-73
lines changed

1 file changed

+0
-73
lines changed

llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -286,79 +286,6 @@ Value *SCEVExpander::InsertBinop(Instruction::BinaryOps Opcode,
286286
return BO;
287287
}
288288

289-
/// FactorOutConstant - Test if S is divisible by Factor, using signed
290-
/// division. If so, update S with Factor divided out and return true.
291-
/// S need not be evenly divisible if a reasonable remainder can be
292-
/// computed.
293-
static bool FactorOutConstant(const SCEV *&S, const SCEV *&Remainder,
294-
const SCEV *Factor, ScalarEvolution &SE,
295-
const DataLayout &DL) {
296-
// Everything is divisible by one.
297-
if (Factor->isOne())
298-
return true;
299-
300-
// x/x == 1.
301-
if (S == Factor) {
302-
S = SE.getConstant(S->getType(), 1);
303-
return true;
304-
}
305-
306-
// For a Constant, check for a multiple of the given factor.
307-
if (const SCEVConstant *C = dyn_cast<SCEVConstant>(S)) {
308-
// 0/x == 0.
309-
if (C->isZero())
310-
return true;
311-
// Check for divisibility.
312-
if (const SCEVConstant *FC = dyn_cast<SCEVConstant>(Factor)) {
313-
ConstantInt *CI =
314-
ConstantInt::get(SE.getContext(), C->getAPInt().sdiv(FC->getAPInt()));
315-
// If the quotient is zero and the remainder is non-zero, reject
316-
// the value at this scale. It will be considered for subsequent
317-
// smaller scales.
318-
if (!CI->isZero()) {
319-
const SCEV *Div = SE.getConstant(CI);
320-
S = Div;
321-
Remainder = SE.getAddExpr(
322-
Remainder, SE.getConstant(C->getAPInt().srem(FC->getAPInt())));
323-
return true;
324-
}
325-
}
326-
}
327-
328-
// In a Mul, check if there is a constant operand which is a multiple
329-
// of the given factor.
330-
if (const SCEVMulExpr *M = dyn_cast<SCEVMulExpr>(S)) {
331-
// Size is known, check if there is a constant operand which is a multiple
332-
// of the given factor. If so, we can factor it.
333-
if (const SCEVConstant *FC = dyn_cast<SCEVConstant>(Factor))
334-
if (const SCEVConstant *C = dyn_cast<SCEVConstant>(M->getOperand(0)))
335-
if (!C->getAPInt().srem(FC->getAPInt())) {
336-
SmallVector<const SCEV *, 4> NewMulOps(M->operands());
337-
NewMulOps[0] = SE.getConstant(C->getAPInt().sdiv(FC->getAPInt()));
338-
S = SE.getMulExpr(NewMulOps);
339-
return true;
340-
}
341-
}
342-
343-
// In an AddRec, check if both start and step are divisible.
344-
if (const SCEVAddRecExpr *A = dyn_cast<SCEVAddRecExpr>(S)) {
345-
const SCEV *Step = A->getStepRecurrence(SE);
346-
const SCEV *StepRem = SE.getConstant(Step->getType(), 0);
347-
if (!FactorOutConstant(Step, StepRem, Factor, SE, DL))
348-
return false;
349-
if (!StepRem->isZero())
350-
return false;
351-
const SCEV *Start = A->getStart();
352-
if (!FactorOutConstant(Start, Remainder, Factor, SE, DL))
353-
return false;
354-
S = SE.getAddRecExpr(Start, Step, A->getLoop(),
355-
A->getNoWrapFlags(SCEV::FlagNW));
356-
return true;
357-
}
358-
359-
return false;
360-
}
361-
362289
/// SimplifyAddOperands - Sort and simplify a list of add operands. NumAddRecs
363290
/// is the number of SCEVAddRecExprs present, which are kept at the end of
364291
/// the list.

0 commit comments

Comments
 (0)