Hi,
In order to better support SVE I’ve extended the LSR pass to be aware of vscale-relative ‘immediates’, so that different (hopefully better) decisions can be made when offsets are a multiple of the in-memory vector size.
The branch for this work can be found here: GitHub - huntergr-arm/llvm-project at vscale-aware-lsr
This did require extending the isLegalAddressingMode and isLegalAddImmediate TTI methods to accept a new FixedOrScalableQuantity type (using a signed Quantity instead of unsigned, as ElementCount does). As such, there’s some no-op changes in non-AArch64 targets to use getFixedValue() in their overridden versions. I wasn’t sure whether to just introduce a new interface instead to avoid changing the other backends, but I suspect that would just open the door to future bugs if someone assumed LSR would never deal with scalable offsets.
I would like some feedback on the approach before carving it up into properly reviewable patches. In particular, for:
- The changes to isLegalAddressing mode mentioned above
- The change in isAlwaysFoldable in LSR where I drop the default ‘scaled’ register if a scalable offset is present. It seems like AArch64 might benefit from dropping that in more cases, but I may have missed something and it’s actually a good idea to keep it.
- The new override for isLSRCostLess in AArch64TargetTransformInfo – the ordering of the terms for comparison is just based on whatever sequence gave me the addressing modes I wanted for SVE without introducing noticeable regressions in our existing unit tests. I’m not sure why we didn’t override this to take instruction count into consideration when many other targets did, but again I may have missed something.
Comments welcome.
Thanks,
-Graham