public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/37542] [4.4 Regression] PRE doesn't simplify during phi-translation
Date: Sat, 01 Nov 2008 17:12:00 -0000	[thread overview]
Message-ID: <20081101171129.835.qmail@sourceware.org> (raw)
In-Reply-To: <bug-37542-10053@http.gcc.gnu.org/bugzilla/>



------- Comment #4 from rguenth at gcc dot gnu dot org  2008-11-01 17:11 -------
We need to be careful with simplifying to SSA_NAMEs as the following example
shows:

int foo (int i, int b)
{
  int mask;
  int result;
  if (b)
    mask = -1;
  else
    mask = 0;
  result = i + 1;
  result = result & mask;
  return result;
}

we have a phi-translation for result & mask that is 0 or result dependent
on the path through the CFG.  But we cannot insert this as a PHI as one
argument (result with value i + 1) is not available there.

The PRE of 4.3 inserts i + 1, re-generating the expression recursively and
exposing a code hoisting opportunity:

<bb 2>:
  if (b_2(D) != 0)
    goto <bb 5>;
  else
    goto <bb 3>;

<bb 5>:
  pretmp.6_10 = i_5(D) + 1;
  pretmp.6_11 = pretmp.6_10;
  goto <bb 4>;

<bb 3>:
  pretmp.6_13 = i_5(D) + 1;

<bb 4>:
  # prephitmp.7_14 = PHI <pretmp.6_10(5), pretmp.6_13(3)>
  # prephitmp.7_12 = PHI <pretmp.6_11(5), 0(3)>
  # mask_1 = PHI <-1(5), 0(3)>
  result_6 = prephitmp.7_14;
  result_7 = prephitmp.7_12;
  return result_7;

I don't think we want to do this now (without code hoisting implemented), but
for cases where result_6 is available we surely want it.

I'm trying to find a way to detect whether it is safe to phi-translate to
result_6.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dberlin at gcc dot gnu dot
                   |                            |org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37542


  parent reply	other threads:[~2008-11-01 17:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-16 15:23 [Bug tree-optimization/37542] New: " rguenth at gcc dot gnu dot org
2008-09-16 15:23 ` [Bug tree-optimization/37542] " rguenth at gcc dot gnu dot org
2008-09-16 15:35 ` [Bug tree-optimization/37542] [4.4 Regression] " rguenth at gcc dot gnu dot org
2008-09-22 12:21 ` rguenth at gcc dot gnu dot org
2008-10-22  3:47 ` mmitchel at gcc dot gnu dot org
2008-11-01 17:12 ` rguenth at gcc dot gnu dot org [this message]
2008-11-01 17:13 ` rguenth at gcc dot gnu dot org
2008-11-02 15:28 ` rguenth at gcc dot gnu dot org
2008-11-02 15:29 ` rguenth at gcc dot gnu dot org

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=20081101171129.835.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).