On Wed, 28 Oct 2026, Jakub Jelinek wrote: > Hi! > > As I wrote earlier, the function has many different rtx note; > variables. This patch changes the code to use the C++ simple declarations > as condition to limit their scope (with one rtx note; remaining at the > outermost scope, but that one is sometimes used across these). > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
OK (looks obvious to me). Richard. > Note, I'm not 100% sure about the last while, while the patch preserves > the previous behavior, I'm not sure if there can be multiple > REG_LABEL_OPERAND notes with the same operand on the same insn. If yes, > perhaps instead of calling find_reg_note and starting from the beginning > of list after each adjustment (so O(N^2) in number of such notes), if no, > just if and not while could be used instead. > > 2026-10-21 Jakub Jelinek <[email protected]> > > * cfgrtl.cc (force_nonfallthru_and_redirect): Replace some note > variables in the function with C++ simple declaration as condition. > > --- a/gcc/cfgrtl.cc > +++ b/gcc/cfgrtl.cc > @@ -1533,7 +1533,6 @@ force_nonfallthru_and_redirect (edge e, basic_block > target, rtx jump_label) > && any_condjump_p (BB_END (e->src)) > && JUMP_LABEL (BB_END (e->src)) == BB_HEAD (e->dest)) > { > - rtx note; > edge b = unchecked_make_edge (e->src, target, 0); > bool redirected; > > @@ -1541,8 +1540,7 @@ force_nonfallthru_and_redirect (edge e, basic_block > target, rtx jump_label) > block_label (target), 0); > gcc_assert (redirected); > > - note = find_reg_note (BB_END (e->src), REG_BR_PROB, NULL_RTX); > - if (note) > + if (rtx note = find_reg_note (BB_END (e->src), REG_BR_PROB, NULL_RTX)) > { > int prob = XINT (note, 0); > > @@ -1674,28 +1672,24 @@ force_nonfallthru_and_redirect (edge e, basic_block > target, rtx jump_label) > } > > rtx_insn *insn = BB_END (new_edge->src); > - rtx note; > rtx_insn *old_label = BB_HEAD (e->dest); > rtx_insn *new_label = BB_HEAD (jump_block); > > if (JUMP_LABEL (insn) == old_label) > { > JUMP_LABEL (insn) = new_label; > - note = find_reg_note (insn, REG_LABEL_TARGET, new_label); > - if (note) > + if (rtx note = find_reg_note (insn, REG_LABEL_TARGET, new_label)) > remove_note (insn, note); > } > else > { > - note = find_reg_note (insn, REG_LABEL_TARGET, old_label); > - if (note) > + if (rtx note = find_reg_note (insn, REG_LABEL_TARGET, old_label)) > remove_note (insn, note); > if (JUMP_LABEL (insn) != new_label > && !find_reg_note (insn, REG_LABEL_TARGET, new_label)) > add_reg_note (insn, REG_LABEL_TARGET, new_label); > } > - while ((note = find_reg_note (insn, REG_LABEL_OPERAND, old_label)) > - != NULL_RTX) > + while (rtx note = find_reg_note (insn, REG_LABEL_OPERAND, old_label)) > XEXP (note, 0) = new_label; > } > > > Jakub > > -- Richard Biener <[email protected]> SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri; (HRB 36809, AG Nuernberg)
