https://gcc.gnu.org/g:5f12ad3aff8325e922b53295d8a3cdd55dc8c018

commit r16-7346-g5f12ad3aff8325e922b53295d8a3cdd55dc8c018
Author: Torbjörn SVENSSON <[email protected]>
Date:   Wed Feb 4 10:52:17 2026 +0100

    middle-end: replace CONST_CAST_RTX with const_cast<rtx> [PR123892]
    
    gcc/ChangeLog:
    
            PR middle-end/123892
            * alias.cc: Replace CONST_CAST_RTX with const_cast<rtx>.
            * config/i386/x86-tune-sched-bd.cc: Likewise.
            * config/rs6000/rs6000.cc: Likewise.
            * recog.cc: Likewise.
            * sel-sched-ir.cc: Likewise.
            * var-tracking.cc: Likewise.
            * varasm.cc: Likewise.
            * system.h (CONST_CAST_RTX): Remove.
    
    Signed-off-by: Torbjörn SVENSSON <[email protected]>

Diff:
---
 gcc/alias.cc                         | 2 +-
 gcc/config/i386/x86-tune-sched-bd.cc | 2 +-
 gcc/config/rs6000/rs6000.cc          | 6 +++---
 gcc/recog.cc                         | 2 +-
 gcc/sel-sched-ir.cc                  | 4 ++--
 gcc/system.h                         | 1 -
 gcc/var-tracking.cc                  | 2 +-
 gcc/varasm.cc                        | 2 +-
 8 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/gcc/alias.cc b/gcc/alias.cc
index bce026200a19..d210d6325512 100644
--- a/gcc/alias.cc
+++ b/gcc/alias.cc
@@ -3337,7 +3337,7 @@ memory_modified_in_insn_p (const_rtx mem, const_rtx insn)
     return true;
   memory_modified = false;
   note_stores (as_a<const rtx_insn *> (insn), memory_modified_1,
-              CONST_CAST_RTX(mem));
+              const_cast<rtx> (mem));
   return memory_modified;
 }
 
diff --git a/gcc/config/i386/x86-tune-sched-bd.cc 
b/gcc/config/i386/x86-tune-sched-bd.cc
index 01f2785e217d..5602478f2351 100644
--- a/gcc/config/i386/x86-tune-sched-bd.cc
+++ b/gcc/config/i386/x86-tune-sched-bd.cc
@@ -345,7 +345,7 @@ find_constant (rtx in_rtx, imm_info *imm_values)
        case SYMBOL_REF:
        case CONST_INT:
          (imm_values->imm)++;
-         if (x86_64_immediate_operand (CONST_CAST_RTX (x), SImode))
+         if (x86_64_immediate_operand (const_cast<rtx> (x), SImode))
            (imm_values->imm32)++;
          else
            (imm_values->imm64)++;
diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index 10b2cf983cc8..a4f60ecb58a8 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -14669,7 +14669,7 @@ print_operand (FILE *file, rtx x, int code)
           (plus (unspec [(symbol_ref ("x")) (reg 2)] tocrel) 4)
           without this hack would be output as "x@toc+4".  We
           want "x+4@toc".  */
-       output_addr_const (file, CONST_CAST_RTX (tocrel_base_oac));
+       output_addr_const (file, const_cast<rtx> (tocrel_base_oac));
       else if (GET_CODE (x) == UNSPEC && XINT (x, 1) == UNSPEC_TLSGD)
        output_addr_const (file, XVECEXP (x, 0, 0));
       else if (GET_CODE (x) == UNSPEC && XINT (x, 1) == UNSPEC_PLTSEQ)
@@ -14780,7 +14780,7 @@ print_operand_address (FILE *file, rtx x)
         .       (plus (unspec [(symbol_ref ("x")) (reg 2)] tocrel) 8))
         without this hack would be output as "x@toc+8@l(9)".  We
         want "x+8@toc@l(9)".  */
-      output_addr_const (file, CONST_CAST_RTX (tocrel_base_oac));
+      output_addr_const (file, const_cast<rtx> (tocrel_base_oac));
       if (GET_CODE (x) == LO_SUM)
        fprintf (file, "@l(%s)", reg_names[REGNO (XEXP (x, 0))]);
       else
