cselim: Extend to check non-trapping for more references [PR89430]
authorHao Liu <hliu@os.amperecomputing.com>
Thu, 4 Jun 2020 08:28:37 +0000 (16:28 +0800)
committerHao Liu <hliu@os.amperecomputing.com>
Thu, 4 Jun 2020 09:04:09 +0000 (17:04 +0800)
commit54ecfb182bc32140722022c1d9818dee4bdc0e45
treed3850c29fff3700aba2e76d39f7cde8269047e9f
parent9b4e77e807e0099c3cfbf9c5b0c9e4154b9cb7a0
cselim: Extend to check non-trapping for more references [PR89430]

If there is a dominating store, a store to the same reference can not be
trapped.  But previously, it only supports such check on MEM_REFs.
So this patch extends it to support ARRAY_REFs and COMPONENT_REFs.

This patch also supports a special case: if there is a dominating load of
local variable without address escape, a store is not trapped, as local
stack is always writable.  Other loads are ignored for simplicity, as they
don't help to check if a store can be trapped (the memory may be read-only).

gcc/ChangeLog:

PR tree-optimization/89430
* tree-ssa-phiopt.c
(struct name_to_bb): Rename to ref_to_bb; add a new field exp;
remove ssa_name_ver, store, offset fields.
(struct ssa_names_hasher): Rename to refs_hasher; update functions.
(class nontrapping_dom_walker): Rename m_seen_ssa_names to m_seen_refs.
(nontrapping_dom_walker::add_or_mark_expr): Extend to support ARRAY_REFs
and COMPONENT_REFs.

gcc/testsuite/ChangeLog:

PR tree-optimization/89430
* gcc.dg/tree-ssa/pr89430-1.c: Remove xfail.
* gcc.dg/tree-ssa/pr89430-2.c: Remove xfail.
* gcc.dg/tree-ssa/pr89430-5.c: Remove xfail.
* gcc.dg/tree-ssa/pr89430-6.c: Remove xfail.
* gcc.dg/tree-ssa/pr89430-7-comp-ref.c: New test.
* gcc.dg/tree-ssa/pr89430-8-mem-ref-size.c: New test.
* gcc.dg/tree-ssa/ssa-pre-17.c: Add -fno-tree-cselim.
gcc/testsuite/gcc.dg/tree-ssa/pr89430-1.c
gcc/testsuite/gcc.dg/tree-ssa/pr89430-2.c
gcc/testsuite/gcc.dg/tree-ssa/pr89430-5.c
gcc/testsuite/gcc.dg/tree-ssa/pr89430-6.c
gcc/testsuite/gcc.dg/tree-ssa/pr89430-7-comp-ref.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/pr89430-8-mem-ref-size.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-17.c
gcc/tree-ssa-phiopt.c