[llvm] [InstCombine] Fold `icmp samesign u{gt/ge/lt/le} (X +nsw C2), C` -> `icmp s{gt/ge/lt/le} X, (C - C2)` (PR #169960)
Andreas Jonson via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 28 14:07:08 PST 2025
andjo403 wrote:
Good start is to look at https://llvm.org/docs/InstCombineContributorGuide.html
is missing a general proof like https://alive2.llvm.org/ce/z/dyczJy that shows that this code is missing handling of cases when the C - C2 calculation overflow.
there is a fold above the new fold that handled this case without the samesign flag.
also more test is needed eg. where there is signed and unsigned overflow of C - C2 calculation, test where add is "nuw nsw"
there also is this old https://github.com/llvm/llvm-project/pull/134556 PR that is trying to solve the same thing that have comments that is not handled.
https://github.com/llvm/llvm-project/pull/169960
More information about the llvm-commits
mailing list