middle-end/100786 - constant folding from incompatible alias
authorRichard Biener <rguenther@suse.de>
Thu, 20 Jan 2022 13:25:51 +0000 (14:25 +0100)
committerRichard Biener <rguenther@suse.de>
Thu, 20 Jan 2022 15:50:34 +0000 (16:50 +0100)
commit5c12507f5d0bc080e4f346af99824e039236e61c
tree61747d6d9370e7df95b11c42e3bfd3e423594302
parent62eb400b51f8a552320a250b3ac0b5d2ebd8927f
middle-end/100786 - constant folding from incompatible alias

The following avoids us ICEing doing constant folding from variables
with aliases of different types.  The issue appears both in
folding and CCP and FRE can do more fancy stuff to still constant
fold cases where the load is smaller than the initializer so
defer it to there.

2022-01-20  Richard Biener  <rguenther@suse.de>

PR middle-end/100786
* gimple-fold.cc (get_symbol_constant_value): Only return
values of compatible type to the symbol.

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