[PATCH] D116766: [SCEV] Poison-safe `UMin` expression
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 6 23:53:36 PST 2022
nikic added a comment.
Thanks, this is about what I had in mind. The need for this is annoying, but I don't really see a way around it.
In D116766#3226340 <https://reviews.llvm.org/D116766#3226340>, @reames wrote:
> Before you go any further, can you explain what you mean by "poison safe"? What IR are you hoping to generate in the end, and why is that more correct than what we have previously?
>
> p.s. I understand the current code is broken, and why. I just haven't seen a viable proposal for a fix as of yet.
The lowering is `X == 0 ? 0 : umin(X, Y)`, which has the same result as `umin(X, Y)`, except in the case where `X == 0` and `Y == poison`, in which case poison is not propagated. So if you have an always-taken exit with TC=0 that prevents branching on a later poison exit, then this is now modeled correctly.
An alternative lowering would be `umin(X, freeze Y)`.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D116766/new/
https://reviews.llvm.org/D116766
More information about the llvm-commits
mailing list