]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/59388 (ICE on valid code at -O1 and above on x86_64-linux...
authorJakub Jelinek <jakub@redhat.com>
Fri, 6 Dec 2013 21:00:49 +0000 (22:00 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 6 Dec 2013 21:00:49 +0000 (22:00 +0100)
PR tree-optimization/59388
* tree-ssa-reassoc.c (update_range_test): If op == range->exp,
gimplify tem after stmt rather than before it.

* gcc.c-torture/execute/pr59388.c: New test.

From-SVN: r205761

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr59388.c [new file with mode: 0644]
gcc/tree-ssa-reassoc.c

index e965f96f5cd20c9f66f9dc2a60a6c36d1f6520fc..cf50c90c4851588354ef25847b49be04193413cd 100644 (file)
@@ -1,5 +1,9 @@
 2013-12-06  Jakub Jelinek  <jakub@redhat.com>
 
+       PR tree-optimization/59388
+       * tree-ssa-reassoc.c (update_range_test): If op == range->exp,
+       gimplify tem after stmt rather than before it.
+
        * tree-data-ref.c (struct data_ref_loc_d): Replace pos field with ref.
        (get_references_in_stmt): Don't record operand addresses, but
        operands themselves.
index eaa7a54fc19803b8452b7a922289c316c8c0ead7..2d8d2eb60b41d46a245b80433c3b08d67871474b 100644 (file)
@@ -1,3 +1,8 @@
+2013-12-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/59388
+       * gcc.c-torture/execute/pr59388.c: New test.
+
 2013-12-06  Dominique d'Humieres  <dominiq@lps.ens.fr>
 
        PR testsuite/59043
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr59388.c b/gcc/testsuite/gcc.c-torture/execute/pr59388.c
new file mode 100644 (file)
index 0000000..de3648a
--- /dev/null
@@ -0,0 +1,11 @@
+/* PR tree-optimization/59388 */
+
+int a;
+struct S { unsigned int f:1; } b;
+
+int
+main ()
+{
+  a = (0 < b.f) | b.f;
+  return a;
+}
index 7145559d697b58f5806c7fcd737b666bea25d787..ba6c3c720c60c3a947ee96ea935025230ff79ebe 100644 (file)
@@ -2072,9 +2072,19 @@ update_range_test (struct range_entry *range, struct range_entry *otherrange,
 
   tem = fold_convert_loc (loc, optype, tem);
   gsi = gsi_for_stmt (stmt);
-  tem = force_gimple_operand_gsi (&gsi, tem, true, NULL_TREE, true,
-                                 GSI_SAME_STMT);
-  for (gsi_prev (&gsi); !gsi_end_p (gsi); gsi_prev (&gsi))
+  /* In rare cases range->exp can be equal to lhs of stmt.
+     In that case we have to insert after the stmt rather then before
+     it.  */
+  if (op == range->exp)
+    tem = force_gimple_operand_gsi (&gsi, tem, true, NULL_TREE, false,
+                                   GSI_CONTINUE_LINKING);
+  else
+    {
+      tem = force_gimple_operand_gsi (&gsi, tem, true, NULL_TREE, true,
+                                     GSI_SAME_STMT);
+      gsi_prev (&gsi);
+    }
+  for (; !gsi_end_p (gsi); gsi_prev (&gsi))
     if (gimple_uid (gsi_stmt (gsi)))
       break;
     else