llvm.org GIT mirror llvm / 047a636
[PATCH] Force LoopReroll to reset the loop trip count value after reroll. It's a bug fix. For rerolled loops SE trip count remains unchanged. It leads to incorrect work of the next passes. My patch just resets SE info for rerolled loop forcing SE to re-evaluate it next time it requested. I also added a verifier call in the exisitng test to be sure no invalid SE data remain. Without my fix this test would fail with -verify-scev. Differential Revision: http://reviews.llvm.org/D18316 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264051 91177308-0d34-0410-b5e6-96231b3b80d8 Zinovy Nis 3 years ago
2 changed file(s) with 9 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
15501550 "] Loop %" << Header->getName() << " (" <<
15511551 L->getNumBlocks() << " block(s))\n");
15521552
1553 bool Changed = false;
1554
15551553 // For now, we'll handle only single BB loops.
15561554 if (L->getNumBlocks() > 1)
1557 return Changed;
1555 return false;
15581556
15591557 if (!SE->hasLoopInvariantBackedgeTakenCount(L))
1560 return Changed;
1558 return false;
15611559
15621560 const SCEV *LIBETC = SE->getBackedgeTakenCount(L);
15631561 const SCEV *IterCount = SE->getAddExpr(LIBETC, SE->getOne(LIBETC->getType()));
15711569
15721570 if (PossibleIVs.empty()) {
15731571 DEBUG(dbgs() << "LRR: No possible IVs found\n");
1574 return Changed;
1572 return false;
15751573 }
15761574
15771575 ReductionTracker Reductions;
15781576 collectPossibleReductions(L, Reductions);
1577 bool Changed = false;
15791578
15801579 // For each possible IV, collect the associated possible set of 'root' nodes
15811580 // (i+1, i+2, etc.).
15861585 break;
15871586 }
15881587
1588 // Trip count of L has changed so SE must be re-evaluated.
1589 if (Changed)
1590 SE->forgetLoop(L);
1591
15891592 return Changed;
15901593 }
None ; RUN: opt < %s -loop-reroll -S | FileCheck %s
0 ; RUN: opt < %s -loop-reroll -verify-scev -S | FileCheck %s
11 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
22 target triple = "x86_64-unknown-linux-gnu"
33