I'm trying to get:

void foo() {
  int rowfraclo[2];
  rowfraclo[1] = 42;
  asm ("movd mm6, %a0" : : "p" (rowfraclo+1));
}

to generate:

        movd mm6, -4(%ebp)

at -O0.  Currently we generate:

  leal    -8(%ebp), %eax
  addl    $4, %eax
  movd mm6, (%eax)

With the below patch (still running the testsuite) I can get the compiler to generate that code. So, the question is how better can I do this?

Doing diffs in .:
--- ./expr.c.~1~        2006-01-27 14:56:09.000000000 -0800
+++ ./expr.c    2006-01-27 15:46:14.000000000 -0800
@@ -6358,9 +6358,11 @@ expand_expr_addr_expr_1 (tree exp, rtx t
              TREE_USED (exp) = 1;
            }
 
+#if 0
          if (modifier != EXPAND_INITIALIZER
              && modifier != EXPAND_CONST_ADDRESS)
            result = force_operand (result, target);
+#endif
          return result;
        }
 
--- ./function.c.~1~    2006-01-27 14:56:10.000000000 -0800
+++ ./function.c        2006-01-27 16:55:58.000000000 -0800
@@ -1455,6 +1455,18 @@ instantiate_virtual_regs_in_insn (rtx in
       x = recog_data.operand[i];
       switch (GET_CODE (x))
        {
+       case PLUS:
+         {
+           bool changed = false;
+           rtx addr = x;
+
+           for_each_rtx (&addr, instantiate_virtual_regs_in_rtx, &changed);
+           x = addr;
+           if (!changed)
+             continue;
+         }
+         break;
+
        case MEM:
          {
            rtx addr = XEXP (x, 0);
--- ./stmt.c.~1~        2006-01-27 14:56:16.000000000 -0800
+++ ./stmt.c    2006-01-27 15:56:26.000000000 -0800
@@ -867,7 +867,7 @@ expand_asm_operands (tree string, tree o
       type = TREE_TYPE (val);
       op = expand_expr (val, NULL_RTX, VOIDmode,
                        (allows_mem && !allows_reg
-                        ? EXPAND_MEMORY : EXPAND_NORMAL));
+                        ? EXPAND_MEMORY : EXPAND_SUM));
 
       /* Never pass a CONCAT to an ASM.  */
       if (GET_CODE (op) == CONCAT)
--- ./tree-gimple.c.~1~ 2006-01-27 14:56:06.000000000 -0800
+++ ./tree-gimple.c     2006-01-27 15:41:37.000000000 -0800
@@ -386,6 +386,9 @@ is_gimple_asm_val (tree t)
   if (TREE_CODE (t) == VAR_DECL && DECL_HARD_REGISTER (t))
     return true;
 
+  if (TREE_CODE (t) == PLUS_EXPR)
+    return true;
+
   return is_gimple_val (t);
 }
 
--------------

Reply via email to