re PR middle-end/64088 (ICE: in fold_abs_const, at fold-const.c:15550)
authorRichard Biener <rguenther@suse.de>
Thu, 27 Nov 2014 14:22:29 +0000 (14:22 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 27 Nov 2014 14:22:29 +0000 (14:22 +0000)
2014-11-27  Richard Biener  <rguenther@suse.de>

PR middle-end/64088
* fold-const.c (const_unop): Re-instantiate missing condition
before calling fold_abs_const.

* gcc.dg/torture/pr64088.c: New testcase.

PR tree-optimization/64088
* tree-ssa-tail-merge.c (update_debug_stmt): After resetting
the stmt break from the loop over use operands.

* gcc.dg/torture/pr64091.c: New testcase.

From-SVN: r218128

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr64088.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr64091.c [new file with mode: 0644]
gcc/tree-ssa-tail-merge.c

index 4abbd35c518d61bd235bb3f7651ef2c37f552122..dad0704a4e24f21a869d9eb54da549e5b87a3ccc 100644 (file)
@@ -1,3 +1,13 @@
+2014-11-27  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/64088
+       * fold-const.c (const_unop): Re-instantiate missing condition
+       before calling fold_abs_const.
+
+       PR tree-optimization/64088
+       * tree-ssa-tail-merge.c (update_debug_stmt): After resetting
+       the stmt break from the loop over use operands.
+
 2014-11-27  Ilya Tocar  <ilya.tocar@intel.com>
 
        * config/i386/cpuid.h (bit_MPX, bit_BNDREGS, bit_BNDCSR):
index 195d1e5408d372fb7ad229d9c449fe8193d91286..486ca19aa38403ca558f20d98d05742555f19a35 100644 (file)
@@ -1481,7 +1481,9 @@ const_unop (enum tree_code code, tree type, tree arg0)
       }
 
     case ABS_EXPR:
-      return fold_abs_const (arg0, type);
+      if (TREE_CODE (arg0) == INTEGER_CST || TREE_CODE (arg0) == REAL_CST)
+       return fold_abs_const (arg0, type);
+      break;
 
     case CONJ_EXPR:
       if (TREE_CODE (arg0) == COMPLEX_CST)
index 259283539004eb28efc06fe1050f71c9e5897d92..8c40dbd273ff4346dc522859d6497b1b2c33e1dd 100644 (file)
@@ -1,3 +1,11 @@
+2014-11-27  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/64088
+       * gcc.dg/torture/pr64088.c: New testcase.
+
+       PR tree-optimization/64088
+       * gcc.dg/torture/pr64091.c: New testcase.
+
 2014-11-27  Ilya Tocar  <ilya.tocar@intel.com>
 
        * g++.dg/ext/mv2.C: Add test for target ("avx512f").
diff --git a/gcc/testsuite/gcc.dg/torture/pr64088.c b/gcc/testsuite/gcc.dg/torture/pr64088.c
new file mode 100644 (file)
index 0000000..0ea5fab
--- /dev/null
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+extern int abs (int);
+extern void attenuate_curve(int*);
+int a;
+void
+setup_tone_curves_center_boost ()
+{
+  int b[0];
+  a = 0;
+  for (; a < 6; a++)
+    {
+      int c = abs (a);
+      b[a] = c;
+    }
+  attenuate_curve (b);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr64091.c b/gcc/testsuite/gcc.dg/torture/pr64091.c
new file mode 100644 (file)
index 0000000..0cd994a
--- /dev/null
@@ -0,0 +1,28 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-g" } */
+
+extern int foo(void);
+
+int main(void)
+{
+  int i, a, b;
+
+  if (foo())
+    return 0;
+
+  for (i = 0, a = 0, b = 0; i < 3; i++, a++)
+  {
+    if (foo())
+      break;
+
+    if (b += a)
+      a = 0;
+  }
+
+  if (!a)
+    return 2;
+
+  b += a;
+
+  return 0;
+}
index 230a4223dbd7bb0886ca6773e5a2d3889d66a9cc..07814c913e67fc91af1a9adde19fcfcc7fed4983 100644 (file)
@@ -1606,9 +1606,7 @@ update_debug_stmt (gimple stmt)
 {
   use_operand_p use_p;
   ssa_op_iter oi;
-  basic_block bbdef, bbuse;
-  gimple def_stmt;
-  tree name;
+  basic_block bbuse;
 
   if (!gimple_debug_bind_p (stmt))
     return;
@@ -1616,19 +1614,16 @@ update_debug_stmt (gimple stmt)
   bbuse = gimple_bb (stmt);
   FOR_EACH_PHI_OR_STMT_USE (use_p, stmt, oi, SSA_OP_USE)
     {
-      name = USE_FROM_PTR (use_p);
-      gcc_assert (TREE_CODE (name) == SSA_NAME);
-
-      def_stmt = SSA_NAME_DEF_STMT (name);
-      gcc_assert (def_stmt != NULL);
-
-      bbdef = gimple_bb (def_stmt);
+      tree name = USE_FROM_PTR (use_p);
+      gimple def_stmt = SSA_NAME_DEF_STMT (name);
+      basic_block bbdef = gimple_bb (def_stmt);
       if (bbdef == NULL || bbuse == bbdef
          || dominated_by_p (CDI_DOMINATORS, bbuse, bbdef))
        continue;
 
       gimple_debug_bind_reset_value (stmt);
       update_stmt (stmt);
+      break;
     }
 }