diff options
author | Richard Biener <rguenther@suse.de> | 2020-05-08 10:24:37 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2020-05-08 13:34:03 +0200 |
commit | 2b42509f8b7bdf0a27a6687a941663380b485416 (patch) | |
tree | a4fe62b429dae15a1ff1c0725b1af8a28d48ac40 /gcc/testsuite | |
parent | 1595a1cb7bfac8d5a6026d5d6f3a495be0391506 (diff) |
Fix availability compute during VN DOM elimination
This fixes an issue with redundant store elimination in FRE/PRE
which, when invoked by the DOM elimination walk, ends up using
possibly stale availability data from the RPO walk. It also
fixes a missed optimization during valueization of addresses
by making sure to use get_addr_base_and_unit_offset_1 which can
valueize and adjusting that to also valueize ARRAY_REFs low-bound.
2020-05-08 Richard Biener <rguenther@suse.de>
* tree-ssa-sccvn.c (rpo_avail): Change type to
eliminate_dom_walker *.
(eliminate_with_rpo_vn): Adjust rpo_avail to make vn_valueize
use the DOM walker availability.
(vn_reference_fold_indirect): Use get_addr_base_and_unit_offset_1
with vn_valueize as valueization callback.
(vn_reference_maybe_forwprop_address): Likewise.
* tree-dfa.c (get_addr_base_and_unit_offset_1): Also valueize
array_ref_low_bound.
* gnat.dg/opt83.adb: New testcase.
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/opt83.adb | 33 |
2 files changed, 37 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b95696f0f19..adacf69b027 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2020-05-08 Richard Biener <rguenther@suse.de> + + * gnat.dg/opt83.adb: New testcase. + 2020-05-08 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/94786 diff --git a/gcc/testsuite/gnat.dg/opt83.adb b/gcc/testsuite/gnat.dg/opt83.adb new file mode 100644 index 00000000000..d71672f622c --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt83.adb @@ -0,0 +1,33 @@ +-- { dg-do compile } +-- { dg-options "-O2" } + +-- rpo fre3 used to loop indefinitely replacing _2 with _8 and back, +-- given MEM[(struct test__e &)_2][0]{lb: _7 sz: 16}._tag = A23s_29; +-- and an earlier _8 = &*_2[0]{lb: _7 sz: 16}. + +procedure Opt83 is + + type E is tagged record + I : Natural := 0; + end record; + + type A is array (Natural range <>) of aliased E; + + F : E; + + R : access A; + + procedure N is + begin + if R = null then + R := new A (0 .. 4); + end if; + end N; + +begin + + N; + + R (0) := F; + +end Opt83; |