[ Please don't post new patch series as replies to old ] On Wed, Jul 22, 2020 at 12:02:33PM +0200, Andrea Corallo wrote: > This first patch implements the addition of a new RTX instruction class > FILLER_INSN, which has been white listed to allow placement of NOPs > outside of a basic block. This is to allow padding after unconditional > branches. This is favorable so that any performance gained from > diluting branches is not paid straight back via excessive eating of > nops. > > It was deemed that a new RTX class was less invasive than modifying > behavior in regards to standard UNSPEC nops.
Deemed, by whom? There are several people very against it, too. You need to modify only one simple behaviour (maybe in a handful of places), making a new RTX class for that is excessive. > * cfgbuild.c (inside_basic_block_p): Handle FILLER_INSN. > * cfgrtl.c (rtl_verify_bb_layout): Whitelist FILLER_INSN outside > basic blocks. > * coretypes.h: New rtx class. coretypes.h is not a new RTX class? :-) Maybe: * coretypes.h (rtx_filler_insn): New struct. > @@ -3033,7 +3034,20 @@ rtl_verify_bb_layout (void) > break; > > default: > - fatal_insn ("insn outside basic block", x); > + /* Allow nops after branches, via FILLER_INSN. */ > + bool fail = true; > + subrtx_iterator::array_type array; > + FOR_EACH_SUBRTX (iter, array, x, ALL) > + { > + const_rtx rtx = *iter; > + if (GET_CODE (rtx) == FILLER_INSN) > + { > + fail = false; > + break; > + } > + } > + if (fail) > + fatal_insn ("insn outside basic block", x); > } > } It wouldn't be hard to allow some existing RTL here. Maybe something with CODE_FOR_filler_nop or similar (after you recog () it). It still allows anything after leading filler insns, btw; you could get rid of the "fail" variable altogether, just call fatal_insn as soon as you see some unexpected RTX code. > + rtx_insn* i = make_insn_raw (pattern); rtx_insn *i = ... Segher