[llvm] [X86] Do not use movq in -mcmodel=kernel on an out of range abs global (PR #163323)
Peter Collingbourne via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 14 12:51:05 PDT 2025
================
@@ -1256,8 +1256,19 @@ def : Pat<(i64 (X86Wrapper tconstpool :$dst)),
(MOV64ri32 tconstpool :$dst)>, Requires<[KernelCode]>;
def : Pat<(i64 (X86Wrapper tjumptable :$dst)),
(MOV64ri32 tjumptable :$dst)>, Requires<[KernelCode]>;
-def : Pat<(i64 (X86Wrapper tglobaladdr :$dst)),
- (MOV64ri32 tglobaladdr :$dst)>, Requires<[KernelCode]>;
+
+// If the globaladdr has an absolute_symbol range, we should assert it would
+// fit into a 32-bit offset.
+def inRange32GlobalAddr : PatLeaf<(tglobaladdr:$dst), [{
+ auto *GA = cast<GlobalAddressSDNode>(N);
+ std::optional<ConstantRange> CR = GA->getGlobal()->getAbsoluteSymbolRange();
----------------
pcc wrote:
I think this can be simplified to `return !GA->getGlobal()->getAbsoluteSymbolRange();`. There is no benefit to using the sign extending instruction with absolute symbols.
https://github.com/llvm/llvm-project/pull/163323
More information about the llvm-commits
mailing list