* [Bug tree-optimization/59651] Vectorizer failing to spot dependence causes incorrect code generation.
2013-12-31 16:28 [Bug tree-optimization/59651] New: Vectorizer failing to spot dependence causes incorrect code generation belagod at gcc dot gnu.org
@ 2013-12-31 16:53 ` bmei at broadcom dot com
2013-12-31 17:12 ` belagod at gcc dot gnu.org
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: bmei at broadcom dot com @ 2013-12-31 16:53 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59651
--- Comment #1 from Bingfeng Mei <bmei at broadcom dot com> ---
That is interesting. On x86-64, GCC does say it cannot determine dist vector
between a[3] & a[b] and needs run-time aliasing test. In the end it gives up
due to too few iterations.
note: === vect_analyze_data_ref_dependences ===
(compute_affine_dependence
stmt_a: _5 = a[3];
stmt_b: a[b.0_16] = _7;
(analyze_overlapping_iterations
(chrec_a = 3)
(chrec_b = {3, +, -1}_1)
(analyze_siv_subscript
)
(overlap_iterations_a = [0])
(overlap_iterations_b = [0]))
(Dependence relation cannot be represented by distance vector.)
)
(compute_affine_dependence
stmt_a: _5 = a[3];
stmt_b: _5 = a[3];
(analyze_overlapping_iterations
(chrec_a = 3)
(chrec_b = 3)
(overlap_iterations_a = [0])
(overlap_iterations_b = [0]))
)
(compute_affine_dependence
stmt_a: a[b.0_16] = _7;
stmt_b: a[b.0_16] = _7;
(analyze_overlapping_iterations
(chrec_a = {3, +, -1}_1)
(chrec_b = {3, +, -1}_1)
(overlap_iterations_a = [0])
(overlap_iterations_b = [0]))
)
/projects/firepath_tools1_scratch/bmei/trunk/gcc/testsuite/gcc.dg/torture/pr52943.c:13:7:
note: versioning for alias required: bad dist vector for a[3] and a[b.0_16]
/projects/firepath_tools1_scratch/bmei/trunk/gcc/testsuite/gcc.dg/torture/pr52943.c:13:7:
note: mark for run-time aliasing test between a[3] and a[b.0_16]
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/59651] Vectorizer failing to spot dependence causes incorrect code generation.
2013-12-31 16:28 [Bug tree-optimization/59651] New: Vectorizer failing to spot dependence causes incorrect code generation belagod at gcc dot gnu.org
2013-12-31 16:53 ` [Bug tree-optimization/59651] " bmei at broadcom dot com
@ 2013-12-31 17:12 ` belagod at gcc dot gnu.org
2013-12-31 21:07 ` [Bug tree-optimization/59651] [4.9 Regression] " pinskia at gcc dot gnu.org
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: belagod at gcc dot gnu.org @ 2013-12-31 17:12 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59651
--- Comment #2 from belagod at gcc dot gnu.org ---
Something simliar happens on aarch64, but later goes ahead and vectorizes it
anyway. How about trying to vectorize on x86 with -fno-vect-cost-model?
pr.c:13:7: note: === vect_analyze_data_ref_dependences ===
(compute_affine_dependence
stmt_a: _5 = a[3];
stmt_b: a[b.0_16] = _7;
(analyze_overlapping_iterations
(chrec_a = 3)
(chrec_b = {3, +, -1}_1)
(analyze_siv_subscript
)
(overlap_iterations_a = [0])
(overlap_iterations_b = [0]))
(Dependence relation cannot be represented by distance vector.)
)
(compute_affine_dependence
stmt_a: _5 = a[3];
stmt_b: _5 = a[3];
(analyze_overlapping_iterations
(chrec_a = 3)
(chrec_b = 3)
(overlap_iterations_a = [0])
(overlap_iterations_b = [0]))
)
(compute_affine_dependence
stmt_a: a[b.0_16] = _7;
stmt_b: a[b.0_16] = _7;
(analyze_overlapping_iterations
(chrec_a = {3, +, -1}_1)
(chrec_b = {3, +, -1}_1)
(overlap_iterations_a = [0])
(overlap_iterations_b = [0]))
)
pr.c:13:7: note: versioning for alias required: bad dist vector for a[3] and
a[b.0_16]
pr.c:13:7: note: mark for run-time aliasing test between a[3] and a[b.0_16]
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/59651] [4.9 Regression] Vectorizer failing to spot dependence causes incorrect code generation.
2013-12-31 16:28 [Bug tree-optimization/59651] New: Vectorizer failing to spot dependence causes incorrect code generation belagod at gcc dot gnu.org
2013-12-31 16:53 ` [Bug tree-optimization/59651] " bmei at broadcom dot com
2013-12-31 17:12 ` belagod at gcc dot gnu.org
@ 2013-12-31 21:07 ` pinskia at gcc dot gnu.org
2013-12-31 22:42 ` bmei at broadcom dot com
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2013-12-31 21:07 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59651
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
Target Milestone|--- |4.9.0
Summary|Vectorizer failing to spot |[4.9 Regression] Vectorizer
|dependence causes incorrect |failing to spot dependence
|code generation. |causes incorrect code
| |generation.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/59651] [4.9 Regression] Vectorizer failing to spot dependence causes incorrect code generation.
2013-12-31 16:28 [Bug tree-optimization/59651] New: Vectorizer failing to spot dependence causes incorrect code generation belagod at gcc dot gnu.org
` (2 preceding siblings ...)
2013-12-31 21:07 ` [Bug tree-optimization/59651] [4.9 Regression] " pinskia at gcc dot gnu.org
@ 2013-12-31 22:42 ` bmei at broadcom dot com
2014-01-01 18:31 ` belagod at gcc dot gnu.org
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: bmei at broadcom dot com @ 2013-12-31 22:42 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59651
--- Comment #3 from Bingfeng Mei <bmei at broadcom dot com> ---
I can reproduce on aarch64. Still try to understand why. I constructed a
similar test but with positive loop step.
extern void abort (void);
int a[] = { 6, 0, 0, 0 };
int b;
int
main ()
{
for (;;)
{
b = 0;
for (; b<3; b += 1)
a[b] = a[0] > 1;
break;
}
if (a[2] != 0)
abort ();
return 0;
}
Actually GCC behaves similarly during vectorization and does vectorize the
loop. The only difference is around loop versioning.
pr52943.c
<bb 10>:
if (1 != 0)
goto <bb 11>;
else
goto <bb 12>;
bb 11 leads to vectorized version. So scalar version gets optimized out.
Above example:
<bb 10>:
if (0 != 0)
goto <bb 11>;
else
goto <bb 12>;
So vectorized version goes away and only scalar version remains.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/59651] [4.9 Regression] Vectorizer failing to spot dependence causes incorrect code generation.
2013-12-31 16:28 [Bug tree-optimization/59651] New: Vectorizer failing to spot dependence causes incorrect code generation belagod at gcc dot gnu.org
` (3 preceding siblings ...)
2013-12-31 22:42 ` bmei at broadcom dot com
@ 2014-01-01 18:31 ` belagod at gcc dot gnu.org
2014-01-02 11:04 ` bmei at broadcom dot com
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: belagod at gcc dot gnu.org @ 2014-01-01 18:31 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59651
--- Comment #4 from belagod at gcc dot gnu.org ---
Thanks for looking at this.
Just to clarify, do you mean loop versioning happens in the up-counting loop?
Because in the down-counting loop, a partition seems to be happening with 2
iterations of the loop getting vectorized and the remaining 2 are left scalar.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/59651] [4.9 Regression] Vectorizer failing to spot dependence causes incorrect code generation.
2013-12-31 16:28 [Bug tree-optimization/59651] New: Vectorizer failing to spot dependence causes incorrect code generation belagod at gcc dot gnu.org
` (4 preceding siblings ...)
2014-01-01 18:31 ` belagod at gcc dot gnu.org
@ 2014-01-02 11:04 ` bmei at broadcom dot com
2014-01-02 11:37 ` belagod at gcc dot gnu.org
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: bmei at broadcom dot com @ 2014-01-02 11:04 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59651
--- Comment #5 from Bingfeng Mei <bmei at broadcom dot com> ---
Created attachment 31559
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31559&action=edit
initial patch
Hi, Tejas, vect_create_cond_for_alias_checks contains a bug in handling
negative step. The computed data access range should be shifted by
TYPE_SIZE_UNIT of bytes. Could you test the attached patch on aarch64 (I don't
have simulation environment setup)? Meanwhile I will check whether there is any
regression on x86-64. If everything is right, I am going to submit the patch.
Thanks.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/59651] [4.9 Regression] Vectorizer failing to spot dependence causes incorrect code generation.
2013-12-31 16:28 [Bug tree-optimization/59651] New: Vectorizer failing to spot dependence causes incorrect code generation belagod at gcc dot gnu.org
` (5 preceding siblings ...)
2014-01-02 11:04 ` bmei at broadcom dot com
@ 2014-01-02 11:37 ` belagod at gcc dot gnu.org
2014-01-03 10:53 ` belagod at gcc dot gnu.org
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: belagod at gcc dot gnu.org @ 2014-01-02 11:37 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59651
--- Comment #6 from belagod at gcc dot gnu.org ---
Thanks for the patch. It fixes this particular test case regression. I've
kicked off a full regression and will let you know the results soon.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/59651] [4.9 Regression] Vectorizer failing to spot dependence causes incorrect code generation.
2013-12-31 16:28 [Bug tree-optimization/59651] New: Vectorizer failing to spot dependence causes incorrect code generation belagod at gcc dot gnu.org
` (6 preceding siblings ...)
2014-01-02 11:37 ` belagod at gcc dot gnu.org
@ 2014-01-03 10:53 ` belagod at gcc dot gnu.org
2014-01-03 15:41 ` meibf at gcc dot gnu.org
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: belagod at gcc dot gnu.org @ 2014-01-03 10:53 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59651
--- Comment #7 from Tejas Belagod <belagod at gcc dot gnu.org> ---
AArch64 regressions came back OK. Thanks!
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/59651] [4.9 Regression] Vectorizer failing to spot dependence causes incorrect code generation.
2013-12-31 16:28 [Bug tree-optimization/59651] New: Vectorizer failing to spot dependence causes incorrect code generation belagod at gcc dot gnu.org
` (7 preceding siblings ...)
2014-01-03 10:53 ` belagod at gcc dot gnu.org
@ 2014-01-03 15:41 ` meibf at gcc dot gnu.org
2014-01-04 12:04 ` jakub at gcc dot gnu.org
2014-01-21 14:16 ` mshawcroft at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: meibf at gcc dot gnu.org @ 2014-01-03 15:41 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59651
--- Comment #8 from meibf at gcc dot gnu.org ---
Author: meibf
Date: Fri Jan 3 15:40:57 2014
New Revision: 206319
URL: http://gcc.gnu.org/viewcvs?rev=206319&root=gcc&view=rev
Log:
2014-01-03 Bingfeng Mei <bmei@broadcom.com>
PR tree-optimization/59651
* tree-vect-loop-manip.c (vect_create_cond_for_alias_checks):
Address range for negative step should be added by TYPE_SIZE_UNIT.
PR tree-optimization/59651
* gcc.dg/torture/pr59651.c: New test.
* gcc.dg/vect/pr59651.c: Ditto.
Added:
trunk/gcc/testsuite/gcc.dg/torture/pr59651.c
trunk/gcc/testsuite/gcc.dg/vect/pr59651.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree-vect-loop-manip.c
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/59651] [4.9 Regression] Vectorizer failing to spot dependence causes incorrect code generation.
2013-12-31 16:28 [Bug tree-optimization/59651] New: Vectorizer failing to spot dependence causes incorrect code generation belagod at gcc dot gnu.org
` (8 preceding siblings ...)
2014-01-03 15:41 ` meibf at gcc dot gnu.org
@ 2014-01-04 12:04 ` jakub at gcc dot gnu.org
2014-01-21 14:16 ` mshawcroft at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-01-04 12:04 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59651
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
CC| |jakub at gcc dot gnu.org
Resolution|--- |FIXED
--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/59651] [4.9 Regression] Vectorizer failing to spot dependence causes incorrect code generation.
2013-12-31 16:28 [Bug tree-optimization/59651] New: Vectorizer failing to spot dependence causes incorrect code generation belagod at gcc dot gnu.org
` (9 preceding siblings ...)
2014-01-04 12:04 ` jakub at gcc dot gnu.org
@ 2014-01-21 14:16 ` mshawcroft at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: mshawcroft at gcc dot gnu.org @ 2014-01-21 14:16 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59651
mshawcroft at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |christophe.lyon at st dot com
--- Comment #10 from mshawcroft at gcc dot gnu.org ---
*** Bug 59725 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 12+ messages in thread