This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: cprop fix for PR78626
- From: Segher Boessenkool <segher at kernel dot crashing dot org>
- To: Bernd Schmidt <bschmidt at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 10 Dec 2016 13:58:57 -0600
- Subject: Re: cprop fix for PR78626
- Authentication-results: sourceware.org; auth=none
- References: <eefab903-071d-a8fe-887d-434f09c36abf@redhat.com>
On Thu, Dec 08, 2016 at 01:21:04PM +0100, Bernd Schmidt wrote:
> This is another case where an optimization turns a trap_if
> unconditional. We have to defer changing the CFG, since the rest of
> cprop seems to blow up when we modify things while scanning.
>
> Bootstrapped and tested on x86_64-linux, and reportedly fixes the
> problem on ppc, ok?
This fixes PR78626, but not yet PR78727.
> @@ -1825,11 +1828,26 @@ one_cprop_pass (void)
> insn into a NOTE, or deleted the insn. */
> if (! NOTE_P (insn) && ! insn->deleted ())
> mark_oprs_set (insn);
> +
> + if (first_uncond_trap == NULL
> + && GET_CODE (PATTERN (insn)) == TRAP_IF
> + && XEXP (PATTERN (insn), 0) == const1_rtx)
> + first_uncond_trap = insn;
> }
> + if (first_uncond_trap != NULL && first_uncond_trap != BB_END (bb))
> + uncond_traps.safe_push (first_uncond_trap);
> }
The problem for PR78727 is that we also need to do this for insns that
already are the last insn in the block:
> + while (!uncond_traps.is_empty ())
> + {
> + rtx_insn *insn = uncond_traps.pop ();
> + basic_block to_split = BLOCK_FOR_INSN (insn);
> + remove_edge (split_block (to_split, insn));
> + emit_barrier_after_bb (to_split);
> + }
We need that barrier, and we also need the successor edges removed
(which split_block+remove_edge does).
(PR78727 works fine with just that BB_END test deleted).
Segher