[llvm] [SCEV] Add non-poison/non-zero checks on denominators (PR #117152)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 21 05:32:18 PST 2024


https://github.com/nikic requested changes to this pull request.

I don't think that this approach is correct. If I understand correctly, you're basically trying to add the invariant that simplification of SCEV expressions must preserve undefined behavior. But to achieve that, this would be only a very partial implementation, e.g. we could also lose it through `%div * 0` or `%div - %div` or any number of other ways.

I think the problem here is rather in that particular addrec construction code. We basically have a derefinement issue here, similar to what we see in select simplification.

We could hit similar derefinement issues with poison rather than UB, probably some example involving `umin_seq(%maybe_poison, 0)`. And with @fhahn's patches for per-use nowrap flags, this would become a more significant problem.

So I think what we need to guard against is derefinement when replacing the start value.

https://github.com/llvm/llvm-project/pull/117152


More information about the llvm-commits mailing list