Shuo Wang via llvm-dev
2016-Mar-19 08:16 UTC
[llvm-dev] Iteration distance failed in DependenceAnalysis C++ API
Hi LLVM-ers, (1) I tried to use the following command line to get the iteration distance of a loop-carried dependence of a simple program : command line: opt -basicaa -da -analyze dis_test.ll program: for ( int i=0; j < n; ++i ) { b[i] = b[i-2] + 3; } results: da analyze — none! da analyze — consistent anti [-2] (This is what I expected!!) da analyze — none! (2) However, when I tried to use the C++ API to do the same thing, the distance result is null. My pass: class IterationDistance : public DependenceAnalysis { ... void getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); AU.addRequired<AliasAnalysis>(); AU.addRequired<LoopInfo>(); AU.addRequired<ScalarEvolution>(); AU.addRequired<DependenceAnalysis>(); } ... DependenceAnalysis *DA = &(getAnalysis<DependenceAnalysis>()); auto D = DA->depends(Src, Des, true); if (D->isAnti()) { unsigned Levels = D->getLevels(); errs() << "levels = " << Levels << "\n"; char Direction; for (unsigned II = 1; II <= Levels; ++II) { ... const SCEV *Distance = D->getDistance(II); const SCEVConstant *SCEVConst = dyn_cast_or_null<SCEVConstant>(Distance); ... } Results: levels = 0; Distance is null. (3) My guess is that the "levels = 0” which makes the Distance cannot be got. Can anyone help me with this? Thanks! Shvo -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160319/b6800b18/attachment.html>