[Bug tree-optimization/37542] [4.4 Regression] PRE doesn't simplify during phi-translation

2008-11-02 Thread rguenth at gcc dot gnu dot org


--- 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=gccview=revrev=141534
Log:
2008-11-02  Richard Guenther  [EMAIL PROTECTED]

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



[Bug tree-optimization/37542] [4.4 Regression] PRE doesn't simplify during phi-translation

2008-11-02 Thread rguenth at gcc dot gnu dot org


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



[Bug tree-optimization/37542] [4.4 Regression] PRE doesn't simplify during phi-translation

2008-11-01 Thread rguenth at gcc dot gnu dot org


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



[Bug tree-optimization/37542] [4.4 Regression] PRE doesn't simplify during phi-translation

2008-11-01 Thread rguenth at gcc dot gnu dot org


--- 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=16609action=view)
preliminary patch

preliminary patch, only dealing with optimizing to constants.


-- 


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



[Bug tree-optimization/37542] [4.4 Regression] PRE doesn't simplify during phi-translation

2008-10-21 Thread mmitchel at gcc dot gnu dot org


-- 

mmitchel at gcc dot gnu dot org changed:

   What|Removed |Added

   Priority|P3  |P2


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



[Bug tree-optimization/37542] [4.4 Regression] PRE doesn't simplify during phi-translation

2008-09-22 Thread rguenth at gcc dot gnu dot org


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



[Bug tree-optimization/37542] [4.4 Regression] PRE doesn't simplify during phi-translation

2008-09-16 Thread rguenth at gcc dot gnu dot org


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