]> gcc.gnu.org Git - gcc.git/commit
tree-optimization/113831 - wrong VN with structurally identical ref
authorRichard Biener <rguenther@suse.de>
Fri, 9 Feb 2024 09:16:38 +0000 (10:16 +0100)
committerRichard Biener <rguenther@suse.de>
Mon, 12 Feb 2024 13:36:25 +0000 (14:36 +0100)
commit938a419182f8c43bd1212ffb98f8aa6077cf8326
tree6a8c53f2ec8bf6a093cd3d897e6b57e0890d03b9
parent0437cbdccb91da6a8c25b2c29e9f19a9585309fc
tree-optimization/113831 - wrong VN with structurally identical ref

When we use get_ref_base_and_extent during VN and that ends up using
global ranges to restrict the range of a ref we have to take care
of not using the same expression in the hashtable as for a ref that
could not use that global range.  The following attempts to ensure
this by applying similar logic as get_ref_base_and_extent to
copy_reference_ops_from_ref so they behave consistent.

PR tree-optimization/113831
PR tree-optimization/108355
* tree-ssa-sccvn.cc (copy_reference_ops_from_ref): When
we see variable array indices and get_ref_base_and_extent
can resolve those to constants fix up the ops to constants
as well.
(ao_ref_init_from_vn_reference): Use 'off' member for
ARRAY_REF and ARRAY_RANGE_REF instead of recomputing it.
(valueize_refs_1): Also fixup 'off' of ARRAY_RANGE_REF.

* gcc.dg/torture/pr113831.c: New testcase.
* gcc.dg/tree-ssa/ssa-fre-104.c: Likewise.
gcc/testsuite/gcc.dg/torture/pr113831.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-104.c [new file with mode: 0644]
gcc/tree-ssa-sccvn.cc
This page took 0.069612 seconds and 5 git commands to generate.