Kiva 0383cd0f77
[InstCombine] Fold fcmp (C - [su]itofp X), C to integer compares (#185826)
Recognize `fcmp pred (C - [su]itofp X), C` in InstCombine and fold it to
`fcmp swap(pred) [su]itofp X, 0` for certain constant `C` (to make sure
`C - Y` nevers rounds back to `C`), then the new pattern further can be
folded by `foldFCmpIntToFPConst` to integer compares.

Fixes #185561
alive2: https://alive2.llvm.org/ce/z/9dWsCb
alive2 with constant constraints (needs local alive2 build):
https://alive2.llvm.org/ce/z/wDs9Tj

I tried generalizing the pattern to any `fcmp pred, (C - Y), C` but
alive2 says no: https://alive2.llvm.org/ce/z/qMLGah. So I will try to
find more constraints on C and Y to make this rewrite hold in future
PRs.
2026-03-26 20:18:15 +01:00
..

The LLVM Compiler Infrastructure
================================

This directory and its subdirectories contain source code for LLVM,
a toolkit for the construction of highly optimized compilers,
optimizers, and runtime environments.

LLVM is open source software. You may freely distribute it under the terms of
the license agreement found in LICENSE.txt.

Please see the documentation provided in docs/ for further
assistance with LLVM, and in particular docs/GettingStarted.rst for getting
started with LLVM and docs/README.txt for an overview of LLVM's
documentation setup.

If you are writing a package for LLVM, see docs/Packaging.rst for our
suggestions.