Ian Lance Taylor <iant@google.com> writes:
> +/* For iterating over insns in basic block when we might remove the
> + current insn. */
> +#define FOR_BB_INSNS_SAFE(BB, INSN, CURR) \
> + for ((INSN) = BB_HEAD (BB), (CURR)=(INSN) ? NEXT_INSN ((INSN)): NULL; \
> + (INSN) && (INSN) != NEXT_INSN (BB_END (BB)); \
> + (INSN) = (CURR), (CURR) = (INSN) ? NEXT_INSN ((INSN)) : NULL)
Would:
for ((INSN) = BB_HEAD (BB); \
(INSN) \
&& (INSN) != NEXT_INSN (BB_END (BB)) \
&& ((CURR) = NEXT_INSN (INSN), true); \
(INSN) = (CURR))
be any better? It's the construct I'm more used to seeing when the
loop is written by hand, albeit with the CURR assignment at the
beginning of the loop body. Similarly for the reverse version.
CURR seems a little misnamed really. It sounds like it ought to be
the current instruction, but it's not. (Indeed, without a comment
saying what CURR is, you might even think CURR is the thing you're
supposed to use.)