[Bug tree-optimization/50067] [4.7 Regression] Wrong code with -fpredictive-commoning
rguenth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Aug 19 11:55:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50067
--- Comment #8 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-08-19 11:51:07 UTC ---
We seem to be "safe" in more cases also because of weird stripping of
MEM_REFs in dr_analyze_indices.
if (TREE_CODE (ref) == MEM_REF
&& TREE_CODE (TREE_OPERAND (ref, 0)) == ADDR_EXPR
&& integer_zerop (TREE_OPERAND (ref, 1)))
ref = TREE_OPERAND (TREE_OPERAND (ref, 0), 0);
if you move that after stripping zero-offset ARRAY_REFs (to also
strip the mem-ref to the base object for (*&a)[i]) then we miscompile
the following testcase because we vectorize it
extern int memcmp(const void *, const void *, __SIZE_TYPE__);
extern void abort (void);
short a[32] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 };
short b[32] = { 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, };
int main()
{
int i;
for (i = 0; i < 32; ++i)
{
a[i] = (*((char(*)[32])&a[0]))[i+8];
}
if (memcmp (&a, &b, sizeof (a)) != 0)
abort ();
return 0;
}
when we leave two mem-refs around with
extern int memcmp(const void *, const void *, __SIZE_TYPE__);
extern void abort (void);
short a[32] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 };
short b[32] = { 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, };
int main()
{
int i;
for (i = 0; i < 32; ++i)
{
(*((unsigned short(*)[32])&a[0]))[i] = (*((char(*)[32])&a[0]))[i+8];
}
if (memcmp (&a, &b, sizeof (a)) != 0)
abort ();
return 0;
}
then the base-object comparison fails.
I wonder if the C access-as character lvalue covers doing so through
arbitrary dimensioned char arrays ...
I'll be "incrementally" trying to fix some oddities in dr_analyze_indices.
More information about the Gcc-bugs
mailing list