sccvn: Handle non-byte aligned offset or size for memset (, 123, ) [PR93945]
authorJakub Jelinek <jakub@redhat.com>
Thu, 27 Feb 2020 09:12:52 +0000 (10:12 +0100)
committerJakub Jelinek <jakub@redhat.com>
Thu, 27 Feb 2020 09:12:52 +0000 (10:12 +0100)
commit5f9cd512c4278621435cce486dd00248ea2e821c
treedffe17c1326c8d4b3bea8892207a7e4e8eafa587
parent4fd9efc8877814e8cda506563d0282a267c562c8
sccvn: Handle non-byte aligned offset or size for memset (, 123, ) [PR93945]

The following is the last spot in vn_reference_lookup_3 that didn't allow
non-byte aligned offsets or sizes.  To be precise, it did allow size that
wasn't multiple of byte size and that caused a wrong-code issue on
big-endian, as the pr93945.c testcase shows, so for GCC 9 we should add
&& multiple_p (ref->size, BITS_PER_UNIT) check instead.
For the memset with SSA_NAME middle-argument, it still requires byte-aligned
offset, as we'd otherwise need to rotate the value at runtime.

2020-02-27  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/93582
PR tree-optimization/93945
* tree-ssa-sccvn.c (vn_reference_lookup_3): Handle memset with
non-zero INTEGER_CST second argument and ref->offset or ref->size
not a multiple of BITS_PER_UNIT.

* gcc.dg/tree-ssa/pr93582-9.c: New test.
* gcc.c-torture/execute/pr93945.c: New test.
gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr93945.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/pr93582-9.c [new file with mode: 0644]
gcc/tree-ssa-sccvn.c