[TF:XLA] Include the frame name in the identity of and recurrences
This is a correctness fix that is important for users outside the loop
(i.e. users that use that "last value" of the and recurrence). The last value
of the and recurrence depends on how many times the loop executes, which isn't
_just_ a function of the init and step deadness predicate.
For instance if we have a loop like:
Init = ... // Could be live or dead
Step = ... // Could be live or dead
V = Init
for (int i = 0; i < N; i++) {
V = V * Step
}
X = V
Then if N is 0 then X (the "loop exit" value of V) is alive iff Init was alive
(i.e. Predicate(X) == Predicate(Init)). But if N is 1 then X is alive iff both
Init and Step are alive (i.e. Predicate(X) == Predicate(Init) &
Predicate(Step)). We can't infer this dependence of Predicate(X) on N if
Predicate(X) == {Predicate(Init),&,Predicate(Step)} since that does not denote
the dependence on the loop trip count. So we make the frame name (i.e. the
loop) part of the and recurrence identity.
Once I added the control flow inference logic I also noticed that quite a few of
the tests were violating frame invariants. I've fixed those tests.
Also worth pointing out: I've not yet seen this bug cause any problems in the
wild.
PiperOrigin-RevId: 230393971
Loading
Please sign in to comment