[llvm] [AArch64][GlobalISel] Add a constant funnel shift post-legalizer combine. (PR #151912)

David Green via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 24 01:31:39 PDT 2025


davemgreen wrote:

I was wondering whether it would be useful to extend the concept of legality in a few cases beyond just type info to include things like whether an operand is constant and what the constant is. I think this would be more useful to us for shift-like-operations, which might be legal for certain constants, but not in general. It would allow us to write generic post-legalizer combines that we know kept operations legal. The shifts are:
G_SHL, G_ASHR, G_LSHR, G_FSHL, G_FSHR, G_ROTR, G_ROTL
There are also:
G_EXTRACT_VECTOR_ELT/G_INSERT_VECTOR_ELT whether the index is constant.
LOAD/STORE mem operand types.
G_SBFX, G_UBFX?
G_SHUFFLE_VECTOR based on shuffle masks?
G_EXTRACT_SUBVECTOR based on index?
G_SEXT_INREG based on the extend typesize.
G_FPTOSI_SAT, G_FPTOUI_SAT if it needed a separate saturate vs result type (we don't have that in gisel at the moment).
G_CONSTANT, G_FCONSTANT possibly dependant immediate operand value (we can just handle all constants late, which can be a better approach).
G_MEMSET/G_MEMCPY/G_MEMMOVE could be legal if we have MOPS and the size is small enough.
G_VSCALE should be dependant on the scale operand.

So not the most opcodes and some of them might not be useful, but maybe worth considering.

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


More information about the llvm-commits mailing list