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

commit a50d6756834db3cf74a96577fd816f67990b5c35
Author: Michael Meissner <meiss...@linux.ibm.com>
Date:   Fri May 2 13:41:49 2025 -0400

    Allow pc-relative references to be used with -mcmodel=large
    
    2025-05-02  Michael Meissner  <meiss...@linux.ibm.com>
    
    gcc/
    
            * config/rs6000/rs6000.cc (rs6000_option_override_internal): Allow
            -mcmodel=large and pc-relative addressing.
            * config/rs6000/rs6000.md (tocref<mode>): Don't split large code 
model
            references if pc-relative addressing is used.

Diff:
---
 gcc/config/rs6000/rs6000.cc | 10 ----------
 gcc/config/rs6000/rs6000.md |  2 +-
 2 files changed, 1 insertion(+), 11 deletions(-)

diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index 528220f30537..3db913c7bd78 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -4536,16 +4536,6 @@ rs6000_option_override_internal (bool global_init_p)
       && (rs6000_isa_flags_explicit & OPTION_MASK_PCREL) == 0)
     rs6000_isa_flags |= OPTION_MASK_PCREL;
 
-  /* -mpcrel requires -mcmodel=medium, but we can't check TARGET_CMODEL until
-      after the subtarget override options are done.  */
-  else if (TARGET_PCREL && TARGET_CMODEL != CMODEL_MEDIUM)
-    {
-      if ((rs6000_isa_flags_explicit & OPTION_MASK_PCREL) != 0)
-       error ("%qs requires %qs", "-mpcrel", "-mcmodel=medium");
-
-      rs6000_isa_flags &= ~OPTION_MASK_PCREL;
-    }
-
   /* Enable -mmma by default on power10 systems.  */
   if (TARGET_POWER10 && (rs6000_isa_flags_explicit & OPTION_MASK_MMA) == 0)
     rs6000_isa_flags |= OPTION_MASK_MMA;
diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index 6786030c6bb6..64fd82b08b40 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -11406,7 +11406,7 @@
 (define_insn_and_split "*tocref<mode>"
   [(set (match_operand:P 0 "gpc_reg_operand" "=b")
        (match_operand:P 1 "small_toc_ref" "R"))]
-   "TARGET_TOC
+   "TARGET_TOC && !TARGET_PCREL
     && legitimate_constant_pool_address_p (operands[1], QImode, false)"
    "la %0,%a1"
    "&& TARGET_CMODEL != CMODEL_SMALL && reload_completed"

Reply via email to