public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/37542]  New: PRE doesn't simplify during phi-translation
@ 2008-09-16 15:23 rguenth at gcc dot gnu dot org
  2008-09-16 15:23 ` [Bug tree-optimization/37542] " rguenth at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-09-16 15:23 UTC (permalink / raw)
  To: gcc-bugs

Related to the XFAIL of gcc.dg/tree-ssa/ssa-pre-15.c (PR37145).  The general
issue is that PRE doesn't simplify expressions during phi-translation
which can be seen for example for

int foo (int i, int b)
{
  int j = 1;
  if (b)
    j = i;
  return j - i;
}

where j - i is partially redundant.


-- 
           Summary: PRE doesn't simplify during phi-translation
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rguenth at gcc dot gnu dot org


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug tree-optimization/37542] PRE doesn't simplify during phi-translation
  2008-09-16 15:23 [Bug tree-optimization/37542] New: PRE doesn't simplify during phi-translation rguenth at gcc dot gnu dot org
@ 2008-09-16 15:23 ` 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
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-09-16 15:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2008-09-16 15:22 -------
Mine.  I have some patches.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |rguenth at gcc dot gnu dot
                   |dot org                     |org
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2008-09-16 15:22:36
               date|                            |


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug tree-optimization/37542] [4.4 Regression] PRE doesn't simplify during phi-translation
  2008-09-16 15:23 [Bug tree-optimization/37542] New: PRE doesn't simplify during phi-translation 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 ` rguenth at gcc dot gnu dot org
  2008-09-22 12:21 ` rguenth at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-09-16 15:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rguenth at gcc dot gnu dot org  2008-09-16 15:34 -------
Hm, actually this is a regression :/  4.3 produces

foo (i, b)
{
  int prephitmp.7;
  int pretmp.6;
  int j;
  int D.1550;

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

<bb 5>:
  pretmp.6_8 = 1 - i_4(D);
  goto <bb 4>;

<bb 3>:

<bb 4>:
  # prephitmp.7_9 = PHI <pretmp.6_8(5), 0(3)>
  # j_1 = PHI <1(5), i_4(D)(3)>
  D.1550_6 = prephitmp.7_9;
  return D.1550_6;

}


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |4.3.2
            Summary|PRE doesn't simplify during |[4.4 Regression] PRE doesn't
                   |phi-translation             |simplify during phi-
                   |                            |translation
   Target Milestone|---                         |4.4.0


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug tree-optimization/37542] [4.4 Regression] PRE doesn't simplify during phi-translation
  2008-09-16 15:23 [Bug tree-optimization/37542] New: PRE doesn't simplify during phi-translation 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
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-09-22 12:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from rguenth at gcc dot gnu dot org  2008-09-22 12:20 -------
Current PRE simplifies only a subset of previous PRE - see
tree-ssa-pre.c:fully_constant_expression.


-- 


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug tree-optimization/37542] [4.4 Regression] PRE doesn't simplify during phi-translation
  2008-09-16 15:23 [Bug tree-optimization/37542] New: PRE doesn't simplify during phi-translation rguenth at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  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
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2008-10-22  3:47 UTC (permalink / raw)
  To: gcc-bugs



-- 

mmitchel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug tree-optimization/37542] [4.4 Regression] PRE doesn't simplify during phi-translation
  2008-09-16 15:23 [Bug tree-optimization/37542] New: PRE doesn't simplify during phi-translation rguenth at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2008-10-22  3:47 ` mmitchel at gcc dot gnu dot org
@ 2008-11-01 17:12 ` rguenth at gcc dot gnu dot org
  2008-11-01 17:13 ` rguenth at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-11-01 17:12 UTC (permalink / raw)
  To: gcc-bugs



------- 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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug tree-optimization/37542] [4.4 Regression] PRE doesn't simplify during phi-translation
  2008-09-16 15:23 [Bug tree-optimization/37542] New: PRE doesn't simplify during phi-translation rguenth at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2008-11-01 17:12 ` rguenth at gcc dot gnu dot org
@ 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
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-11-01 17:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rguenth at gcc dot gnu dot org  2008-11-01 17:12 -------
Created an attachment (id=16609)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16609&action=view)
preliminary patch

preliminary patch, only dealing with optimizing to constants.


-- 


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug tree-optimization/37542] [4.4 Regression] PRE doesn't simplify during phi-translation
  2008-09-16 15:23 [Bug tree-optimization/37542] New: PRE doesn't simplify during phi-translation rguenth at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  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
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-11-02 15:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from rguenth at gcc dot gnu dot org  2008-11-02 15:27 -------
Subject: Bug 37542

Author: rguenth
Date: Sun Nov  2 15:26:04 2008
New Revision: 141534

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=141534
Log:
2008-11-02  Richard Guenther  <rguenther@suse.de>

        PR tree-optimization/37542
        * tree-ssa-pre.c (fully_constant_expression): Handle more cases.
        * tree-ssa-sccvn.c (vn_get_expr_for): Fix typo.
        (vn_nary_op_lookup_stmt): Adjust for unary reference trees.
        (vn_nary_op_insert_stmt): Likewise.
        (visit_use): Likewise.

        * gcc.dg/tree-ssa/ssa-pre-22.c: New testcase.
        * gcc.c-torture/compile/20081101-1.c: Likewise.

Added:
    trunk/gcc/testsuite/gcc.c-torture/compile/20081101-1.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-22.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-pre.c
    trunk/gcc/tree-ssa-sccvn.c


-- 


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug tree-optimization/37542] [4.4 Regression] PRE doesn't simplify during phi-translation
  2008-09-16 15:23 [Bug tree-optimization/37542] New: PRE doesn't simplify during phi-translation rguenth at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2008-11-02 15:28 ` rguenth at gcc dot gnu dot org
@ 2008-11-02 15:29 ` rguenth at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-11-02 15:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from rguenth at gcc dot gnu dot org  2008-11-02 15:27 -------
Fixed as far as constants are concerned.  For the non-constant case I'll open
another bug.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2008-11-02 15:29 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-16 15:23 [Bug tree-optimization/37542] New: PRE doesn't simplify during phi-translation 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
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

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).