public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Henderson <rth@redhat.com>
To: Steven Bosscher <stevenb.gcc@gmail.com>
Cc: GCC Mailing List <gcc@gcc.gnu.org>
Subject: Re: Question about dead_or_predicable
Date: Wed, 24 Jun 2009 16:22:00 -0000	[thread overview]
Message-ID: <4A4247BF.5090400@redhat.com> (raw)
In-Reply-To: <571f6b510906231527h453fe581i5cf85b785b587b86@mail.gmail.com>

On 06/23/2009 03:27 PM, Steven Bosscher wrote:
> Hi,
>
> I have a question about ifcvt.c:dead_or_predicable.  This function is
> pretty complicated and it's not really clear to me what it is doing.
> But I'll have to understand what is going on because there is a bug in
> this function that I would like to fix (see
> http://gcc.gnu.org/PR40525).
>
> The code I don't understand, is the part where the changes are
> actually applied.  This code starts with the following comment:
>
>   33547        rth
>   33547        rth  no_body:
>   33547        rth   /* We don't want to use normal invert_jump or
> redirect_jump because
>   33547        rth      we don't want to delete_insn called.  Also, we
> want to do our own
>   33547        rth      change group management.  */
>   33547        rth
>
> The comment doesn't explain *why* we don't want delete_insn to be
> called, or why we want to do our own change group management.

Have a quick look at the implementation of invert_jump, and both
questions are quickly answered.

First, invert_jump calls apply_change_group, which we clearly
don't want -- thus the comment about "own change group mgmt".

Second, the third argument to invert_jump is delete_unused,
which (if true) eventually results in a call to delete_related_insns,
which we also don't want.

> Can I assume that the
> changes to the jumps never fail? Or should the changes to redirect
> other_bb to new_dest actually be part of the big change group (or at
> least, should it be somehow verified that these changes are applied
> successfully) and is it a bug in ifcvt.c that these changes are
> applied without checks?

They aren't applied without checks.

       if (reversep
           ? ! invert_jump_1 (jump, new_label)
           : ! redirect_jump_1 (jump, new_label))
         goto cancel;

invert and redirect_jump_1 are returning a success value, and they
do apply their changes to the larger change group, all of which is
verified by the apply_change_group call just a few lines down.

All that said, I think your plan to rearrange things to allow both
CE and NCE paths to be followed is fine.  You'll just need to dup
that jump change into both paths so that the CE path change group
gets its own shot at rejecting the jump change.


r~

  parent reply	other threads:[~2009-06-24 15:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-23 22:50 Steven Bosscher
2009-06-24  2:45 ` Dave Korn
2009-06-24  7:06   ` Steven Bosscher
2009-06-24 16:22 ` Richard Henderson [this message]
2009-06-25 13:09   ` Steven Bosscher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A4247BF.5090400@redhat.com \
    --to=rth@redhat.com \
    --cc=gcc@gcc.gnu.org \
    --cc=stevenb.gcc@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).