@@ -427,14 +427,15 @@ std::pair<MemoryLocationRange, bool> aggregate(
427427 if (Bounds->getDirection () == Loop::LoopBounds::Direction::Increasing) {
428428 if (Predicate == Predicate::ICMP_SLT ||
429429 Predicate == Predicate::ICMP_ULT) {
430- FinalSCEV = SE->getMinusSCEV (FinalSCEV,
431- SE->getOne (FinalSCEV->getType ()));
430+ FinalSCEV = subtractSCEVAndCast (FinalSCEV,
431+ SE->getOne (FinalSCEV->getType ()),
432+ SE);
432433 }
433434 } else {
434435 if (Predicate == Predicate::ICMP_SGT ||
435436 Predicate == Predicate::ICMP_UGT) {
436- FinalSCEV = SE-> getAddExpr (SE->getOne (FinalSCEV->getType ()),
437- FinalSCEV);
437+ FinalSCEV = addSCEVAndCast (SE->getOne (FinalSCEV->getType ()),
438+ FinalSCEV, SE );
438439 }
439440 }
440441 LLVM_DEBUG (dbgs () << " [AGGREGATE] AddRecType: " ; C->getType ()->dump ());
@@ -445,19 +446,19 @@ std::pair<MemoryLocationRange, bool> aggregate(
445446 if (LoopStep > 0 && IdxExprStep > 0 ) {
446447 DimInfo.Start = ZeroItr;
447448 DimInfo.End = C->evaluateAtIteration (
448- SE-> getMinusSCEV (FinalSCEV, InitSCEV), *SE);
449+ subtractSCEVAndCast (FinalSCEV, InitSCEV, SE ), *SE);
449450 } else if (LoopStep > 0 && IdxExprStep < 0 ) {
450451 DimInfo.Start = C->evaluateAtIteration (
451- SE-> getMinusSCEV (FinalSCEV, InitSCEV), *SE);
452+ subtractSCEVAndCast (FinalSCEV, InitSCEV, SE ), *SE);
452453 DimInfo.End = ZeroItr;
453454 } else if (LoopStep < 0 && IdxExprStep > 0 ) {
454455 DimInfo.Start = C->evaluateAtIteration (
455- SE-> getMinusSCEV (InitSCEV, FinalSCEV), *SE);
456+ subtractSCEVAndCast (InitSCEV, FinalSCEV, SE ), *SE);
456457 DimInfo.End = ZeroItr;
457458 } else {
458459 DimInfo.Start = ZeroItr;
459460 DimInfo.End = C->evaluateAtIteration (
460- SE-> getMinusSCEV (InitSCEV, FinalSCEV), *SE);
461+ subtractSCEVAndCast (InitSCEV, FinalSCEV, SE ), *SE);
461462 }
462463 auto CmpStartEnd = compareSCEVs (DimInfo.Start , DimInfo.End , SE);
463464 if (CmpStartEnd && *CmpStartEnd > 0 ) {
0 commit comments