]> gcc.gnu.org Git - gcc.git/commitdiff
re PR tree-optimization/15089 (local register variable with a specified register...
authorRichard Henderson <rth@redhat.com>
Wed, 29 Sep 2004 02:50:47 +0000 (19:50 -0700)
committerRichard Henderson <rth@gcc.gnu.org>
Wed, 29 Sep 2004 02:50:47 +0000 (19:50 -0700)
        PR 15089
        * tree-ssa-copy.c (may_propagate_copy_into_asm): New.
        * tree-flow.h (may_propagate_copy_into_asm): Declare.
        * tree-ssa-ccp.c (replace_uses_in): Use it.
        * tree-ssa-dom.c (cprop_operand): Likewise.

From-SVN: r88269

gcc/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/asm-2.c [new file with mode: 0644]
gcc/tree-flow.h
gcc/tree-ssa-ccp.c
gcc/tree-ssa-copy.c
gcc/tree-ssa-dom.c

index 2212c39b42cde508372a611c68bd6b32f7cb755f..8b803fa8596c2fe642c7c5f404e092af11da5b68 100644 (file)
@@ -1,3 +1,11 @@
+2004-09-28  Richard Henderson  <rth@redhat.com>
+
+       PR 15089
+       * tree-ssa-copy.c (may_propagate_copy_into_asm): New.
+       * tree-flow.h (may_propagate_copy_into_asm): Declare.
+       * tree-ssa-ccp.c (replace_uses_in): Use it.
+       * tree-ssa-dom.c (cprop_operand): Likewise.
+
 2004-09-28 Jeff Law  <law@redhat.com>
 
        * tree-ssa-threadupdate.c (create_block_for_threading):  Request
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/asm-2.c b/gcc/testsuite/gcc.dg/tree-ssa/asm-2.c
new file mode 100644 (file)
index 0000000..c07b0f1
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+#define REGISTER "0"
+
+void baz(void)
+{
+       register int xyzzy asm(REGISTER) = 1;
+       asm volatile ("" : : "r"(xyzzy));
+}
+
+/* { dg-final { scan-tree-dump-times "asm\[^\\r\\n\]*xyzzy" 1 "optimized" } } */
index 292879ac4306d6586902ac9107eafdfb259ef2f7..d62e6b7efa0882753e20ae1520b878175e08a001 100644 (file)
@@ -610,6 +610,7 @@ extern void propagate_value (use_operand_p, tree);
 extern void propagate_tree_value (tree *, tree);
 extern void replace_exp (use_operand_p, tree);
 extern bool may_propagate_copy (tree, tree);
+extern bool may_propagate_copy_into_asm (tree);
 
 /* Description of number of iterations of a loop.  All the expressions inside
    the structure can be evaluated at the end of the loop's preheader
index 144a8bfaeb0e1bd027e92114c2815476ea4ec361..d3ad9563a6b8894addc92a037a32eb175c815e15 100644 (file)
@@ -454,16 +454,21 @@ replace_uses_in (tree stmt, bool *replaced_addresses_p)
 
   FOR_EACH_SSA_USE_OPERAND (use, stmt, iter, SSA_OP_USE)
     {
-      value *val = get_value (USE_FROM_PTR (use));
+      tree tuse = USE_FROM_PTR (use);
+      value *val = get_value (tuse);
 
-      if (val->lattice_val == CONSTANT)
-       {
-         SET_USE (use, val->const_val);
-         replaced = true;
-         if (POINTER_TYPE_P (TREE_TYPE (USE_FROM_PTR (use))) 
-             && replaced_addresses_p)
-           *replaced_addresses_p = true;
-       }
+      if (val->lattice_val != CONSTANT)
+       continue;
+
+      if (TREE_CODE (stmt) == ASM_EXPR
+         && !may_propagate_copy_into_asm (tuse))
+       continue;
+
+      SET_USE (use, val->const_val);
+
+      replaced = true;
+      if (POINTER_TYPE_P (TREE_TYPE (tuse)) && replaced_addresses_p)
+       *replaced_addresses_p = true;
     }
 
   return replaced;
index 447f149ab4abf16bf3e21d03f6f5245159297bac..63a3c20417d7c0314562d2491b048fd837b26ec1 100644 (file)
@@ -156,6 +156,16 @@ may_propagate_copy (tree dest, tree orig)
   return true;
 }
 
+/* Similarly, but we know that we're propagating into an ASM_EXPR.  */
+
+bool
+may_propagate_copy_into_asm (tree dest)
+{
+  /* Hard register operands of asms are special.  Do not bypass.  */
+  return !(TREE_CODE (dest) == SSA_NAME
+          && DECL_HARD_REGISTER (SSA_NAME_VAR (dest)));
+}
+
 
 /* Given two SSA_NAMEs pointers ORIG and NEW such that we are copy
    propagating NEW into ORIG, consolidate aliasing information so that
index 1e6830bb54b1adce5f8bb58cd5ade0de9625da49..15bf695db4b276e9dff65439d5f7605ecfc7f68f 100644 (file)
@@ -2536,6 +2536,11 @@ cprop_operand (tree stmt, use_operand_p op_p)
              || TREE_CODE (val) != SSA_NAME))
        return false;
 
+      /* Do not replace hard register operands in asm statements.  */
+      if (TREE_CODE (stmt) == ASM_EXPR
+         && !may_propagate_copy_into_asm (op))
+       return false;
+
       /* Get the toplevel type of each operand.  */
       op_type = TREE_TYPE (op);
       val_type = TREE_TYPE (val);
This page took 0.08718 seconds and 5 git commands to generate.