public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] tree-optimization/105763 - avoid abnormals with ranger
Date: Mon, 30 May 2022 12:46:45 +0000 (UTC)	[thread overview]
Message-ID: <nycvar.YFH.7.77.849.2205301246110.32424@jbgna.fhfr.qr> (raw)


In unswitching we use ranger to simplify switch statements so we
have to avoid doing anything for abnormals.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

Richard.

2022-05-30  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/105763
	* tree-ssa-loop-unswitch.cc (find_unswitching_predicates_for_bb):
	Check gimple_range_ssa_p.

	* gcc.dg/pr105763.c: New testcase.
---
 gcc/testsuite/gcc.dg/pr105763.c | 21 +++++++++++++++++++++
 gcc/tree-ssa-loop-unswitch.cc   |  3 +--
 2 files changed, 22 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/pr105763.c

diff --git a/gcc/testsuite/gcc.dg/pr105763.c b/gcc/testsuite/gcc.dg/pr105763.c
new file mode 100644
index 00000000000..4c76b17e73d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr105763.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-O3" } */
+
+int rl2_decode_png_bit_depth;
+int *rl2_decode_png_p_data;
+void png_destroy_read_struct ();
+int __attribute__((returns_twice)) _setjmp ();
+void rl2_decode_png_row_pointers()
+{
+  unsigned sample_type = 0;
+  _setjmp();
+  switch (rl2_decode_png_bit_depth)
+  case 6:
+    sample_type = 7;
+  png_destroy_read_struct();
+  for (;;)
+    switch (sample_type)
+    case 3:
+    case 5:
+      *rl2_decode_png_p_data;
+}
diff --git a/gcc/tree-ssa-loop-unswitch.cc b/gcc/tree-ssa-loop-unswitch.cc
index f32f1a78f00..a55905c2c68 100644
--- a/gcc/tree-ssa-loop-unswitch.cc
+++ b/gcc/tree-ssa-loop-unswitch.cc
@@ -494,8 +494,7 @@ find_unswitching_predicates_for_bb (basic_block bb, class loop *loop,
     {
       unsigned nlabels = gimple_switch_num_labels (stmt);
       tree idx = gimple_switch_index (stmt);
-      if (TREE_CODE (idx) != SSA_NAME
-	  || nlabels < 1)
+      if (!gimple_range_ssa_p (idx) || nlabels < 1)
 	return;
       /* Index must be invariant.  */
       def = SSA_NAME_DEF_STMT (idx);
-- 
2.35.3


                 reply	other threads:[~2022-05-30 12:46 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=nycvar.YFH.7.77.849.2205301246110.32424@jbgna.fhfr.qr \
    --to=rguenther@suse.de \
    --cc=gcc-patches@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).