aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-dse.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2020-08-26 08:44:59 +0200
committerRichard Biener <rguenther@suse.de>2020-08-27 08:07:34 +0200
commit989bc4ca2f2978baecff00f6d0532994b82897ef (patch)
tree818b5867caed131fd5c269b18d5a1948d6cbb459 /gcc/tree-ssa-dse.c
parent3ae0cd94abc15e33dc06ca7a5f76f14b1d74129f (diff)
downloadgcc-989bc4ca2f2978baecff00f6d0532994b82897ef.zip
gcc-989bc4ca2f2978baecff00f6d0532994b82897ef.tar.gz
gcc-989bc4ca2f2978baecff00f6d0532994b82897ef.tar.bz2
tree-optimization/96565 - improve DSE with paths ending in noreturn
This improves DSEs stmt walking by not considering a DEF without uses for further processing (and thus giving up when there's two paths to follow). 2020-08-26 Richard Biener <rguenther@suse.de> PR tree-optimization/96565 * tree-ssa-dse.c (dse_classify_store): Remove defs with no uses from further processing. * gcc.dg/tree-ssa/ssa-dse-40.c: New testcase. * gcc.dg/builtin-object-size-4.c: Adjust.
Diffstat (limited to 'gcc/tree-ssa-dse.c')
-rw-r--r--gcc/tree-ssa-dse.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/tree-ssa-dse.c b/gcc/tree-ssa-dse.c
index cc93f55..76eed06 100644
--- a/gcc/tree-ssa-dse.c
+++ b/gcc/tree-ssa-dse.c
@@ -898,6 +898,17 @@ dse_classify_store (ao_ref *ref, gimple *stmt,
*by_clobber_p = false;
defs.unordered_remove (i);
}
+ /* If the path ends here we do not need to process it further.
+ This for example happens with calls to noreturn functions. */
+ else if (gimple_code (def) != GIMPLE_PHI
+ && has_zero_uses (gimple_vdef (def)))
+ {
+ /* But if the store is to global memory it is definitely
+ not dead. */
+ if (ref_may_alias_global_p (ref))
+ return DSE_STORE_LIVE;
+ defs.unordered_remove (i);
+ }
/* In addition to kills we can remove defs whose only use
is another def in defs. That can only ever be PHIs of which
we track a single for simplicity reasons (we fail for multiple