[llvm] [InstCombine] Optimize unneeded float to int cast when icmp (PR #155501)

Artem Trokhymchuk via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 7 07:40:43 PDT 2025


trokhymchuk wrote:

> > * `icmp sgt (fptosi %x), <non-negative> -> fcmp oge %x, <non-negative + 1>`: https://alive2.llvm.org/ce/z/sdZTgm
> > * `icmp slt (fptosi %x), <non-positive> -> fcmp ole %x, <non-positive - 1>:` https://alive2.llvm.org/ce/z/kwQv2U
> 
> It looks like these two have an additional pre-condition on the min/max value, but it doesn't seem to be checked in your implementation?

thsnk for noticing, I added those corner-cases and thought that `ConstantFoldBinaryOpOperands` would return nullptr, but looks like it would not...

I added `m_MaxSignedValue()` and `m_MinSignedValue()` checks, later one was not implemented so I added it also

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


More information about the llvm-commits mailing list