fix constant folding from array CTORs
authorRichard Biener <rguenther@suse.de>
Thu, 9 Jul 2020 14:03:45 +0000 (16:03 +0200)
committerRichard Biener <rguenther@suse.de>
Fri, 10 Jul 2020 08:52:47 +0000 (10:52 +0200)
commit6e41c27bf549d957eb399d39d7d0c213f8733351
treebfd509af5c0156df1f28bc7c79a85132ac7e4802
parentba9c87d3255f168db811dd1fa69e5011d4e8194f
fix constant folding from array CTORs

This fixes the case where we try to fold a read from an
array initalizer and happen to cross the boundary of
multiple CTORs which isn't really supported.  For the
interesting cases like the testcase we actually handle
the folding by encoding the whole initializer.

2020-07-10  Richard Biener  <rguenther@suse.de>

PR tree-optimization/96133
* gimple-fold.c (fold_array_ctor_reference): Do not
recurse to folding a CTOR that does not fully cover the
asked for object.

* gcc.dg/torture/pr96133.c: New testcase.
gcc/gimple-fold.c
gcc/testsuite/gcc.dg/torture/pr96133.c [new file with mode: 0644]