[llvm] [AArch64] Avoid NEON ORR when NEON and SVE are unavailable (PR #93940)

Sander de Smalen via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 10 03:55:25 PDT 2024


sdesmalen-arm wrote:

> The code sequence here assumes there's no red zone; is that actually enforced somewhere? Can we allocate a stack slot instead of modifying the stack pointer?
> 
> As an alternative, it might be possible to use an integer register here, but I guess allocating that might be a bit complicated.

Good spot!

>From what I can see, it seems better to just disable the Red Zone entirely for now. 

The issue is that the way things currently work, the `COPY` is only expanded post register-allocation and post prologue-epilogue-insertion. Assuming we'd tell PEI to allocate a stack slot, then in the `copyPhysReg` function we'd need to emit the base + offset manually. Then, if the slot is allocated too far away from either the FP/SP, we'd need the Register Scavenger to either give us an extra register or spill a register to access it, but the Register Scavenger is not passed to `copyPhysReg`. I guess we could implement this mechanism manually using the emergency spill slot (or allocating a larger emergency slot for the spill/fill purpose), or as you suggest using a GPR register (for which we'd still need to do some sort of scavenging for free registers). Alternatively, we could also create another post-RA expand pass that runs before PEI, to let PEI do the heavy lifting.

Fixing the problem with a stop-gap (disabling red zone) could be a good first step. And if this turns out to be a genuine performance issue, we can come up with a better mechanism later. Does that make sense?

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


More information about the llvm-commits mailing list