[llvm-dev] SCEV cannot compute the trip count of Simple loop
Kevin Choi via llvm-dev
llvm-dev at lists.llvm.org
Fri Sep 16 13:56:43 PDT 2016
> int mat;
> for (p = (x+1) ; p < (x+3) ;p++)
> mat[x][p-1][i] = mat[x][p-1][i] + 5;
The trip count of 2 should be valid for x in [0,6]. If SCEV doesn't catch
it with, say GVN and appropriate matching conditions, it could be improved.
CMIIW, I don't think LLVM goes out of the way to opportunistically version
the loop by inserting if check(s) and then unroll it.
On Fri, Sep 16, 2016 at 1:27 PM, Sanjoy Das via llvm-dev <
llvm-dev at lists.llvm.org> wrote:
> Hi Deepali,
> SCEV reports the backedge taken count as "((-1 * (sext i32 (3 + %x) to
> i64))<nsw> + ((sext i32 (3 + %x) to i64) smax (sext i32 (6 + %x) to
> i64)))", so symbolically it does have an answer.
> Ideally SCEV should be able to exploit <nsw> on (3 + %x) and (6 + %x)
> to fold the expression above to "3", but due to some systemic issues
> SCEV can't exploit <nsw> as aggressively as we should.
> Without exploiting <nsw> the trip count is 2^32, which does not fit in
> an 32 bit unsigned integer. This is why getSmallConstantTripCount
> returns 0.
> Does this answer your question?
> -- Sanjoy
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev