aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/ProfileData/MemProfTest.cpp
diff options
context:
space:
mode:
authorAlex MacLean <amaclean@nvidia.com>2025-06-10 07:55:56 -0700
committerGitHub <noreply@github.com>2025-06-10 07:55:56 -0700
commit09029045a88b48591ce645bae640fc3bc8b58b63 (patch)
treeff1e52a4dac9489f7ab522cf5f6baef9fa551bd3 /llvm/unittests/ProfileData/MemProfTest.cpp
parente74d834cb155a894fa0f9dbd1483b7fef53a79ae (diff)
downloadllvm-09029045a88b48591ce645bae640fc3bc8b58b63.zip
llvm-09029045a88b48591ce645bae640fc3bc8b58b63.tar.gz
llvm-09029045a88b48591ce645bae640fc3bc8b58b63.tar.bz2
[InstCombine] Fold max/min when incrementing/decrementing by 1 (#142466)
Add the following folds for integer min max folding in InstCombine: - (X > Y) ? X : (Y - 1) ==> MIN(X, Y - 1) - (X < Y) ? X : (Y + 1) ==> MAX(X, Y + 1) These are safe when overflow corresponding to the sign of the comparison is poison. (proof https://alive2.llvm.org/ce/z/oj5iiI). The most common of these patterns is likely the minimum case which occurs in some internal library code when clamping an integer index to a range (The maximum cases are included for completeness). Here is a simplified example: int clampToWidth(int idx, int width) { if (idx >= width) return width - 1; return idx; } https://cuda.godbolt.org/z/nhPzWrc3W
Diffstat (limited to 'llvm/unittests/ProfileData/MemProfTest.cpp')
0 files changed, 0 insertions, 0 deletions