[Bug tree-optimization/52091] [4.7 Regression] ICE: verify_gimple failed

2012-02-06 Thread irar at il dot ibm.com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52091

Ira Rosen  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED

--- Comment #9 from Ira Rosen  2012-02-06 08:42:00 UTC 
---
Fixed.


[Bug tree-optimization/52091] [4.7 Regression] ICE: verify_gimple failed

2012-02-04 Thread irar at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52091

--- Comment #8 from irar at gcc dot gnu.org 2012-02-05 05:58:22 UTC ---
Author: irar
Date: Sun Feb  5 05:58:18 2012
New Revision: 183902

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183902
Log:

PR tree-optimization/52091
* tree-vectorizer.h (vect_is_simple_use): Add an argument.
(vect_is_simple_use_1): Likewise.
* tree-vect-loop.c (vectorizable_reduction): Update calls
to vect_is_simple_use_1 and vect_is_simple_use.
(vectorizable_live_operation): Likewise.
* tree-vect-patterns.c (widened_name_p,
vect_recog_vector_vector_shift_pattern, check_bool_pattern):
Likewise.
* tree-vect-stmts.c (process_use, vect_get_vec_def_for_operand,
vectorizable_call, vectorizable_conversion,
vectorizable_assignment, vectorizable_shift,
vectorizable_operation, vectorizable_store, vectorizable_load):
Likewise.
(vect_is_simple_cond): Add an argument, pass it to
vect_is_simple_use_1.
(vectorizable_condition): Update calls to vect_is_simple_cond,
vect_is_simple_use.
(vect_is_simple_use): Add an argument, the statement in which
OPERAND is used.  Check that if OPERAND's def stmt is a double
reduction phi node, the use is a phi node too.
(vect_is_simple_use_1): Add an argument, pass it to
vect_is_simple_use.
* tree-vect-slp.c (vect_get_and_check_slp_defs): Update a call
to vect_is_simple_use.


Added:
trunk/gcc/testsuite/gcc.dg/vect/pr52091.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree-vect-loop.c
trunk/gcc/tree-vect-patterns.c
trunk/gcc/tree-vect-slp.c
trunk/gcc/tree-vect-stmts.c
trunk/gcc/tree-vectorizer.h


[Bug tree-optimization/52091] [4.7 Regression] ICE: verify_gimple failed

2012-02-02 Thread irar at il dot ibm.com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52091

