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

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 21 01:04:26 PDT 2026


nikic wrote:

I'm curious if there is some larger motivation for this? As-is, this trades an add for a shl, which is fine as a matter of canonicalization, I'm just wondering if this is needed to enable some optimization as a followup.

On llvm-opt-benchmark the main impact seems to be trading the add for a ashr (because the argument is usually already an ashr) and dropping a != 0 assume, as the fact can now be directly derived.

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


More information about the llvm-commits mailing list