[llvm] [InstCombine] Fix #163110: Fold icmp (shl X, L), (add (shl Y, L), 1<<L) to icmp X, (Y + 1) (PR #165975)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Sat Dec 20 09:09:51 PST 2025
dtcxzyw wrote:
> Is this specific optimization expected to be handled by a more generic shift distribution rule?Or are you suggesting that using getShiftedValue is necessary to handle other, potentially more complex, but unproven patterns that might contain this specific case as a sub-pattern?
Yes. I'd like to see a general solution that reuses existing logic. This significantly reduces the maintenance burden (e.g., pre-condition checking/multi-use handling/flag propagation). For example, if you extend `canEvaluateShifted/getShiftedValue` to support ashr/add nsw in this patch, it will be free to cancel out ashr when the next time someone wants another similar fold like this: https://alive2.llvm.org/ce/z/9u-eTV
https://github.com/llvm/llvm-project/pull/165975
More information about the llvm-commits
mailing list