Follow-up on Roman's idea expressed in D103959.
- If a Phi has undefined inputs from live blocks:
- and no other inputs, assume it is undef itself;
- and exactly one non-undef input, we can assume that all undefs are equal to this input.
Paths
| Differential D104618
[LoopDeletion] Exploit undef Phi inputs when symbolically executing 1st iteration ClosedPublic Authored by mkazantsev on Jun 20 2021, 11:43 PM.
Details Summary Follow-up on Roman's idea expressed in D103959.
Diff Detail Event TimelineComment Actions Urgh, I double-checked with lang ref and my initial version was fine: Branching on an undefined value is undefined behavior. Rolling back to initial version. Comment Actions Looks good to me, thank you.
It is correct as per langref, but i'm not confident we currently Comment Actions Hi, Comment Actions I would suggest splitting this into two patches. The "ignore undef input in phi" is safe, and commonly done across the optimizer. The "branch on undef" is tricky. Just from a risk management perspective, I think it makes sense to split them into separate changes. If you want to split, you can consider this an LGTM for the "ignore undef input in phi" part, and then continue this review for the "branch on undef" part. mkazantsev added a child revision: D104689: [LoopDeletion] Benefit from branches by undef conditions when symbolically executing 1st iteration.Jun 21 2021, 11:01 PM mkazantsev retitled this revision from [LoopDeletion] Exploit undef when symbolically executing 1st iteration to [LoopDeletion] Exploit undef Phi inputs when symbolically executing 1st iteration. This revision is now accepted and ready to land.Jun 22 2021, 12:44 AM Closed by commit rG842b4c83cb75: [LoopDeletion] Exploit undef Phi inputs when symbolically executing 1st… (authored by mkazantsev). · Explain WhyJun 22 2021, 9:54 PM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 353278 llvm/lib/Transforms/Scalar/LoopDeletion.cpp
llvm/test/Transforms/LoopDeletion/eval_first_iteration.ll
|
nit: they are equal