public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Richard Biener <rguenth@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-3248] middle-end/102129 - avoid TER of possibly trapping expressions
Date: Tue, 31 Aug 2021 09:38:24 +0000 (GMT)	[thread overview]
Message-ID: <20210831093824.C405C3858428@sourceware.org> (raw)

https://gcc.gnu.org/g:5e57bacf6f3599efea7634470db84121641c80b0

commit r12-3248-g5e57bacf6f3599efea7634470db84121641c80b0
Author: Richard Biener <rguenther@suse.de>
Date:   Tue Aug 31 09:13:20 2021 +0200

    middle-end/102129 - avoid TER of possibly trapping expressions
    
    The following avoids applying TER to possibly trapping expressions,
    preventing a trapping FP multiplication to be moved across a call
    that should not be executed.
    
    2021-08-31  Richard Biener  <rguenther@suse.de>
    
            PR middle-end/102129
            * tree-ssa-ter.c (find_replaceable_in_bb): Do not move
            possibly trapping expressions across calls.

Diff:
---
 gcc/tree-ssa-ter.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/gcc/tree-ssa-ter.c b/gcc/tree-ssa-ter.c
index 9eb8a11a7c0..3a057c2d25f 100644
--- a/gcc/tree-ssa-ter.c
+++ b/gcc/tree-ssa-ter.c
@@ -658,11 +658,15 @@ find_replaceable_in_bb (temp_expr_table *tab, basic_block bb)
 		 substitution list, or the def and use span a call such that
 		 we'll expand lifetimes across a call.  We also don't want to
 		 replace across these expressions that may call libcalls that
-		 clobber the register involved.  See PR 70184.  */
+		 clobber the register involved.  See PR 70184.  Neither
+		 do we want to move possibly trapping expressions across
+		 a call.  See PRs 102129 and 33593.  */
 	      if (gimple_has_volatile_ops (stmt) || same_root_var
 		  || (tab->call_cnt[ver] != cur_call_cnt
-		      && SINGLE_SSA_USE_OPERAND (SSA_NAME_DEF_STMT (use), SSA_OP_USE)
-			 == NULL_USE_OPERAND_P)
+		      && (SINGLE_SSA_USE_OPERAND (SSA_NAME_DEF_STMT (use),
+						  SSA_OP_USE)
+			    == NULL_USE_OPERAND_P
+			  || gimple_could_trap_p (SSA_NAME_DEF_STMT (use))))
 		  || tab->reg_vars_cnt[ver] != cur_reg_vars_cnt)
 		finished_with_expr (tab, ver, true);
 	      else


                 reply	other threads:[~2021-08-31  9:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210831093824.C405C3858428@sourceware.org \
    --to=rguenth@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).