The combiner is somewhat strange about how it uses costs. If any of the insns involved in a comparison have a cost of 0, it does not verify that the substitution is cheaper. Also, it does not compute costs for jump insns, so they are always set to zero. As a consequence, any possible substitution is performed if a combination into a jump is possible, which turns out isn't really desirable on m68k with cbranch patterns.
This patch simply removes a test for NONJUMP_INSN_P. Bootstrapped and tested on the gcc135 machine (powerpc64le-unknown-linux-gnu). Bernd
* combine.c (combine_instructions): Record costs for jumps. diff --git a/gcc/combine.c b/gcc/combine.c index 857ea30dafd..9446d2769ab 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -1234,8 +1234,7 @@ combine_instructions (rtx_insn *f, unsigned int nregs) insn); /* Record the current insn_cost of this instruction. */ - if (NONJUMP_INSN_P (insn)) - INSN_COST (insn) = insn_cost (insn, optimize_this_for_speed_p); + INSN_COST (insn) = insn_cost (insn, optimize_this_for_speed_p); if (dump_file) { fprintf (dump_file, "insn_cost %d for ", INSN_COST (insn));