[llvm-dev] SCEV cannot compute the trip count of Simple loop

Sanjoy Das via llvm-dev llvm-dev at lists.llvm.org
Fri Sep 16 13:27:41 PDT 2016


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


More information about the llvm-dev mailing list