[committed] bswap: Fix up a thinko with empty CONSTRUCTORs [PR98378]
Jakub Jelinek
jakub@redhat.com
Sat Dec 19 11:49:42 GMT 2020
Hi!
The code I've added recently in find_bswap_or_nop for VECTOR CONSTRUCTORs
is missing punt on an important case - namely empty CONSTRUCTORs, because in that
case the loop will not initialize *n and the code after the loop will then
use the uninitialized structure.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
committed to trunk.
No added testcase, as it exhibits only under valgrind, and on existing
testcases already.
2020-12-19 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/98378
* gimple-ssa-store-merging.c (find_bswap_or_nop): Punt if CONSTRUCTOR
has no elements.
--- gcc/gimple-ssa-store-merging.c.jj 2020-12-16 16:14:44.000000000 +0100
+++ gcc/gimple-ssa-store-merging.c 2020-12-18 23:12:59.671282002 +0100
@@ -873,6 +873,8 @@ find_bswap_or_nop (gimple *stmt, struct
if (sz != 16 && sz != 32 && sz != 64)
return NULL;
tree rhs = gimple_assign_rhs1 (stmt);
+ if (CONSTRUCTOR_NELTS (rhs) == 0)
+ return NULL;
tree eltype = TREE_TYPE (TREE_TYPE (rhs));
unsigned HOST_WIDE_INT eltsz
= int_size_in_bytes (eltype) * BITS_PER_UNIT;
Jakub
More information about the Gcc-patches
mailing list