[llvm] [InstCombine] Support gep nuw in icmp folds (PR #118472)

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 19 09:46:50 PST 2024


nico wrote:

> `-fwrapv` should already cover pointers

Thanks for pointing this out! I confirmed that that's true. The documentation only talks about it affecting signed overflow.

We'll switch to that, at least for now. It comes with a noticeable binary size hit, but it seems like the least bad option for now.

(The reverts that landed don't seem to help some of the pointer checks that we saw getting deleted, and the compiler warning also didn't catch them due to the addition being stored in a variable before being compared.)

> so you'd like a flag that only makes pointer overflow well-defined, but not signed integer overflow? This should be possible if Clang folks agree.

Yes, that'd be great. I think gcc has that flag already.

If it doesn't yet, this should get a scary-looking release notes entry that mentions possible mitigations :)

(Also, thank you for working on making llvm / clang better in removing unnecessary bounds checks! This is fantastic. The intermediate change breaks us pretty bad, but long term I'm very excited about this, so thanks again!)

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


More information about the llvm-commits mailing list