[llvm] [SCEVDivision] Prevent propagation of incorrect no-wrap flags (PR #154745)

Ryotaro Kasuga via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 21 07:19:21 PDT 2025


kasuga-fj wrote:

> Sorry, the description is somewhat wrong... I'm reconsidering about it.

It turned out to be correct after all. This case hasn’t occurred only because delinearization doesn’t make such a call right now. After making some changes to the delinearization code, I was able to reproduce it. [The test I added](https://github.com/llvm/llvm-project/blob/1e2b6d4c5631b1d228fbe3fecc5134de76c7be7a/llvm/test/Analysis/Delinearization/wraps.ll#L3-L31) is a special case of it, where `%n` is 42. Maybe I should write unittests?

> SCEV does not guarantee that `%m * %n` does not wrap. I think the current code is incorrect in reporting that the result of dividing `%m * %n` by `%n` is `q = %m, r = 0`. This is only valid if we have appropriate nowrap flags.
> 
> https://alive2.llvm.org/ce/z/UcgT45

Hm, it seem somewhat useful when we just want to do something like symbolic execution, but it’s also quite misleading...

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


More information about the llvm-commits mailing list