@@ -14807,7 +14807,7 @@ rs6000_output_addr_const_extra (FILE *file, rtx x)
          {
            if (INTVAL (tocrel_offset_oac) >= 0)
              fprintf (file, "+");
-           output_addr_const (file, CONST_CAST_RTX (tocrel_offset_oac));
+           output_addr_const (file, const_cast<rtx> (tocrel_offset_oac));
          }
        if (!TARGET_AIX || (TARGET_ELF && TARGET_MINIMAL_TOC))
          {
diff --git a/gcc/recog.cc b/gcc/recog.cc
index a0b4925a8ee5..48f6b45ec6d7 100644
--- a/gcc/recog.cc
+++ b/gcc/recog.cc
@@ -2030,7 +2030,7 @@ extract_asm_operands (rtx body)
 int
 asm_noperands (const_rtx body)
 {
-  rtx asm_op = extract_asm_operands (CONST_CAST_RTX (body));
+  rtx asm_op = extract_asm_operands (const_cast<rtx> (body));
   int i, n_sets = 0;
 
   if (asm_op == NULL)
diff --git a/gcc/sel-sched-ir.cc b/gcc/sel-sched-ir.cc
index 4991de2dfa0c..3e0ce5895f6a 100644
--- a/gcc/sel-sched-ir.cc
+++ b/gcc/sel-sched-ir.cc
@@ -1090,7 +1090,7 @@ skip_unspecs_callback (const_rtx *xx, const_rtx *yy, rtx 
*nx, rtx* ny)
           || targetm.sched.skip_rtx_p (x)))
     {
       *nx = XVECEXP (x, 0, 0);
-      *ny = CONST_CAST_RTX (y);
+      *ny = const_cast<rtx> (y);
       return true;
     }
 
@@ -1098,7 +1098,7 @@ skip_unspecs_callback (const_rtx *xx, const_rtx *yy, rtx 
*nx, rtx* ny)
       && (targetm.sched.skip_rtx_p == NULL
           || targetm.sched.skip_rtx_p (y)))
     {
-      *nx = CONST_CAST_RTX (x);
+      *nx = const_cast<rtx> (x);
       *ny = XVECEXP (y, 0, 0);
       return true;
     }
diff --git a/gcc/system.h b/gcc/system.h
index 58adb8e97bf0..d1710307b3aa 100644
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -1195,7 +1195,6 @@ helper_const_non_const_cast (const char *p)
 #endif
 #define CONST_CAST(TYPE,X) CONST_CAST2 (TYPE, const TYPE, (X))
 #define CONST_CAST_TREE(X) CONST_CAST (union tree_node *, (X))
-#define CONST_CAST_RTX(X) CONST_CAST (struct rtx_def *, (X))
 #define CONST_CAST_BB(X) CONST_CAST (struct basic_block_def *, (X))
 #define CONST_CAST_GIMPLE(X) CONST_CAST (gimple *, (X))
 
diff --git a/gcc/var-tracking.cc b/gcc/var-tracking.cc
index bfe75b0577d6..e7065e81ca55 100644
--- a/gcc/var-tracking.cc
+++ b/gcc/var-tracking.cc
@@ -1195,7 +1195,7 @@ adjust_mem_stores (rtx loc, const_rtx expr, void *data)
                                              adjust_mems, data);
       if (new_dest != SET_DEST (expr))
        {
-         rtx xexpr = CONST_CAST_RTX (expr);
+         rtx xexpr = const_cast<rtx> (expr);
          validate_change (NULL_RTX, &SET_DEST (xexpr), new_dest, true);
        }
     }
diff --git a/gcc/varasm.cc b/gcc/varasm.cc
index fec792ec2326..dc5439be3ca3 100644
--- a/gcc/varasm.cc
+++ b/gcc/varasm.cc
@@ -4517,7 +4517,7 @@ mark_constants_in_pattern (rtx insn)
              if (!TREE_ASM_WRITTEN (DECL_INITIAL (decl)))
                {
                  n_deferred_constants--;
-                 output_constant_def_contents (CONST_CAST_RTX (x));
+                 output_constant_def_contents (const_cast<rtx> (x));
                }
            }
        }

Reply via email to