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/tree-dfa.c | |
parent | 1595a1cb7bfac8d5a6026d5d6f3a495be0391506 (diff) | |
download | gcc-2b42509f8b7bdf0a27a6687a941663380b485416.zip gcc-2b42509f8b7bdf0a27a6687a941663380b485416.tar.gz gcc-2b42509f8b7bdf0a27a6687a941663380b485416.tar.bz2 |
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/tree-dfa.c')
-rw-r--r-- | gcc/tree-dfa.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/gcc/tree-dfa.c b/gcc/tree-dfa.c index b6edc5c..3283d11 100644 --- a/gcc/tree-dfa.c +++ b/gcc/tree-dfa.c @@ -806,23 +806,25 @@ get_addr_base_and_unit_offset_1 (tree exp, poly_int64_pod *poffset, if (valueize && TREE_CODE (index) == SSA_NAME) index = (*valueize) (index); + if (!poly_int_tree_p (index)) + return NULL_TREE; + low_bound = array_ref_low_bound (exp); + if (valueize + && TREE_CODE (low_bound) == SSA_NAME) + low_bound = (*valueize) (low_bound); + if (!poly_int_tree_p (low_bound)) + return NULL_TREE; + unit_size = array_ref_element_size (exp); + if (TREE_CODE (unit_size) != INTEGER_CST) + return NULL_TREE; /* If the resulting bit-offset is constant, track it. */ - if (poly_int_tree_p (index) - && (low_bound = array_ref_low_bound (exp), - poly_int_tree_p (low_bound)) - && (unit_size = array_ref_element_size (exp), - TREE_CODE (unit_size) == INTEGER_CST)) - { - poly_offset_int woffset - = wi::sext (wi::to_poly_offset (index) - - wi::to_poly_offset (low_bound), - TYPE_PRECISION (TREE_TYPE (index))); - woffset *= wi::to_offset (unit_size); - byte_offset += woffset.force_shwi (); - } - else - return NULL_TREE; + poly_offset_int woffset + = wi::sext (wi::to_poly_offset (index) + - wi::to_poly_offset (low_bound), + TYPE_PRECISION (TREE_TYPE (index))); + woffset *= wi::to_offset (unit_size); + byte_offset += woffset.force_shwi (); } break; |