]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/60902 (ffmpeg built with gcc 4.9 RC produces incorrect flac...
authorJeff Law <law@redhat.com>
Wed, 23 Apr 2014 18:04:46 +0000 (12:04 -0600)
committerJeff Law <law@gcc.gnu.org>
Wed, 23 Apr 2014 18:04:46 +0000 (12:04 -0600)
PR tree-optimization/60902
* tree-ssa-threadedge.c
(record_temporary_equivalences_from_stmts_at_dest): Make sure to
invalidate outputs from statements that do not produce useful
outputs for threading.

PR tree-optimization/60902
* gcc.target/i386/pr60902.c: New test.

From-SVN: r209716

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr60902.c [new file with mode: 0644]
gcc/tree-ssa-threadedge.c

index 638c0da2d295289b1c6ee17b323afd2d5a788721..ddebba79f84ec13fca97d556081c694ef528c0f4 100644 (file)
@@ -1,3 +1,11 @@
+2014-04-23  Jeff Law  <law@redhat.com>
+
+       PR tree-optimization/60902
+       * tree-ssa-threadedge.c
+       (record_temporary_equivalences_from_stmts_at_dest): Make sure to
+       invalidate outputs from statements that do not produce useful
+       outputs for threading.
+
 2014-04-23 Venkataramanan Kumar  <venkataramanan.kumar@linaro.org>
 
        * config/aarch64/aarch64.md (stack_protect_set, stack_protect_test)
index 126ad08300b39c8f1f1a745f805df1ea1486edf7..62b07f4bc0dada72092267e97fa464dac5decf56 100644 (file)
@@ -1,3 +1,8 @@
+2014-04-23  Jeff Law  <law@redhat.com>
+
+       PR tree-optimization/60902
+       * gcc.target/i386/pr60902.c: New test.
+
 2014-04-23  Alex Velenko  <Alex.Velenko@arm.com>
 
        * gcc.target/aarch64/vdup_lane_1.c: New testcase.
diff --git a/gcc/testsuite/gcc.target/i386/pr60902.c b/gcc/testsuite/gcc.target/i386/pr60902.c
new file mode 100644 (file)
index 0000000..b81dcd7
--- /dev/null
@@ -0,0 +1,32 @@
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+extern void abort ();
+extern void exit (int);
+
+int x;
+
+foo()
+{
+  static int count;
+  count++;
+  if (count > 1)
+    abort ();
+}
+
+static inline int
+frob ()
+{
+  int a;
+  __asm__ ("mov %1, %0\n\t" : "=r" (a) : "m" (x));
+  x++;
+  return a;
+}
+
+int
+main ()
+{
+  int i;
+  for (i = 0; i < 10 && frob () == 0; i++)
+    foo();
+  exit (0);
+}
index c447b72c32f3dc731455b92eba6f404c039da375..8a0103b1637fae9bced979223972426e0c08bc8e 100644 (file)
@@ -387,7 +387,34 @@ record_temporary_equivalences_from_stmts_at_dest (edge e,
           && (gimple_code (stmt) != GIMPLE_CALL
               || gimple_call_lhs (stmt) == NULL_TREE
               || TREE_CODE (gimple_call_lhs (stmt)) != SSA_NAME))
-       continue;
+       {
+         /* STMT might still have DEFS and we need to invalidate any known
+            equivalences for them.
+
+            Consider if STMT is a GIMPLE_ASM with one or more outputs that
+            feeds a conditional inside a loop.  We might derive an equivalence
+            due to the conditional.  */
+         tree op;
+         ssa_op_iter iter;
+
+         if (backedge_seen)
+           FOR_EACH_SSA_TREE_OPERAND (op, stmt, iter, SSA_OP_ALL_DEFS)
+             {
+               /* This call only invalidates equivalences created by
+                  PHI nodes.  This is by design to keep the cost of
+                  of invalidation reasonable.  */
+               invalidate_equivalences (op, stack, src_map, dst_map);
+
+               /* However, conditionals can imply values for real
+                  operands as well.  And those won't be recorded in the
+                  maps.  In fact, those equivalences may be recorded totally
+                  outside the threading code.  We can just create a new
+                  temporary NULL equivalence here.  */
+               record_temporary_equivalence (op, NULL_TREE, stack);
+             }
+
+         continue;
+       }
 
       /* The result of __builtin_object_size depends on all the arguments
         of a phi node. Temporarily using only one edge produces invalid