[llvm] [CGP][AArch64] Rebase the common base offset for better ISel (PR #74046)

David Green via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 3 09:21:44 PST 2023


================
@@ -15982,6 +15982,19 @@ bool AArch64TargetLowering::isLegalAddressingMode(const DataLayout &DL,
                                                           AM.Scale);
 }
 
+// Check whether the 2 offsets belong to the same imm24 range, and their high
+// 12bits are same, then their high part can be decoded with the offset of add.
+int64_t AArch64TargetLowering::getPreferBaseOffset(int64_t MinOffset,
+                                                   int64_t MaxOffset) const {
+  int64_t HighPart = MinOffset & 0xfff000;
+  if (MinOffset >> 12 == MaxOffset >> 12 && isLegalAddImmediate(HighPart)) {
----------------
davemgreen wrote:

Maybe do `HighPart = MinOffset & ~0xfffULL;`, to try and capture more ranges.

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


More information about the llvm-commits mailing list