https://gcc.gnu.org/g:f2ce8af772774e5593ba6b1157554998e9a36c2b
commit r17-5844-gf2ce8af772774e5593ba6b1157554998e9a36c2b Author: Trevor Saunders <[email protected]> Date: Sat Oct 24 07:02:51 2026 +0000 Use label_ref_label instead of XEXP on a LABEL_REF gcc/ChangeLog: * config/arm/minipool.cc (print_value): Use label_ref_label instead of XEXP on a LABEL_REF. * config/avr/avr.cc (avr_jump_mode, jump_over_one_insn_p): Likewise. * config/bfin/bfin.cc (branch_dest): Likewise. * config/csky/csky.cc (print_csky_value): Likewise. * config/frv/frv.cc (frv_print_operand_jump_hint): Likewise. * config/pa/pa.md: Likewise. * config/rs6000/rs6000.cc (rs6000_hash_constant): Likewise. * config/s390/s390.cc (s390_chunkify_start, s390_fix_long_loop_prediction): Likewise. * config/sh/sh.cc (untangle_mova, gen_block_redirect, split_branches, branch_dest, sh_mark_label): Likewise. * final.cc (shorten_branches): Likewise. Diff: --- gcc/config/arm/minipool.cc | 2 +- gcc/config/avr/avr.cc | 4 ++-- gcc/config/bfin/bfin.cc | 3 +-- gcc/config/csky/csky.cc | 2 +- gcc/config/frv/frv.cc | 2 +- gcc/config/pa/pa.md | 4 ++-- gcc/config/rs6000/rs6000.cc | 2 +- gcc/config/s390/s390.cc | 6 +++--- gcc/config/sh/sh.cc | 21 ++++++++++++--------- gcc/final.cc | 4 ++-- 10 files changed, 26 insertions(+), 24 deletions(-) diff --git a/gcc/config/arm/minipool.cc b/gcc/config/arm/minipool.cc index 36714a6b1e77..a540b548c85e 100644 --- a/gcc/config/arm/minipool.cc +++ b/gcc/config/arm/minipool.cc @@ -390,7 +390,7 @@ print_value (FILE *f, rtx x) return; case LABEL_REF: - fprintf (f, "L%d", INSN_UID (XEXP (x, 0))); + fprintf (f, "L%d", INSN_UID (label_ref_label (x))); return; case CONST: diff --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc index 95343ad417df..09a1e63f6c3c 100644 --- a/gcc/config/avr/avr.cc +++ b/gcc/config/avr/avr.cc @@ -2949,7 +2949,7 @@ int avr_jump_mode (rtx x, rtx_insn *insn, int extra) { int dest_addr = INSN_ADDRESSES (INSN_UID (GET_CODE (x) == LABEL_REF - ? XEXP (x, 0) : x)); + ? label_ref_label (x) : x)); int cur_addr = INSN_ADDRESSES (INSN_UID (insn)); int jump_distance = cur_addr - dest_addr; @@ -14564,7 +14564,7 @@ bool jump_over_one_insn_p (rtx_insn *insn, rtx dest) { int uid = INSN_UID (GET_CODE (dest) == LABEL_REF - ? XEXP (dest, 0) + ? label_ref_label (dest) : dest); int jump_addr = INSN_ADDRESSES (INSN_UID (insn)); int dest_addr = INSN_ADDRESSES (uid); diff --git a/gcc/config/bfin/bfin.cc b/gcc/config/bfin/bfin.cc index 68b9cf9240cc..e52df8b3ae15 100644 --- a/gcc/config/bfin/bfin.cc +++ b/gcc/config/bfin/bfin.cc @@ -2442,8 +2442,7 @@ branch_dest (rtx_insn *branch) dest = SET_SRC (pat); if (GET_CODE (dest) == IF_THEN_ELSE) dest = XEXP (dest, 1); - dest = XEXP (dest, 0); - dest_uid = INSN_UID (dest); + dest_uid = INSN_UID (label_ref_label (dest)); return INSN_ADDRESSES (dest_uid); } diff --git a/gcc/config/csky/csky.cc b/gcc/config/csky/csky.cc index 71da4f0d0f72..fe4134eb4722 100644 --- a/gcc/config/csky/csky.cc +++ b/gcc/config/csky/csky.cc @@ -1322,7 +1322,7 @@ print_csky_value (FILE *f, rtx x) return; case LABEL_REF: - fprintf (f, "L%d", INSN_UID (XEXP (x, 0))); + fprintf (f, "L%d", INSN_UID (label_ref_label (x))); return; case CONST: diff --git a/gcc/config/frv/frv.cc b/gcc/config/frv/frv.cc index cc461c8f39e0..033eafb366ae 100644 --- a/gcc/config/frv/frv.cc +++ b/gcc/config/frv/frv.cc @@ -2616,7 +2616,7 @@ frv_print_operand_jump_hint (rtx_insn *insn) labelref = condjump_label (insn); if (labelref) { - rtx label = XEXP (labelref, 0); + rtx_insn *label = label_ref_label (labelref); jump_type = (insn_current_address > INSN_ADDRESSES (INSN_UID (label)) ? BACKWARD : FORWARD); diff --git a/gcc/config/pa/pa.md b/gcc/config/pa/pa.md index a7f8ff1448d8..a94b2eaf8ea4 100644 --- a/gcc/config/pa/pa.md +++ b/gcc/config/pa/pa.md @@ -2630,7 +2630,7 @@ /* If we're trying to load the address of a label that happens to be close, then we can use a shorter sequence. */ if (INSN_ADDRESSES_SET_P () - && abs (INSN_ADDRESSES (INSN_UID (XEXP (operands[1], 0))) + && abs (INSN_ADDRESSES (INSN_UID (label_ref_label (operands[1]))) - INSN_ADDRESSES (INSN_UID (insn))) < 8100) output_asm_insn (\"ldo %1-%2(%0),%0\", xoperands); else @@ -2681,7 +2681,7 @@ /* If we're trying to load the address of a label that happens to be close, then we can use a shorter sequence. */ if (INSN_ADDRESSES_SET_P () - && abs (INSN_ADDRESSES (INSN_UID (XEXP (operands[1], 0))) + && abs (INSN_ADDRESSES (INSN_UID (label_ref_label (operands[1]))) - INSN_ADDRESSES (INSN_UID (insn))) < 8100) output_asm_insn (\"ldo %1-%2(%0),%0\", xoperands); else diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 821aec7797b2..31f3d45eb819 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -17543,7 +17543,7 @@ rs6000_hash_constant (rtx k) switch (code) { case LABEL_REF: - return result * 1231 + (unsigned) INSN_UID (XEXP (k, 0)); + return result * 1231 + (unsigned) INSN_UID (label_ref_label (k)); case CONST_WIDE_INT: { diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc index 0336e6e508d6..1d82ab89b9f4 100644 --- a/gcc/config/s390/s390.cc +++ b/gcc/config/s390/s390.cc @@ -10329,7 +10329,7 @@ s390_chunkify_start (void) for (i = 0; i < XVECLEN (vec_pat, diff_p); i++) { - rtx label = XEXP (XVECEXP (vec_pat, diff_p, i), 0); + rtx_insn *label = label_ref_label (XVECEXP (vec_pat, diff_p, i)); if (s390_find_pool (pool_list, label) != s390_find_pool (pool_list, insn)) @@ -14917,7 +14917,7 @@ static bool s390_fix_long_loop_prediction (rtx_insn *insn) { rtx set = single_set (insn); - rtx code_label, label_ref; + rtx label_ref; rtx_insn *uncond_jump; rtx_insn *cur_insn; rtx tmp; @@ -14945,7 +14945,7 @@ s390_fix_long_loop_prediction (rtx_insn *insn) gcc_assert (GET_CODE (label_ref) == LABEL_REF); - code_label = XEXP (label_ref, 0); + rtx_insn *code_label = label_ref_label (label_ref); if (INSN_ADDRESSES (INSN_UID (code_label)) == -1 || INSN_ADDRESSES (INSN_UID (insn)) == -1 diff --git a/gcc/config/sh/sh.cc b/gcc/config/sh/sh.cc index 410f1f37ee2c..e915c9343565 100644 --- a/gcc/config/sh/sh.cc +++ b/gcc/config/sh/sh.cc @@ -4908,7 +4908,8 @@ untangle_mova (int *num_mova, rtx_insn **first_mova, rtx_insn *new_mova) return -1; n_addr = INSN_ADDRESSES (INSN_UID (new_mova)); - n_target = INSN_ADDRESSES (INSN_UID (XEXP (MOVA_LABELREF (new_mova), 0))); + n_target = INSN_ADDRESSES + (INSN_UID (label_ref_label (MOVA_LABELREF (new_mova)))); if (n_addr > n_target || n_addr + 1022 < n_target) { /* Change the mova into a load. @@ -4924,7 +4925,8 @@ untangle_mova (int *num_mova, rtx_insn **first_mova, rtx_insn *new_mova) } if (!optimize || ((f_target - = INSN_ADDRESSES (INSN_UID (XEXP (MOVA_LABELREF (*first_mova), 0)))) + = INSN_ADDRESSES + (INSN_UID (label_ref_label (MOVA_LABELREF (*first_mova))))) >= n_target)) return -1; @@ -5504,7 +5506,7 @@ gen_block_redirect (rtx_insn *jump, int addr, int need_block) } /* We can't use JUMP_LABEL here because it might be undefined when not optimizing. */ - rtx dest = XEXP (SET_SRC (PATTERN (jump)), 0); + rtx_insn *dest = label_ref_label (SET_SRC (PATTERN (jump))); /* If the branch is out of range, try to find a scratch register for it. */ if (optimize && (INSN_ADDRESSES (INSN_UID (dest)) - addr + (unsigned) 4092 @@ -5573,13 +5575,13 @@ gen_block_redirect (rtx_insn *jump, int addr, int need_block) else if (optimize && need_block >= 0) { - rtx_insn *next = next_active_insn (as_a<rtx_insn *> (dest)); + rtx_insn *next = next_active_insn (dest); next = next_active_insn (next); if (next && JUMP_P (next) && GET_CODE (PATTERN (next)) == SET && recog_memoized (next) == CODE_FOR_jump_compact) { - dest = JUMP_LABEL (next); + dest = JUMP_LABEL_AS_INSN (next); if (dest && (INSN_ADDRESSES (INSN_UID (dest)) - addr + (unsigned) 4092 > 4092 + 4098)) @@ -6476,7 +6478,8 @@ split_branches (rtx_insn *first) && GET_CODE (PATTERN (beyond)) == SET && recog_memoized (beyond) == CODE_FOR_jump_compact && ((INSN_ADDRESSES - (INSN_UID (XEXP (SET_SRC (PATTERN (beyond)), 0))) + (INSN_UID (label_ref_label + (SET_SRC (PATTERN (beyond))))) - INSN_ADDRESSES (INSN_UID (insn)) + (unsigned) 252) > 252 + 258 + 2)) gen_block_redirect (beyond, @@ -6492,7 +6495,7 @@ split_branches (rtx_insn *first) && GET_CODE (PATTERN (next)) == SET && recog_memoized (next) == CODE_FOR_jump_compact && ((INSN_ADDRESSES - (INSN_UID (XEXP (SET_SRC (PATTERN (next)), 0))) + (INSN_UID (label_ref_label (SET_SRC (PATTERN (next))))) - INSN_ADDRESSES (INSN_UID (insn)) + (unsigned) 252) > 252 + 258 + 2)) gen_block_redirect (next, INSN_ADDRESSES (INSN_UID (next)), 1); @@ -8736,7 +8739,7 @@ branch_dest (rtx branch) if (GET_CODE (dest) == IF_THEN_ELSE) dest = XEXP (dest, 1); - return INSN_ADDRESSES (INSN_UID (XEXP (dest, 0))); + return INSN_ADDRESSES (INSN_UID (label_ref_label (dest))); } /* Return nonzero if REG is not used after INSN. @@ -10657,7 +10660,7 @@ sh_mark_label (rtx address, int nuses) } if (GET_CODE (address) == LABEL_REF && LABEL_P (XEXP (address, 0))) - LABEL_NUSES (XEXP (address, 0)) += nuses; + LABEL_NUSES (label_ref_label (address)) += nuses; } /* Compute extra cost of moving data between one register class diff --git a/gcc/final.cc b/gcc/final.cc index 20adb7571266..420e00916754 100644 --- a/gcc/final.cc +++ b/gcc/final.cc @@ -962,7 +962,7 @@ shorten_branches (rtx_insn *first) min_align = MAX_CODE_ALIGN; for (min = max_shuid, max = min_shuid, i = len - 1; i >= 0; i--) { - rtx lab = XEXP (XVECEXP (pat, 1, i), 0); + rtx_insn *lab = label_ref_label (XVECEXP (pat, 1, i)); int shuid = INSN_SHUID (lab); if (shuid < min) { @@ -982,7 +982,7 @@ shorten_branches (rtx_insn *first) XEXP (pat, 2) = gen_rtx_LABEL_REF (Pmode, min_lab); XEXP (pat, 3) = gen_rtx_LABEL_REF (Pmode, max_lab); insn_shuid = INSN_SHUID (insn); - rel = INSN_SHUID (XEXP (XEXP (pat, 0), 0)); + rel = INSN_SHUID (label_ref_label (XEXP (pat, 0))); memset (&flags, 0, sizeof (flags)); flags.min_align = min_align; flags.base_after_vec = rel > insn_shuid;
