[PATCH] Loop Rerolling Pass
    Hal Finkel 
    hfinkel at anl.gov
       
    Thu Oct 17 11:33:00 PDT 2013
    
    
  
----- Original Message -----
> 
> 
> 
> On Oct 17, 2013, at 10:30 AM, Hal Finkel < hfinkel at anl.gov > wrote:
> 
> 
> 
> 
> If the loop is testing less-than constant ’n’, I think we already
> handle it (knowing n < INT_MAX-stride). I’m not sure what we do for
> equals ’n’.
> 
> No, that does not currently work. Compiling the following with clang:
> 
> void foo(int n, int *x) {
> for (int i = 0; i < n; i += 3) {
> x[i] = i;
> x[i+1] = i+1;
> x[i+2] = i+2;
> }
> }
> 
> I find that SE->hasLoopInvariantBackedgeTakenCount(L) returns false.
> From what you're saying, this sounds like a bug, no?
> 
> By “constant n” I meant “a constant” ;)
Right, and the constant case works. The variable case does not, and if I understand correctly, this is the 'we ignore the nsw flag' case. If we get to assume that i += 3 does not wrap, then we can positively return a backedge taken count of n/3-1, right?
You had also said that we need to make clear what the number returned means (because we can't actually guarantee that many iterations in the face of functions that might throw, etc.), but I don't see how this interpretation concern is affected by whether or not n is a constant. Are these two issues related?
Thanks again,
Hal
> -Andy
-- 
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory
    
    
More information about the llvm-commits
mailing list