This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/59354] Element swizzling produces invalid result with -O3 (tree-cunrolli pass problem?)


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59354

UroÅ Bizjak <ubizjak at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|middle-end                  |tree-optimization
            Summary|Unexpected result in g++    |Element swizzling produces
                   |when casting int to char    |invalid result with -O3
                   |from an stl vector to an    |(tree-cunrolli pass
                   |array                       |problem?)

--- Comment #3 from UroÅ Bizjak <ubizjak at gmail dot com> ---
It looks to me that cunrolli pass is messing up element swizzling code.

bisection-friendly C testcase:

--cut here--
void abort (void);

unsigned int a[256];
unsigned char b[256];

int main()
{
  int i, z, x, y;

  for(i = 0; i < 256; i++)
    a[i] = i % 5;

  for (z = 0; z < 16; z++)
    for (y = 0; y < 4; y++)
      for (x = 0; x < 4; x++)
        b[y*64 + z*4 + x] = a[z*16 + y*4 + x];

  if (b[4] != 1)
    abort ();

  return 0;
}
--cut here--

gcc-5 on x86_64-linux-gnu with the above testcase:

~/gcc-build/gcc/cc1 -O3 pr59354.c
Aborted
~/gcc-build/gcc/cc1 -O3 -fdisable-tree-cunrolli pr59354.c
OK

"Working" code produces following array:

Breakpoint 1, main () at pr59354.c:18
18        if (b[4] != 1)
(gdb) p b
$1 =
"\000\001\002\003\001\002\003\004\002\003\004\000\003\004\000\001\004\000\001\002\000\001\002\003\001\002\003\004\002\003\004\000\003\004\000\001\004\000\001\002\000\001\002\003\001\002\003\004\002\003\004\000\003\004\000\001\004\000\001\002\000\001\002\003\004\000\001\002\000\001\002\003\001\002\003\004\002\003\004\000\003\004\000\001\004\000\001\002\000\001\002\003\001\002\003\004\002\003\004\000\003\004\000\001\004\000\001\002\000\001\002\003\001\002\003\004\002\003\004\000\003\004\000\001\004\000\001\002\003\004\000\001\004\000\001\002\000\001\002\003\001\002\003\004\002\003\004\000\003\004\000\001\004\000\001\002\000\001\002\003\001\002\003\004\002\003\004\000\003\004\000\001\004\000\001\002\000\001\002\003\001\002\003\004\002\003\004\000\003\004\000\001\002\003\004\000\003\004\000\001"...
(gdb)

while "non-working" produces:

(gdb) p b
$1 =
"\000\001\002\003\004\000\001\002\003\004\000\001\002\003\004\000\001\002\003\004\000\001\002\003\004\000\001\002\003\004\000\001\002\003\004\000\001\002\003\004\000\001\002\003\004\000\001\002\003\004\000\001\002\003\004\000\001\002\003\004\000\001\002\003\004\000\001\002\000\001\002\003\001\002\003\004\002\003\004\000\003\004\000\001\004\000\001\002\000\001\002\003\001\002\003\004\002\003\004\000\003\004\000\001\004\000\001\002\000\001\002\003\001\002\003\004\002\003\004\000\003\004\000\001\004\000\001\002\003\004\000\001\004\000\001\002\000\001\002\003\001\002\003\004\002\003\004\000\003\004\000\001\004\000\001\002\000\001\002\003\001\002\003\004\002\003\004\000\003\004\000\001\004\000\001\002\000\001\002\003\001\002\003\004\002\003\004\000\003\004\000\001",
'\000' <repeats 63 times>
(gdb)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]