* [Bug tree-optimization/52091] [4.7 Regression] ICE: verify_gimple failed
2012-02-02 4:42 [Bug c/52091] New: ICE: verify_gimple failed regehr at cs dot utah.edu
@ 2012-02-02 4:47 ` pinskia at gcc dot gnu.org
2012-02-02 4:53 ` pinskia at gcc dot gnu.org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-02-02 4:47 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52091
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |4.7.0
Summary|ICE: verify_gimple failed |[4.7 Regression] ICE:
| |verify_gimple failed
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/52091] [4.7 Regression] ICE: verify_gimple failed
2012-02-02 4:42 [Bug c/52091] New: ICE: verify_gimple failed regehr at cs dot utah.edu
2012-02-02 4:47 ` [Bug tree-optimization/52091] [4.7 Regression] " pinskia at gcc dot gnu.org
@ 2012-02-02 4:53 ` pinskia at gcc dot gnu.org
2012-02-02 8:30 ` jakub at gcc dot gnu.org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-02-02 4:53 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52091
Andrew Pinski <pinskia at gcc dot gnu.org> 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 <pinskia at gcc dot gnu.org> 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 <http://gcc.gnu.org/bugs.html> for instructions.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/52091] [4.7 Regression] ICE: verify_gimple failed
2012-02-02 4:42 [Bug c/52091] New: ICE: verify_gimple failed regehr at cs dot utah.edu
2012-02-02 4:47 ` [Bug tree-optimization/52091] [4.7 Regression] " pinskia at gcc dot gnu.org
2012-02-02 4:53 ` pinskia at gcc dot gnu.org
@ 2012-02-02 8:30 ` jakub at gcc dot gnu.org
2012-02-02 9:01 ` jakub at gcc dot gnu.org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-02-02 8:30 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52091
Jakub Jelinek <jakub at gcc dot gnu.org> 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 <jakub at gcc dot gnu.org> 2012-02-02 08:29:41 UTC ---
Looking at it.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/52091] [4.7 Regression] ICE: verify_gimple failed
2012-02-02 4:42 [Bug c/52091] New: ICE: verify_gimple failed regehr at cs dot utah.edu
` (2 preceding siblings ...)
2012-02-02 8:30 ` jakub at gcc dot gnu.org
@ 2012-02-02 9:01 ` jakub at gcc dot gnu.org
2012-02-02 12:07 ` jakub at gcc dot gnu.org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-02-02 9:01 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52091
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-02-02 09:00:36 UTC ---
Started with http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=178728
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/52091] [4.7 Regression] ICE: verify_gimple failed
2012-02-02 4:42 [Bug c/52091] New: ICE: verify_gimple failed regehr at cs dot utah.edu
` (3 preceding siblings ...)
2012-02-02 9:01 ` jakub at gcc dot gnu.org
@ 2012-02-02 12:07 ` jakub at gcc dot gnu.org
2012-02-02 13:23 ` irar at il dot ibm.com
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-02-02 12:07 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52091
Jakub Jelinek <jakub at gcc dot gnu.org> 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 <jakub at gcc dot gnu.org> 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.jj 2012-02-01 10:33:58.000000000 +0100
+++ gcc/tree-vect-stmts.c 2012-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.jj 2011-12-16 08:37:45.000000000 +0100
+++ gcc/tree-vect-loop.c 2012-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.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/52091] [4.7 Regression] ICE: verify_gimple failed
2012-02-02 4:42 [Bug c/52091] New: ICE: verify_gimple failed regehr at cs dot utah.edu
` (4 preceding siblings ...)
2012-02-02 12:07 ` jakub at gcc dot gnu.org
@ 2012-02-02 13:23 ` irar at il dot ibm.com
2012-02-02 13:42 ` jakub at gcc dot gnu.org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: irar at il dot ibm.com @ 2012-02-02 13:23 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52091
Ira Rosen <irar at il dot ibm.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |irar at il dot ibm.com
--- Comment #5 from Ira Rosen <irar at il dot ibm.com> 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 <d.3_44(7), pretmp.16_28(2)> ,
is a phi node marked as double reduction:
<bb 3>:
# f.6_36 = PHI <f.7_13(7), 0(2)>
# prephitmp.17_21 = PHI <d.3_44(7), pretmp.16_28(2)> - double reduction phi
...
D.2030_19 = prephitmp.17_21 & 65535; - not a reduction stmt
...
<bb 4>:
# b.4_41 = PHI <b.5_11(5), 0(3)>
...
d.3_9 = d_lsm.23_31 & 1;
...
<bb 6>:
# d.3_44 = PHI <d.3_9(4)> - 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?
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/52091] [4.7 Regression] ICE: verify_gimple failed
2012-02-02 4:42 [Bug c/52091] New: ICE: verify_gimple failed regehr at cs dot utah.edu
` (5 preceding siblings ...)
2012-02-02 13:23 ` irar at il dot ibm.com
@ 2012-02-02 13:42 ` jakub at gcc dot gnu.org
2012-02-02 15:16 ` irar at il dot ibm.com
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-02-02 13:42 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52091
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> 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.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/52091] [4.7 Regression] ICE: verify_gimple failed
2012-02-02 4:42 [Bug c/52091] New: ICE: verify_gimple failed regehr at cs dot utah.edu
` (6 preceding siblings ...)
2012-02-02 13:42 ` jakub at gcc dot gnu.org
@ 2012-02-02 15:16 ` irar at il dot ibm.com
2012-02-05 5:59 ` irar at gcc dot gnu.org
2012-02-06 8:42 ` irar at il dot ibm.com
9 siblings, 0 replies; 11+ messages in thread
From: irar at il dot ibm.com @ 2012-02-02 15:16 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52091
--- Comment #7 from Ira Rosen <irar at il dot ibm.com> 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.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/52091] [4.7 Regression] ICE: verify_gimple failed
2012-02-02 4:42 [Bug c/52091] New: ICE: verify_gimple failed regehr at cs dot utah.edu
` (7 preceding siblings ...)
2012-02-02 15:16 ` irar at il dot ibm.com
@ 2012-02-05 5:59 ` irar at gcc dot gnu.org
2012-02-06 8:42 ` irar at il dot ibm.com
9 siblings, 0 replies; 11+ messages in thread
From: irar at gcc dot gnu.org @ 2012-02-05 5:59 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/52091] [4.7 Regression] ICE: verify_gimple failed
2012-02-02 4:42 [Bug c/52091] New: ICE: verify_gimple failed regehr at cs dot utah.edu
` (8 preceding siblings ...)
2012-02-05 5:59 ` irar at gcc dot gnu.org
@ 2012-02-06 8:42 ` irar at il dot ibm.com
9 siblings, 0 replies; 11+ messages in thread
From: irar at il dot ibm.com @ 2012-02-06 8:42 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52091
Ira Rosen <irar at il dot ibm.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
--- Comment #9 from Ira Rosen <irar at il dot ibm.com> 2012-02-06 08:42:00 UTC ---
Fixed.
^ permalink raw reply [flat|nested] 11+ messages in thread