[llvm] [InstCombine] Canonicalize `icmp pred (X +/- C1), C2` into `icmp pred X, C2 -/+ C1` with nowrap flag implied by with.overflow intrinsic (PR #75511)

Andy Sadler via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 15 14:01:52 PST 2023


sadlerap wrote:

@dtcxzyw I'm not entirely sure it's necessary.  LLVM already optimizes [the signed case][1], and it seems that underflowing subtraction is already optimized [for unsigned integers][2].  As far as I can tell, InstCombine was already handling underflowing subtraction - it looks like overflowing addition wasn't getting handled as well.

[1]: https://godbolt.org/z/djqfv9dvz
[2]: https://godbolt.org/z/c8jKPPEPM

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


More information about the llvm-commits mailing list