]> git.ipfire.org Git - thirdparty/gcc.git/commit
tree-optimization/93491 - avoid PRE of trapping calls across exits
authorRichard Biener <rguenther@suse.de>
Wed, 1 Sep 2021 09:49:39 +0000 (11:49 +0200)
committerRichard Biener <rguenther@suse.de>
Wed, 1 Sep 2021 10:56:13 +0000 (12:56 +0200)
commit13a43a90aea368a25da50762eba4873bafb4e448
treea6f2dbe2ca31cfcfb047ed7384745ed48eb519ff
parent153766ec8351d55cfe8bd6d69bdfc0c2cef71e56
tree-optimization/93491 - avoid PRE of trapping calls across exits

This makes us avoid PREing calls that could trap across other
calls that might not return.  The PR88087 testcase has exactly
such case so I've refactored the testcase to contain a valid PRE.
I've also adjusted PRE to not consider pure calls possibly
not returning in line with what we do elsewhere.

Note we don't have a good idea whether a function always returns
normally or whether its body is known to never trap.  That's
something IPA could compute.

2021-09-01  Richard Biener  <rguenther@suse.de>

PR tree-optimization/93491
* tree-ssa-pre.c (compute_avail): Set BB_MAY_NOTRETURN
after processing the stmt itself.  Do not consider
pure functions possibly not returning.  Properly avoid
adding possibly trapping calls to EXP_GEN when there's
a preceeding possibly not returning call.
* tree-ssa-sccvn.c (vn_reference_may_trap): Conservatively
not handle calls.

* gcc.dg/torture/pr93491.c: New testcase.
* gcc.dg/tree-ssa/pr88087.c: Change to valid PRE opportunity.
gcc/testsuite/gcc.dg/torture/pr93491.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/pr88087.c
gcc/tree-ssa-pre.c
gcc/tree-ssa-sccvn.c