]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/105763 - avoid abnormals with ranger queries
authorRichard Biener <rguenther@suse.de>
Mon, 30 May 2022 11:19:38 +0000 (13:19 +0200)
committerRichard Biener <rguenther@suse.de>
Wed, 1 Jun 2022 07:07:37 +0000 (09:07 +0200)
In unswitching we use ranger to simplify switch statements so we
have to avoid doing anything for abnormals.

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 [new file with mode: 0644]
gcc/tree-ssa-loop-unswitch.cc

diff --git a/gcc/testsuite/gcc.dg/pr105763.c b/gcc/testsuite/gcc.dg/pr105763.c
new file mode 100644 (file)
index 0000000..4c76b17
--- /dev/null
@@ -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;
+}
index f32f1a78f00f741f8c019d4be53f41e3916e359d..a55905c2c68a82dc9154bc19ec01016b7b0d9e6a 100644 (file)
@@ -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);