Hi, I wonder how many of you are familiar with scalar evolution pass. I met a problem regarding to the SCEVAddRecExpr. Say for the code: const int N = 100; int a[N]; for(int i=0;i<N;i++) a[i] = 0; For the access of a[i], the pass will transform this a[i] to a SCEVAddRecExpr <@a, +, sizeof(int)><BB_Name>, which means the access of the array `a' starts from the address `a' and has an access stride of `sizeof(int)'. However, when this code is slightly modified: const int N=100; int a[N]; int i; for(i=0;i<N-1; i++) {} a[i] = 0; So the loop is empty and there's an access of `a[i]' (actually a[99] in this case), this a[i] will still be transformed into the same SCEVAddRecExpr as above. This does not really seem to make sense to me because the access pattern is not really so at all. Is is a small bug in this tool? Thank you! -- View this message in context: http://old.nabble.com/About-Scalar-Evolution-Pass-and-SCEVAddRecExpr-tp33745284p33745284.html Sent from the LLVM - Dev mailing list archive at Nabble.com.
Hongbin Zheng
2012-Apr-25 16:16 UTC
[LLVMdev] About Scalar Evolution Pass and SCEVAddRecExpr
Hi, You may try function "getSCEVAtScope" of the ScalarEvolution analysis: /// getSCEVAtScope - Return a SCEV expression for the specified value /// at the specified scope in the program. The L value specifies a loop /// nest to evaluate the expression at, where null is the top-level or a /// specified loop is immediately inside of the loop. /// /// This method can be used to compute the exit value for a variable defined /// in a loop by querying what the value will hold in the parent loop. /// /// In the case that a relevant loop exit value cannot be computed, the /// original value V is returned. best regards ether On Wed, Apr 25, 2012 at 5:16 PM, ihcinihsdk <ali28 at wisc.edu> wrote:> > Hi, > I wonder how many of you are familiar with scalar evolution pass. I met a > problem regarding to the SCEVAddRecExpr. Say for the code: > const int N = 100; > int a[N]; > for(int i=0;i<N;i++) a[i] = 0; > For the access of a[i], the pass will transform this a[i] to a > SCEVAddRecExpr <@a, +, sizeof(int)><BB_Name>, which means the access of the > array `a' starts from the address `a' and has an access stride of > `sizeof(int)'. > However, when this code is slightly modified: > > const int N=100; > int a[N]; > int i; > for(i=0;i<N-1; i++) {} > a[i] = 0; > > So the loop is empty and there's an access of `a[i]' (actually a[99] in this > case), this a[i] will still be transformed into the same SCEVAddRecExpr as > above. This does not really seem to make sense to me because the access > pattern is not really so at all. Is is a small bug in this tool? Thank you! > -- > View this message in context: http://old.nabble.com/About-Scalar-Evolution-Pass-and-SCEVAddRecExpr-tp33745284p33745284.html > Sent from the LLVM - Dev mailing list archive at Nabble.com. > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Hi, thank you for your suggestion. It works well now! Hongbin Zheng wrote:> > Hi, > > You may try function "getSCEVAtScope" of the ScalarEvolution analysis: > > /// getSCEVAtScope - Return a SCEV expression for the specified value > /// at the specified scope in the program. The L value specifies a loop > /// nest to evaluate the expression at, where null is the top-level or a > /// specified loop is immediately inside of the loop. > /// > /// This method can be used to compute the exit value for a variable > defined > /// in a loop by querying what the value will hold in the parent loop. > /// > /// In the case that a relevant loop exit value cannot be computed, the > /// original value V is returned. > > best regards > ether > > On Wed, Apr 25, 2012 at 5:16 PM, ihcinihsdk <ali28 at wisc.edu> wrote: >> >> Hi, >> I wonder how many of you are familiar with scalar evolution pass. I met a >> problem regarding to the SCEVAddRecExpr. Say for the code: >> const int N = 100; >> int a[N]; >> for(int i=0;i<N;i++) a[i] = 0; >> For the access of a[i], the pass will transform this a[i] to a >> SCEVAddRecExpr <@a, +, sizeof(int)><BB_Name>, which means the access of >> the >> array `a' starts from the address `a' and has an access stride of >> `sizeof(int)'. >> However, when this code is slightly modified: >> >> const int N=100; >> int a[N]; >> int i; >> for(i=0;i<N-1; i++) {} >> a[i] = 0; >> >> So the loop is empty and there's an access of `a[i]' (actually a[99] in >> this >> case), this a[i] will still be transformed into the same SCEVAddRecExpr >> as >> above. This does not really seem to make sense to me because the access >> pattern is not really so at all. Is is a small bug in this tool? Thank >> you! >> -- >> View this message in context: >> http://old.nabble.com/About-Scalar-Evolution-Pass-and-SCEVAddRecExpr-tp33745284p33745284.html >> Sent from the LLVM - Dev mailing list archive at Nabble.com. >> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-- View this message in context: http://old.nabble.com/About-Scalar-Evolution-Pass-and-SCEVAddRecExpr-tp33745284p33747887.html Sent from the LLVM - Dev mailing list archive at Nabble.com.