[llvm] [BasicAA] Use nuw attribute of GEPs (PR #98608)

Hari Limaye via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 7 02:39:17 PDT 2024


hazzlim wrote:

> By the way, I put up https://github.com/llvm/llvm-project/pull/102141 as a complement to this, which handles the simpler case where you have both nusw and nuw (or inbounds and nuw). I think many use cases will be covered by that one, but handling for the "nuw only" case is still desirable, it's just trickier.

Thanks for putting that patch up - looks like it will cover the cases we were hoping to catch with this patch in C/C++ code.

> I don't think the approach here is quite right. Consider this case: https://alive2.llvm.org/ce/z/TvPTRV
> 
> Your current implementation will say that the pointers don't alias, but they may. We need to be careful about how the GEP subtraction affects whether NUW still holds afterwards.

Thank you for reviewing and pointing out the issues with this patch - I see that I was not sufficiently considering how the GEP subtraction works in cases such as that example. I guess for this approach to work we'd need to prove that the constant offset between the GEPs does not cross the address space boundary, and its not obvious to me how to do this (without inbounds/nusw).

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


More information about the llvm-commits mailing list