[llvm-dev] PHI nodes and connected ICMp

Sanjoy Das via llvm-dev llvm-dev at lists.llvm.org
Sun Aug 13 20:00:29 PDT 2017


Hi,

On Sun, Aug 13, 2017 at 5:58 AM, Anastasiya Ruzhanskaya via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> And still, aren't there any possibilities to find that phi node, that led
> SCEV to compute max trip count?

So there is no good  answer to your question since in most cases SCEV
does not directly look at PHI nodes (or expressions based off of the
PHI node).  It converts PHI nodes and related expressions into SCEV
expressions and computes trip counts off of these SCEV expressions;
and there is no reliable way to map a SCEV expression back into a PHI
node (though it may be possible in some cases).

However this is sounding like an XY problem (http://xyproblem.info/)
:)  Do you mind taking a step back and giving us some information
about the broader picture?

> 2017-08-13 14:55 GMT+02:00 Anastasiya Ruzhanskaya
>> To continue this topic:
>> sometimes SCEV's behavior is rather controversial : for loops with i
>> changing as i \=2 for example, he can't figure what the type of expressions
>> is, but surprisingly can determine max trip count. Shouldn't it be able to
>> detect or not detect  these parameters at the same time?

SCEV expressions cannot represent recurrences that are are divided by
some amount every iteration.  And while not being able to represent
induction variables as SCEV expressions does make it more difficult to
compute trip counts, SCEV has some other patterns it tries to
recognize even in cases where the relevant expressions could not be
mapped to neat SCEV add recurrences.  Another example: SCEV can
compute the trip counts for strlen-like loops:
https://godbolt.org/g/hWtEWm

-- Sanjoy


More information about the llvm-dev mailing list