[Bug tree-optimization/59594] [4.9 Regression] wrong code (by tree vectorizer) at -O3 on x86_64-linux-gnu
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Jan 22 13:22:00 GMT 2014
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59594
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 31919
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31919&action=edit
gcc49-pr59594.patch
Untested patch for discussion. The reason why we (incorrectly) vectorize the
testcase is that we ignore the data dependency, on the testcase both the b[a]
read vs. b[a+1] store and b[a] store vs. b[a+1] store DDRs have dist 1 and
DDR_REVERSED_P set and we ignore those. Now on say:
int printf (const char *, ...);
int a;
static int b[1024];
int
main ()
{
for (a = 0; a <= 512; a++)
{
b[a - 1] = b[a];
b[a] = 1;
}
printf ("%d\n", b[1]);
return 0;
}
only the b[a] read vs. b[a-1] store is dist 1 DDR_REVERSED_P and b[a] store vs.
b[a-1] store is dist 1 !DDR_REVERSED_P, thus we don't vectorize it (correctly).
Unfortunately not ignoring dist > 0 && DDR_REVERSED_P ddrs for negative step
regresses the testcase I've attached, where there is a write after read ddr and
it works properly with the current check. While the attached patch keeps that
testcase (no-vfa-vect-depend*.c) working and fixes the test (pr59594.c), the
conditions are piled completely randomly, I'm afraid I don't know why it is so,
if for the DDR_REVERSED_P continue it matters whether step is positive or
negative, or if that is irrelevant and all the write after write DDR_REVERSED_P
ddrs need to be checked normally (abs (dist) >= *max_vf), or if say only write
after read should be treated as the code treats it right now and even read
after write is problematic. The DDR_REVERSED_P stuff has been added in 2007
for PR32377, see e.g. http://gcc.gnu.org/ml/gcc-patches/2007-09/msg01067.html
Richard, any ideas?
More information about the Gcc-bugs
mailing list