https://gcc.gnu.org/g:bc002b9e8439a708cda95e16a918760266fd053b

commit r17-5470-gbc002b9e8439a708cda95e16a918760266fd053b
Author: John David Anglin <[email protected]>
Date:   Wed Oct 21 16:17:22 2026 -0400

    hppa: Partially revert commit b55ba08f1055d5c8748699a36f419c8078044594
    
    Jeff was correct.  GNU ld can't fixup a ldil/addl sequence when
    we have an unresolved weak symbol.  It can only replace the %dp
    register with %r0 in the addil instruction.  This was noticed in
    the failure of gcc.dg/torture/pr116835.c.
    
    Hopefully, the other LRA related improvements that have been
    recently implemented will fix the %r1 spill failures reported in
    PR rtl-optimization/127142.  If we still get these spill failures,
    the linker will need fixing to handle ldil/addl sequences.
    
    2026-10-21  John David Anglin  <[email protected]>
    
    gcc/ChangeLog:
    
            PR rtl-optimization/127142
            * config/pa/pa.md: Remove ldil/addl alternative from insns
            to load the high part of a symbolic operand.

Diff:
---
 gcc/config/pa/pa.md | 49 +++++++++++++++++++------------------------------
 1 file changed, 19 insertions(+), 30 deletions(-)

diff --git a/gcc/config/pa/pa.md b/gcc/config/pa/pa.md
index db812ba726b7..e91522ea9cca 100644
--- a/gcc/config/pa/pa.md
+++ b/gcc/config/pa/pa.md
@@ -2716,18 +2716,16 @@
    (set_attr "length" "4")])
 
 (define_insn ""
-  [(set (match_operand:DI 0 "register_operand" "=a,!&r")
-       (plus:DI (match_operand:DI 1 "register_operand" "r,r")
+  [(set (match_operand:DI 0 "register_operand" "=a")
+       (plus:DI (match_operand:DI 1 "register_operand" "r")
                 (high:DI (match_operand 2 "" ""))))]
   "symbolic_operand (operands[2], Pmode)
    && ! function_label_operand (operands[2], Pmode)
    && TARGET_64BIT
    && flag_pic"
-  "@
-   addil LT'%G2,%1
-   ldil LT'%G2,%0\;add,l %0,%1,%0"
-  [(set_attr "type" "binary,binary")
-   (set_attr "length" "4,8")])
+  "addil LT'%G2,%1"
+  [(set_attr "type" "binary")
+   (set_attr "length" "4")])
 
 (define_insn ""
  [(set (match_operand:SI 0 "register_operand" "=r")
@@ -2754,35 +2752,26 @@
 
 ;; Always use addil rather than ldil;add sequences.  This allows the
 ;; HP linker to eliminate the dp relocation if the symbolic operand
-;; lives in the TEXT space.  In order to avoid spill failures with
-;; LRA, we need ldil;add sequence with general register target.
-(define_insn ""
-  [(set (match_operand:SI 0 "register_operand" "=a,!r")
-       (high:SI (match_operand 1 "" "")))]
-  "! TARGET_LONG_LOAD_STORE
-   && symbolic_operand (operands[1], Pmode)
-   && ! function_label_operand (operands[1], Pmode)
-   && ! read_only_operand (operands[1], Pmode)
-   && ! flag_pic"
-  "@
-   addil LR'%H1,%%r27
-   ldil LR'%H1,%0\;{addl|add,l} %0,%%r27,%0"
-  [(set_attr "type" "binary,binary")
-   (set_attr "length" "4,8")])
-
+;; lives in the TEXT space.
 (define_insn ""
-  [(set (match_operand:SI 0 "register_operand" "=a,!r")
+  [(set (match_operand:SI 0 "register_operand" "=a")
        (high:SI (match_operand 1 "" "")))]
-  "TARGET_LONG_LOAD_STORE
-   && symbolic_operand (operands[1], Pmode)
+  "symbolic_operand (operands[1], Pmode)
    && ! function_label_operand (operands[1], Pmode)
    && ! read_only_operand (operands[1], Pmode)
    && ! flag_pic"
-  "@
-   addil NLR'%H1,%%r27\;ldo N'%H1(%%r1),%%r1
-   ldil NLR'%H1,%0\;{addl|add,l} %0,%%r27,%0\;ldo N'%H1(%0),%0"
+  "*
+{
+  if (TARGET_LONG_LOAD_STORE)
+    return \"addil NLR'%H1,%%r27\;ldo N'%H1(%%r1),%%r1\";
+  else
+    return \"addil LR'%H1,%%r27\";
+}"
   [(set_attr "type" "binary")
-   (set_attr "length" "8,12")])
+   (set (attr "length")
+      (if_then_else (not (match_test "TARGET_LONG_LOAD_STORE"))
+                   (const_int 4)
+                   (const_int 8)))])
 
 
 ;; This is for use in the prologue/epilogue code.  We need it

Reply via email to