* [Bug tree-optimization/59519] ICE on valid code at -O3 on x86_64-linux-gnu in slpeel_update_phi_nodes_for_guard1, at tree-vect-loop-manip.c:486
2013-12-16 1:39 [Bug tree-optimization/59519] New: ICE on valid code at -O3 on x86_64-linux-gnu in slpeel_update_phi_nodes_for_guard1, at tree-vect-loop-manip.c:486 su at cs dot ucdavis.edu
@ 2013-12-16 17:19 ` su at cs dot ucdavis.edu
2013-12-17 19:21 ` [Bug tree-optimization/59519] [4.9 Regression] " mpolacek at gcc dot gnu.org
` (12 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: su at cs dot ucdavis.edu @ 2013-12-16 17:19 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59519
--- Comment #1 from Zhendong Su <su at cs dot ucdavis.edu> ---
Below is simpler testcase that triggers the same ICE:
------------------------------------
int a, b, c, d;
void
foo ()
{
for (; d; d++)
for (b = 0; b < 14; b++)
{
c |= 1;
if (a)
break;
}
}
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug tree-optimization/59519] [4.9 Regression] ICE on valid code at -O3 on x86_64-linux-gnu in slpeel_update_phi_nodes_for_guard1, at tree-vect-loop-manip.c:486
2013-12-16 1:39 [Bug tree-optimization/59519] New: ICE on valid code at -O3 on x86_64-linux-gnu in slpeel_update_phi_nodes_for_guard1, at tree-vect-loop-manip.c:486 su at cs dot ucdavis.edu
2013-12-16 17:19 ` [Bug tree-optimization/59519] " su at cs dot ucdavis.edu
@ 2013-12-17 19:21 ` mpolacek at gcc dot gnu.org
2013-12-19 11:46 ` jakub at gcc dot gnu.org
` (11 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2013-12-17 19:21 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59519
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P1
Status|UNCONFIRMED |NEW
Last reconfirmed| |2013-12-17
CC| |mpolacek at gcc dot gnu.org
Target Milestone|--- |4.9.0
Summary|ICE on valid code at -O3 on |[4.9 Regression] ICE on
|x86_64-linux-gnu in |valid code at -O3 on
|slpeel_update_phi_nodes_for |x86_64-linux-gnu in
|_guard1, at |slpeel_update_phi_nodes_for
|tree-vect-loop-manip.c:486 |_guard1, at
| |tree-vect-loop-manip.c:486
Ever confirmed|0 |1
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug tree-optimization/59519] [4.9 Regression] ICE on valid code at -O3 on x86_64-linux-gnu in slpeel_update_phi_nodes_for_guard1, at tree-vect-loop-manip.c:486
2013-12-16 1:39 [Bug tree-optimization/59519] New: ICE on valid code at -O3 on x86_64-linux-gnu in slpeel_update_phi_nodes_for_guard1, at tree-vect-loop-manip.c:486 su at cs dot ucdavis.edu
2013-12-16 17:19 ` [Bug tree-optimization/59519] " su at cs dot ucdavis.edu
2013-12-17 19:21 ` [Bug tree-optimization/59519] [4.9 Regression] " mpolacek at gcc dot gnu.org
@ 2013-12-19 11:46 ` jakub at gcc dot gnu.org
2013-12-19 12:02 ` amker.cheng at gmail dot com
` (10 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-12-19 11:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59519
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |amker at gcc dot gnu.org,
| |jakub at gcc dot gnu.org
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r205959.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug tree-optimization/59519] [4.9 Regression] ICE on valid code at -O3 on x86_64-linux-gnu in slpeel_update_phi_nodes_for_guard1, at tree-vect-loop-manip.c:486
2013-12-16 1:39 [Bug tree-optimization/59519] New: ICE on valid code at -O3 on x86_64-linux-gnu in slpeel_update_phi_nodes_for_guard1, at tree-vect-loop-manip.c:486 su at cs dot ucdavis.edu
` (2 preceding siblings ...)
2013-12-19 11:46 ` jakub at gcc dot gnu.org
@ 2013-12-19 12:02 ` amker.cheng at gmail dot com
2013-12-19 14:45 ` amker.cheng at gmail dot com
` (9 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: amker.cheng at gmail dot com @ 2013-12-19 12:02 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59519
bin.cheng <amker.cheng at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |amker.cheng at gmail dot com
--- Comment #3 from bin.cheng <amker.cheng at gmail dot com> ---
I will look into it.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug tree-optimization/59519] [4.9 Regression] ICE on valid code at -O3 on x86_64-linux-gnu in slpeel_update_phi_nodes_for_guard1, at tree-vect-loop-manip.c:486
2013-12-16 1:39 [Bug tree-optimization/59519] New: ICE on valid code at -O3 on x86_64-linux-gnu in slpeel_update_phi_nodes_for_guard1, at tree-vect-loop-manip.c:486 su at cs dot ucdavis.edu
` (3 preceding siblings ...)
2013-12-19 12:02 ` amker.cheng at gmail dot com
@ 2013-12-19 14:45 ` amker.cheng at gmail dot com
2013-12-20 10:28 ` amker.cheng at gmail dot com
` (8 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: amker.cheng at gmail dot com @ 2013-12-19 14:45 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59519
--- Comment #4 from bin.cheng <amker.cheng at gmail dot com> ---
First clue.
b_lsm.11_13 is recognized as chrec {1, +, 1}_2 with the patch, thus the loop
can be vectorized now.
<bb 5>:
<bb 6>:
# b.4_30 = PHI <b.4_12(5), 1(12)>
# prephitmp_28 = PHI <c.1_9(5), c.1_21(12)>
# b_lsm.11_13 = PHI <b.4_12(5), 1(12)>
# ivtmp_46 = PHI <ivtmp_45(5), 13(12)>
c.1_9 = prephitmp_28 | 1;
b.4_12 = b.4_30 + 1;
ivtmp_45 = ivtmp_46 - 1;
if (ivtmp_45 != 0)
goto <bb 5>;
else
goto <bb 7>;
Problem arises in calling stack like:
vect_do_peeling_for_loop_bound
slpeel_tree_peel_loop_to_edge
slpeel_update_phi_nodes_for_guard1
for phi node : # b_lsm.11_13 = PHI <b.4_12(5), 1(12)>
It looks like loop peeling has difficulty in coping with peeled phi node.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug tree-optimization/59519] [4.9 Regression] ICE on valid code at -O3 on x86_64-linux-gnu in slpeel_update_phi_nodes_for_guard1, at tree-vect-loop-manip.c:486
2013-12-16 1:39 [Bug tree-optimization/59519] New: ICE on valid code at -O3 on x86_64-linux-gnu in slpeel_update_phi_nodes_for_guard1, at tree-vect-loop-manip.c:486 su at cs dot ucdavis.edu
` (4 preceding siblings ...)
2013-12-19 14:45 ` amker.cheng at gmail dot com
@ 2013-12-20 10:28 ` amker.cheng at gmail dot com
2014-01-02 15:52 ` jakub at gcc dot gnu.org
` (7 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: amker.cheng at gmail dot com @ 2013-12-20 10:28 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59519
--- Comment #5 from bin.cheng <amker.cheng at gmail dot com> ---
For the offending loop:
<bb 5>:
<bb 6>:
# b.4_30 = PHI <b.4_12(5), 1(12)>
# prephitmp_28 = PHI <c.1_9(5), c.1_21(12)>
# b_lsm.11_13 = PHI <b.4_12(5), 1(12)>
# ivtmp_46 = PHI <ivtmp_45(5), 13(12)>
c.1_9 = prephitmp_28 | 1;
b.4_12 = b.4_30 + 1;
ivtmp_45 = ivtmp_46 - 1;
if (ivtmp_45 != 0)
goto <bb 5>;
else
goto <bb 7>;
Now SCEV recognizes b_lsm.11_13 as {1,1}_2, and vectorizer considers it can be
vectorized.
The problem comes in function slpeel_update_phi_nodes_for_guard1 for phi node
:# b_lsm.11_13 = PHI <b.4_12(5), 1(12)>. It's special because its loop_arg:
b.4_12 has already been handled in previous node and has non-null current
definition, resulting in assertion failure at line:
gcc_assert (get_current_def (current_new_name) == NULL_TREE);
It seems loop manipulating utility for vectorization can't cope with this kind
PEELED phi node.
We can get more loops vectorized if we can handle this issue in vectorization.
For example, the more complicated example reported can be vectorized
successfully.
But, I think it's a little bit difficult to handle the case because it's
possible to have the PEELED phi node come before the phi node from which it's
peeled from (b.4_30, in this case), just like:
<bb 5>:
<bb 6>:
# b_lsm.11_13 = PHI <b.4_12(5), 1(12)> <----appear before b.4_30
# b.4_30 = PHI <b.4_12(5), 1(12)>
# prephitmp_28 = PHI <c.1_9(5), c.1_21(12)>
# ivtmp_46 = PHI <ivtmp_45(5), 13(12)>
c.1_9 = prephitmp_28 | 1;
b.4_12 = b.4_30 + 1;
ivtmp_45 = ivtmp_46 - 1;
if (ivtmp_45 != 0)
goto <bb 5>;
else
goto <bb 7>;
So here I come up three options:
0) handle peeled phi in slpeel_update_phi_nodes_for_guard*. Maybe two passes
scanning for phi nodes is necessary.
1) reject loops containing peeled phi node in vectorization.
2) add code to rewrite such peeled phi node into normal one.
I am new to vectorization, so any words?
Thanks,
bin
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug tree-optimization/59519] [4.9 Regression] ICE on valid code at -O3 on x86_64-linux-gnu in slpeel_update_phi_nodes_for_guard1, at tree-vect-loop-manip.c:486
2013-12-16 1:39 [Bug tree-optimization/59519] New: ICE on valid code at -O3 on x86_64-linux-gnu in slpeel_update_phi_nodes_for_guard1, at tree-vect-loop-manip.c:486 su at cs dot ucdavis.edu
` (5 preceding siblings ...)
2013-12-20 10:28 ` amker.cheng at gmail dot com
@ 2014-01-02 15:52 ` jakub at gcc dot gnu.org
2014-01-03 2:18 ` amker.cheng at gmail dot com
` (6 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-01-02 15:52 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59519
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 31562
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31562&action=edit
gcc49-pr59519.patch
I wonder if this isn't just a checking issue, the two PHI nodes created in
*new_exit_bb have the same argument, so I think it is just fine if the two PHI
results are used interchangeably, later optimization passes should hopefully
coalesce them into a single IV.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug tree-optimization/59519] [4.9 Regression] ICE on valid code at -O3 on x86_64-linux-gnu in slpeel_update_phi_nodes_for_guard1, at tree-vect-loop-manip.c:486
2013-12-16 1:39 [Bug tree-optimization/59519] New: ICE on valid code at -O3 on x86_64-linux-gnu in slpeel_update_phi_nodes_for_guard1, at tree-vect-loop-manip.c:486 su at cs dot ucdavis.edu
` (6 preceding siblings ...)
2014-01-02 15:52 ` jakub at gcc dot gnu.org
@ 2014-01-03 2:18 ` amker.cheng at gmail dot com
2014-01-03 10:01 ` jakub at gcc dot gnu.org
` (5 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: amker.cheng at gmail dot com @ 2014-01-03 2:18 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59519
--- Comment #7 from bin.cheng <amker.cheng at gmail dot com> ---
(In reply to Jakub Jelinek from comment #6)
> Created attachment 31562 [details]
> gcc49-pr59519.patch
>
> I wonder if this isn't just a checking issue, the two PHI nodes created in
> *new_exit_bb have the same argument, so I think it is just fine if the two
> PHI results are used interchangeably, later optimization passes should
> hopefully coalesce them into a single IV.
I tested one similar patch before. It passed x86_64 bootstrap and normal
regression test. It failed some ada (also one go) cases if I ran regression
test with "-O3" option. The failures look like noise to me, which I am not
sure about. What's your test results?
One potential shortage is it introduces additional PHI/copy of different ssa
names and makes the generated code some kind of ugly and hard to read, but just
as you pointed out, later passes should be able to coalescing them (I am not
sure about that, especially after seeing ssa names not get coalesced in some
more regular cases.)
Thanks.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug tree-optimization/59519] [4.9 Regression] ICE on valid code at -O3 on x86_64-linux-gnu in slpeel_update_phi_nodes_for_guard1, at tree-vect-loop-manip.c:486
2013-12-16 1:39 [Bug tree-optimization/59519] New: ICE on valid code at -O3 on x86_64-linux-gnu in slpeel_update_phi_nodes_for_guard1, at tree-vect-loop-manip.c:486 su at cs dot ucdavis.edu
` (7 preceding siblings ...)
2014-01-03 2:18 ` amker.cheng at gmail dot com
@ 2014-01-03 10:01 ` jakub at gcc dot gnu.org
2014-01-03 10:08 ` amker.cheng at gmail dot com
` (4 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-01-03 10:01 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59519
--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
BTW, the patch can hardly regress anything, it only affects cases that ICEd
before the patch.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug tree-optimization/59519] [4.9 Regression] ICE on valid code at -O3 on x86_64-linux-gnu in slpeel_update_phi_nodes_for_guard1, at tree-vect-loop-manip.c:486
2013-12-16 1:39 [Bug tree-optimization/59519] New: ICE on valid code at -O3 on x86_64-linux-gnu in slpeel_update_phi_nodes_for_guard1, at tree-vect-loop-manip.c:486 su at cs dot ucdavis.edu
` (8 preceding siblings ...)
2014-01-03 10:01 ` jakub at gcc dot gnu.org
@ 2014-01-03 10:08 ` amker.cheng at gmail dot com
2014-01-03 10:24 ` jakub at gcc dot gnu.org
` (3 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: amker.cheng at gmail dot com @ 2014-01-03 10:08 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59519
--- Comment #10 from bin.cheng <amker.cheng at gmail dot com> ---
(In reply to Jakub Jelinek from comment #9)
> BTW, the patch can hardly regress anything, it only affects cases that ICEd
> before the patch.
Em, I am worried if vectorization can handle peeled phi correctly for each
scenario before, because I barely know the implementation. That's why I looked
for your guys' suggestions in the first place.
Thanks.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug tree-optimization/59519] [4.9 Regression] ICE on valid code at -O3 on x86_64-linux-gnu in slpeel_update_phi_nodes_for_guard1, at tree-vect-loop-manip.c:486
2013-12-16 1:39 [Bug tree-optimization/59519] New: ICE on valid code at -O3 on x86_64-linux-gnu in slpeel_update_phi_nodes_for_guard1, at tree-vect-loop-manip.c:486 su at cs dot ucdavis.edu
` (9 preceding siblings ...)
2014-01-03 10:08 ` amker.cheng at gmail dot com
@ 2014-01-03 10:24 ` jakub at gcc dot gnu.org
2014-01-03 13:22 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-01-03 10:24 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59519
--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I've tried even:
struct S { int f0; } d;
int a[8] = { 0 }, b, c, e, f;
void
foo (void)
{
for (; e < 1; e++)
{
for (b = 0; b < 7; b++)
{
c |= (a[b + 1] != 0);
if (d.f0)
break;
}
f += b;
}
}
where I've hoped get_current_def would be called on the problematic loop_arg,
but apparently it isn't (the only calls are the one changed in the patch).
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug tree-optimization/59519] [4.9 Regression] ICE on valid code at -O3 on x86_64-linux-gnu in slpeel_update_phi_nodes_for_guard1, at tree-vect-loop-manip.c:486
2013-12-16 1:39 [Bug tree-optimization/59519] New: ICE on valid code at -O3 on x86_64-linux-gnu in slpeel_update_phi_nodes_for_guard1, at tree-vect-loop-manip.c:486 su at cs dot ucdavis.edu
` (10 preceding siblings ...)
2014-01-03 10:24 ` jakub at gcc dot gnu.org
@ 2014-01-03 13:22 ` jakub at gcc dot gnu.org
2014-01-04 11:23 ` jakub at gcc dot gnu.org
2014-01-04 12:03 ` jakub at gcc dot gnu.org
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-01-03 13:22 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59519
--- Comment #12 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
--target_board=unix/-O3 testing showed no changes (except for the testcases in
the patch), on both x86_64-linux and i686-linux (on the former one including
ada testing).
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug tree-optimization/59519] [4.9 Regression] ICE on valid code at -O3 on x86_64-linux-gnu in slpeel_update_phi_nodes_for_guard1, at tree-vect-loop-manip.c:486
2013-12-16 1:39 [Bug tree-optimization/59519] New: ICE on valid code at -O3 on x86_64-linux-gnu in slpeel_update_phi_nodes_for_guard1, at tree-vect-loop-manip.c:486 su at cs dot ucdavis.edu
` (11 preceding siblings ...)
2014-01-03 13:22 ` jakub at gcc dot gnu.org
@ 2014-01-04 11:23 ` jakub at gcc dot gnu.org
2014-01-04 12:03 ` jakub at gcc dot gnu.org
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-01-04 11:23 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59519
--- Comment #13 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Sat Jan 4 11:23:16 2014
New Revision: 206333
URL: http://gcc.gnu.org/viewcvs?rev=206333&root=gcc&view=rev
Log:
PR tree-optimization/59519
* tree-vect-loop-manip.c (slpeel_update_phi_nodes_for_guard1): Don't
ICE if get_current_def (current_new_name) is already non-NULL, as long
as it is a phi result of some other phi in *new_exit_bb that has
the same argument.
* gcc.dg/vect/pr59519-1.c: New test.
* gcc.dg/vect/pr59519-2.c: New test.
Added:
trunk/gcc/testsuite/gcc.dg/vect/pr59519-1.c
trunk/gcc/testsuite/gcc.dg/vect/pr59519-2.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree-vect-loop-manip.c
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug tree-optimization/59519] [4.9 Regression] ICE on valid code at -O3 on x86_64-linux-gnu in slpeel_update_phi_nodes_for_guard1, at tree-vect-loop-manip.c:486
2013-12-16 1:39 [Bug tree-optimization/59519] New: ICE on valid code at -O3 on x86_64-linux-gnu in slpeel_update_phi_nodes_for_guard1, at tree-vect-loop-manip.c:486 su at cs dot ucdavis.edu
` (12 preceding siblings ...)
2014-01-04 11:23 ` jakub at gcc dot gnu.org
@ 2014-01-04 12:03 ` jakub at gcc dot gnu.org
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-01-04 12:03 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59519
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #14 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 15+ messages in thread