[llvm] [AArch64] Fold vector shifts guarded against oversized amounts into USHL (PR #207628)

Adam Scott via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 9 18:14:34 PDT 2026


as4230 wrote:

> Sounds good. This seems to do two separate combines, one for select(shift) and one for shift(select)? Can we do the first one first?
> 
> Is there a reason not to add sra at the same time?

FWIW the x86 version did both in one PR but im happy to split it. This PR will do just the select(shift) form and shift(select) will be a separate PR. 

sra doesn't work for select(shift) because for an out-of-range amount the select forces 0 but sshl saturates the sign bit so e.g. ashr(-1, 40) would be -1 where select needs 0. So only shl/lshr line up here since those zero-fill. It does work for the shift(select) form though since out-of-range lanes are already poison so I can include it when I move the code over to that PR 

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


More information about the llvm-commits mailing list