[PATCH] D45191: [LoopReroll] Rewrite induction variable rewriting.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 24 14:04:33 PDT 2018


fhahn added a comment.

In https://reviews.llvm.org/D45191#1077281, @efriedma wrote:

> > I am probably missing something, but maybe we could avoid the overflow by doing the re-writing of the induction variables/exit conditions closer to the original range for the induction variables?
>
> The fundamental problem is that the rerolled loop could have a trip count that doesn't fit into a single register, even if the original loop's trip count does fit (e.g. on a 32-bit target, the original loop has a trip count 2^31, we reroll by a factor of four, and the new loop has a trip count of 2^33).  So handling overflow correctly in general requires some extra code in the rerolled loop.


Ah okay. After a very brief look I thought we only support loops like `for ( i = start; i < end; i += scale)` for which trip count should be something like `(end - start) / scale` and the original `i` should fit into (start, end]. In that case, the induction variable in the re-rolled loop could fit into (start, end] too.


Repository:
  rL LLVM

https://reviews.llvm.org/D45191





More information about the llvm-commits mailing list