<div dir="ltr">From the description in <a href="http://llvm.org/docs/Passes.html#loop-reduce-loop-strength-reduction">http://llvm.org/docs/Passes.html#loop-reduce-loop-strength-reduction</a> I expected adding a -loop-reduce pass would transform a simple indexing by the loop variable into a pointer increment, i.e. effectively transforming this:<div><br></div><div><div>  for(int a = 0; a < 64; a++) {</div><div>    s += f(b[a]);</div><div>  }<br></div></div><div><br></div><div>into this:</div><div><br></div><div><div>  int*p = b;</div><div>  for(int a = 0; a < 64; a++) {</div><div>    s+= f(*p);</div><div>    ++p;</div><div>  }<br></div></div><div><br></div><div>But on my toy CPU architecture I actually see the reverse, that the second loop gets converted by -loop-reduce from:</div><div><br></div><div><div>  %p.01 = phi i8* [ %b, %entry ], [ %incdec.ptr, %for.body ]</div><div>  %0 = load i8, i8* %p.01, align 1</div><div>  %call = tail call i8 @_Z1fi(i8 %0)</div><div>  %incdec.ptr = getelementptr inbounds i8, i8* %p.01, i8 1</div></div><div><br></div><div>to:</div><div><br></div><div><div>  %scevgep = getelementptr i8, i8* %b, i8 %a.03</div><div>  %0 = load i8, i8* %scevgep, align 1</div><div>  %call = tail call i8 @_Z1fi(i8 %0)</div></div><div><br></div><div>I suspect it's related to this comment in LoopStrengthReduce.cpp "it rewrites expressions to take advantage of scaled-index addressing modes available on the target" and that my toy architecture lacks appropriate modes (or incorrectly describes what it does have) but I haven't seen what this interaction is. Any advice for where to start debugging / fixing my target handling?</div><div><br></div><div>Thanks!</div></div>