--- Comment #7 from Ira Rosen  2012-02-02 15:16:18 UTC 
---
(In reply to comment #6)
> (In reply to comment #5)
> > I think we should fail to vectorize D.2030_19 = prephitmp.17_21 & 65535, or 
> > any
> > other non-phi/not vect_double_reduction_def stmt with a double reduction 
> > phi as
> > a def_stmt.
> > 
> > We can either check this in every vectorizable_* for every operand, like 
> > this:
> > Index: tree-vect-stmts.c
> > ===
> > --- tree-vect-stmts.c   (revision 183125)
> > +++ tree-vect-stmts.c   (working copy)
> > @@ -3326,7 +3326,8 @@ vectorizable_operation (gimple stmt, gimple_stmt_i
> > 
> >op0 = gimple_assign_rhs1 (stmt);
> >if (!vect_is_simple_use_1 (op0, loop_vinfo, bb_vinfo,
> > -&def_stmt, &def, &dt[0], &vectype))
> > +&def_stmt, &def, &dt[0], &vectype)
> > +  || dt[0] == vect_double_reduction_def)
> >  {
> >if (vect_print_dump_info (REPORT_DETAILS))
> >  fprintf (vect_dump, "use not simple.");
> > 
> > 
> > or pass stmt or stmt_info to vect_is_simple_use and check it there.
> 
> Are you going to write a patch for this?  Not sure how exactly would you like
> it to look up.
> 

We need to check that if def_stmt is vect_double_reduction_def, the stmt itself
needs to be vect_double_reduction_def. We know def_type (dt in the above patch)
of def_stmt from vect_is_simple_use. We call it from all the vectorizable_*
functions. We don't pass the stmt itself to vect_is_simple_use, therefore, we
should either do that and perform the check in vect_is_simple_use, or check
this in all the vectorizable_* (except perhaps vectorizable_reduction). I
prefer to pass stmt or stmt_info to vect_is_simple_use.

I can do this on Sunday. You are welcome to do this yourself. Whatever you
prefer.


[Bug tree-optimization/52091] [4.7 Regression] ICE: verify_gimple failed

2012-02-02 Thread jakub at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52091

--- Comment #6 from Jakub Jelinek  2012-02-02 
13:41:01 UTC ---
(In reply to comment #5)
> I think we should fail to vectorize D.2030_19 = prephitmp.17_21 & 65535, or 
> any
> other non-phi/not vect_double_reduction_def stmt with a double reduction phi 
> as
> a def_stmt.
> 
> We can either check this in every vectorizable_* for every operand, like this:
> Index: tree-vect-stmts.c
> ===
> --- tree-vect-stmts.c   (revision 183125)
> +++ tree-vect-stmts.c   (working copy)
> @@ -3326,7 +3326,8 @@ vectorizable_operation (gimple stmt, gimple_stmt_i
> 
>op0 = gimple_assign_rhs1 (stmt);
>if (!vect_is_simple_use_1 (op0, loop_vinfo, bb_vinfo,
> -&def_stmt, &def, &dt[0], &vectype))
> +&def_stmt, &def, &dt[0], &vectype)
> +  || dt[0] == vect_double_reduction_def)
>  {
>if (vect_print_dump_info (REPORT_DETAILS))
>  fprintf (vect_dump, "use not simple.");
> 
> 
> or pass stmt or stmt_info to vect_is_simple_use and check it there.

Are you going to write a patch for this?  Not sure how exactly would you like
it to look up.

> > OT, it is strange that we are creating a reduction for a loop which loops
> > exactly as many times as there are units in the vector, that doesn't seem 
> > to be
> > profitable.
> > 
> 
> Right, but doesn't cost model catch this?

For simple testcases it does apparently.


[Bug tree-optimization/52091] [4.7 Regression] ICE: verify_gimple failed

2012-02-02 Thread irar at il dot ibm.com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52091

Ira Rosen  changed:

   What|Removed |Added

 CC||irar at il dot ibm.com

--- Comment #5 from Ira Rosen  2012-02-02 13:22:53 UTC 
---
(In reply to comment #4)

I think that the problem here is that 
D.2030_19 = prephitmp.17_21 & 65535
is falsely initialized as reduction, while it isn't a reduction. The mistake
occurs because its def_stmt, 
prephitmp.17_21 = PHI  ,
is a phi node marked as double reduction:

:
  # f.6_36 = PHI 
  # prephitmp.17_21 = PHI  - double reduction phi
   ...
  D.2030_19 = prephitmp.17_21 & 65535; - not a reduction stmt
   ...
:
  # b.4_41 = PHI 
   ...
  d.3_9 = d_lsm.23_31 & 1;
   ...

:
  # d.3_44 = PHI- double reduction stmt

I think we should fail to vectorize D.2030_19 = prephitmp.17_21 & 65535, or any
other non-phi/not vect_double_reduction_def stmt with a double reduction phi as
a def_stmt.

We can either check this in every vectorizable_* for every operand, like this:
Index: tree-vect-stmts.c
===
--- tree-vect-stmts.c   (revision 183125)
+++ tree-vect-stmts.c   (working copy)
@@ -3326,7 +3326,8 @@ vectorizable_operation (gimple stmt, gimple_stmt_i

   op0 = gimple_assign_rhs1 (stmt);
   if (!vect_is_simple_use_1 (op0, loop_vinfo, bb_vinfo,
-&def_stmt, &def, &dt[0], &vectype))
+&def_stmt, &def, &dt[0], &vectype)
+  || dt[0] == vect_double_reduction_def)
 {
   if (vect_print_dump_info (REPORT_DETAILS))
 fprintf (vect_dump, "use not simple.");


or pass stmt or stmt_info to vect_is_simple_use and check it there.


> OT, it is strange that we are creating a reduction for a loop which loops
> exactly as many times as there are units in the vector, that doesn't seem to 
> be
> profitable.
> 

Right, but doesn't cost model catch this?


[Bug tree-optimization/52091] [4.7 Regression] ICE: verify_gimple failed

2012-02-02 Thread jakub at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52091

Jakub Jelinek  changed:

   What|Removed |Added

 Status|ASSIGNED|NEW
 CC||irar at gcc dot gnu.org
 AssignedTo|jakub at gcc dot gnu.org|unassigned at gcc dot
   ||gnu.org

--- Comment #4 from Jakub Jelinek  2012-02-02 
12:06:27 UTC ---
Executable testcase:

/* PR tree-optimization/52091 */

int b, c, d, f;
unsigned h;
extern void abort (void);

int
main ()
{
  d = -1;
  h = 65;
  asm volatile ("" : : : "memory");
  for (f = 0; f < 4; f++)
{
  h &= (unsigned short) d;
  for (b = 0; b <= 1; b++)
{
  c = 0;
  d &= 1;
}
}
  asm volatile ("" : : : "memory");
  if (b != 2 || c != 0 || d != 1 || f != 4 || h != 1)
abort ();
  return 0;
}

Following patch fixes the ICE:
--- gcc/tree-vect-stmts.c.jj2012-02-01 10:33:58.0 +0100
+++ gcc/tree-vect-stmts.c2012-02-02 11:50:42.623948066 +0100
@@ -1294,7 +1294,11 @@ vect_get_vec_def_for_operand (tree op, g

 /* Get the def before the loop  */
 op = PHI_ARG_DEF_FROM_EDGE (def_stmt, loop_preheader_edge (loop));
-return get_initial_def_for_reduction (stmt, op, scalar_def);
+vec_oprnd = get_initial_def_for_reduction (stmt, op, scalar_def);
+if (!is_gimple_val (vec_oprnd))
+  vec_oprnd = vect_init_vector (stmt, vec_oprnd,
+TREE_TYPE (vec_oprnd), NULL);
+return vec_oprnd;
  }

 /* Case 5: operand is defined by loop-header phi - induction.  */
but just turns ice-on-valid-code into wrong-code, h is 65 when vectorizing.

Ira, could you please look at this?  Thanks.

OT, it is strange that we are creating a reduction for a loop which loops
exactly as many times as there are units in the vector, that doesn't seem to be
profitable.

My other attempt to fix the ICE was:
--- gcc/tree-vect-loop.c.jj2011-12-16 08:37:45.0 +0100
+++ gcc/tree-vect-loop.c2012-02-02 11:57:25.354607843 +0100
@@ -3370,7 +3370,10 @@ get_initial_def_for_reduction (gimple st
 if (TREE_CONSTANT (init_val))
   init_def = build_vector (vectype, t);
 else
-  init_def = build_constructor_from_list (vectype, t);
+  {
+init_def = build_constructor_from_list (vectype, t);
+init_def = vect_init_vector (stmt, init_def, vectype, NULL);
+  }

 break;
but that ICEs on the testcase, because the other caller of
get_initial_def_for_reduction is calling vect_init_vector immediately after it,
with a different stmt than was passed to get_initial_def_for_reduction, and
this resulted in definition not dominating the use.  Wonder if that isn't
another bug.


[Bug tree-optimization/52091] [4.7 Regression] ICE: verify_gimple failed

2012-02-02 Thread jakub at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52091

--- Comment #3 from Jakub Jelinek  2012-02-02 
09:00:36 UTC ---
Started with http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=178728


[Bug tree-optimization/52091] [4.7 Regression] ICE: verify_gimple failed

2012-02-02 Thread jakub at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52091

Jakub Jelinek  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
 CC||jakub at gcc dot gnu.org
 AssignedTo|unassigned at gcc dot   |jakub at gcc dot gnu.org
   |gnu.org |

--- Comment #2 from Jakub Jelinek  2012-02-02 
08:29:41 UTC ---
Looking at it.


[Bug tree-optimization/52091] [4.7 Regression] ICE: verify_gimple failed

2012-02-01 Thread pinskia at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52091

Andrew Pinski  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2012-02-02
   Host|x86_64-unknown-linux-gnu|
 Ever Confirmed|0   |1
  Build|x86_64-unknown-linux-gnu|

--- Comment #1 from Andrew Pinski  2012-02-02 
04:53:25 UTC ---
Confirmed reduced testcase:
int b,c,d,f;
unsigned h;

void fn52 (void)
{
  for (f = 4; f; f--)
{
  h &= (unsigned short)d;
  for (b = 0; b <= 1; b++)
  {
   c = 0;
   d &= 1;
  }
}
}
 CUT 

Note also:
int b,c,d,f;
unsigned h;

void fn52 (void)
{
  for (f = 4; f; f--)
{
  h &= d;
  for (b = 0; b <= 1; b++)
  {
   c = 0;
   d &= 1;
  }
}
}
 CUT 
Gives a slightly different ICE:
t.c: In function ‘fn52’:
t.c:4:6: internal compiler error: in get_initial_def_for_reduction, at
tree-vect-loop.c:3391
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.


[Bug tree-optimization/52091] [4.7 Regression] ICE: verify_gimple failed

2012-02-01 Thread pinskia at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52091

Andrew Pinski  changed:

   What|Removed |Added

   Target Milestone|--- |4.7.0
Summary|ICE: verify_gimple failed   |[4.7 Regression] ICE:
   ||verify_gimple failed