@@ -428,14 +428,15 @@ std::pair<MemoryLocationRange, bool> aggregate(
428428 if (Bounds->getDirection () == Loop::LoopBounds::Direction::Increasing) {
429429 if (Predicate == Predicate::ICMP_SLT ||
430430 Predicate == Predicate::ICMP_ULT) {
431- FinalSCEV = SE->getMinusSCEV (FinalSCEV,
432- SE->getOne (FinalSCEV->getType ()));
431+ FinalSCEV = subtractSCEVAndCast (FinalSCEV,
432+ SE->getOne (FinalSCEV->getType ()),
433+ SE);
433434 }
434435 } else {
435436 if (Predicate == Predicate::ICMP_SGT ||
436437 Predicate == Predicate::ICMP_UGT) {
437- FinalSCEV = SE-> getAddExpr (SE->getOne (FinalSCEV->getType ()),
438- FinalSCEV);
438+ FinalSCEV = addSCEVAndCast (SE->getOne (FinalSCEV->getType ()),
439+ FinalSCEV, SE );
439440 }
440441 }
441442 LLVM_DEBUG (dbgs () << " [AGGREGATE] AddRecType: " ; C->getType ()->dump ());
@@ -446,19 +447,19 @@ std::pair<MemoryLocationRange, bool> aggregate(
446447 if (LoopStep > 0 && IdxExprStep > 0 ) {
447448 DimInfo.Start = ZeroItr;
448449 DimInfo.End = C->evaluateAtIteration (
449- SE-> getMinusSCEV (FinalSCEV, InitSCEV), *SE);
450+ subtractSCEVAndCast (FinalSCEV, InitSCEV, SE ), *SE);
450451 } else if (LoopStep > 0 && IdxExprStep < 0 ) {
451452 DimInfo.Start = C->evaluateAtIteration (
452- SE-> getMinusSCEV (FinalSCEV, InitSCEV), *SE);
453+ subtractSCEVAndCast (FinalSCEV, InitSCEV, SE ), *SE);
453454 DimInfo.End = ZeroItr;
454455 } else if (LoopStep < 0 && IdxExprStep > 0 ) {
455456 DimInfo.Start = C->evaluateAtIteration (
456- SE-> getMinusSCEV (InitSCEV, FinalSCEV), *SE);
457+ subtractSCEVAndCast (InitSCEV, FinalSCEV, SE ), *SE);
457458 DimInfo.End = ZeroItr;
458459 } else {
459460 DimInfo.Start = ZeroItr;
460461 DimInfo.End = C->evaluateAtIteration (
461- SE-> getMinusSCEV (InitSCEV, FinalSCEV), *SE);
462+ subtractSCEVAndCast (InitSCEV, FinalSCEV, SE ), *SE);
462463 }
463464 auto CmpStartEnd = compareSCEVs (DimInfo.Start , DimInfo.End , SE);
464465 if (CmpStartEnd && *CmpStartEnd > 0 ) {
0 commit comments