@@ -286,79 +286,6 @@ Value *SCEVExpander::InsertBinop(Instruction::BinaryOps Opcode,
286
286
return BO;
287
287
}
288
288
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
-
362
289
// / SimplifyAddOperands - Sort and simplify a list of add operands. NumAddRecs
363
290
// / is the number of SCEVAddRecExprs present, which are kept at the end of
364
291
// / the list.
0 commit comments