https://gcc.gnu.org/g:55788176f1e103a2912bb3b4b6fad65c480276f9

commit r15-5456-g55788176f1e103a2912bb3b4b6fad65c480276f9
Author: Evgeny Karpov <evgeny.kar...@microsoft.com>
Date:   Thu Sep 12 13:19:32 2024 +0200

    aarch64: Extend the offset limit in "symbol + offset" from 1MB to 16MB
    
    This patch allows using an offset of up to 16MB in "symbol + offset",
    instead of 1MB limit that was used previously.
    
    gcc/ChangeLog:
    
            * config/aarch64/aarch64.cc (aarch64_load_symref_appropriately):
            Update.

Diff:
---
 gcc/config/aarch64/aarch64.cc | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index e5e993d39850..a2945f7fd0b4 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -3030,7 +3030,22 @@ aarch64_load_symref_appropriately (rtx dest, rtx imm,
        if (can_create_pseudo_p ())
          tmp_reg = gen_reg_rtx (mode);
 
+       HOST_WIDE_INT mid_const = 0;
+       if (TARGET_PECOFF)
+         {
+           poly_int64 offset;
+           strip_offset (imm, &offset);
+
+           HOST_WIDE_INT const_offset;
+           if (offset.is_constant (&const_offset))
+             /* Written this way for the sake of negative offsets.  */
+             mid_const = const_offset / (1 << 20) * (1 << 20);
+         }
+       imm = plus_constant (mode, imm, -mid_const);
+
        emit_move_insn (tmp_reg, gen_rtx_HIGH (mode, copy_rtx (imm)));
+       if (mid_const)
+         emit_set_insn (tmp_reg, plus_constant (mode, tmp_reg, mid_const));
        emit_insn (gen_add_losym (dest, tmp_reg, imm));
        return;
       }

Reply via email to