[llvm] [InstCombine] Fold X + umax(X, 1) -> umax(X << 1, 1) (PR #222727)

Andrew Pinski via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 21 01:14:41 PDT 2026


pinskia wrote:

So we end up with this change as
UMin<umax<t*2, 1>, ssize_t_max> (for std::vector<char> )
But that could be umax<ssat_add<t,t>,1> .
So it is not just about the shift but the later transformation into a saturated add (or multiply which has a more complex ir being involved with 8 for the std::vector<int> case) with the min/max swapped around.
Unless you have another suggestion on detecting the signed saturated multiply/add here?

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


More information about the llvm-commits mailing list