This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Memory attribute on movstrsi for i386


It's always a bad idea for an MD file to emit an explicit MEM.  Here, it does
so in numerous places, but doesn't attempt to copy the attributes from the
original memory reference.  This is an efficienty issue when the alias set
isn't copied, but a correctness issue when RTX_UNCHANGING_P isn't clobbered,
and the latter is how I caught this.

This fix is somewhat of a kludge, since the patterns in question need to be
reworked to not have a MEM in the template, but there are quite a few pattern
involved and I'm not in a good enough debugging position on that target to
try such a massive change.  It should be done, though.

I committed this on the mainline and GCC 3.0 branch.
	
Sat Feb 24 20:25:29 2001  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>

	* config/i386/i386.c (ix86_set_move_mem_attrs): New function.
	(ix86_set_move_mem_attrs_1): Likewise.
	* config/i386/i386-protos.h (ix86_set_move_mem_attrs): New declaration.
	* config/i386/i386.md (movstrsi): Call it.

*** config/i386/i386.c	2001/02/24 02:34:05	1.222
--- config/i386/i386.c	2001/02/25 01:21:12
*************** static void ix86_emit_save_regs PARAMS((
*** 508,511 ****
--- 508,512 ----
  static void ix86_emit_restore_regs_using_mov PARAMS ((rtx, int));
  static void ix86_emit_epilogue_esp_adjustment PARAMS((int));
+ static void ix86_set_move_mem_attrs_1 PARAMS ((rtx, rtx, rtx, rtx, rtx));
  static void ix86_sched_reorder_pentium PARAMS((rtx *, rtx *));
  static void ix86_sched_reorder_ppro PARAMS((rtx *, rtx *));
*************** ix86_variable_issue (dump, sched_verbose
*** 7361,7364 ****
--- 7362,7411 ----
        }
        return --ix86_sched_data.ppro.issued_this_cycle;
+     }
+ }
+ 
+ /* Walk through INSNS and look for MEM references whose address is DSTREG or
+    SRCREG and set the memory attribute to those of DSTREF and SRCREF, as
+    appropriate.  */
+ 
+ void
+ ix86_set_move_mem_attrs (insns, dstref, srcref, dstreg, srcreg)
+      rtx insns;
+      rtx dstref, srcref, dstreg, srcreg;
+ {
+   rtx insn;
+ 
+   for (insn = insns; insn != 0 ; insn = NEXT_INSN (insn))
+     if (INSN_P (insn))
+       ix86_set_move_mem_attrs_1 (PATTERN (insn), dstref, srcref,
+ 				 dstreg, srcreg);
+ }
+ 
+ /* Subroutine of above to actually do the updating by recursively walking
+    the rtx.  */
+ 
+ static void
+ ix86_set_move_mem_attrs_1 (x, dstref, srcref, dstreg, srcreg)
+      rtx x;
+      rtx dstref, srcref, dstreg, srcreg;
+ {
+   enum rtx_code code = GET_CODE (x);
+   const char *format_ptr = GET_RTX_FORMAT (code);
+   int i, j;
+ 
+   if (code == MEM && XEXP (x, 0) == dstreg)
+     MEM_COPY_ATTRIBUTES (x, dstref);
+   else if (code == MEM && XEXP (x, 0) == srcreg)
+     MEM_COPY_ATTRIBUTES (x, srcref);
+ 
+   for (i = 0; i < GET_RTX_LENGTH (code); i++, format_ptr++)
+     {
+       if (*format_ptr == 'e')
+ 	ix86_set_move_mem_attrs_1 (XEXP (x, i), dstref, srcref,
+ 				   dstreg, srcreg);
+       else if (*format_ptr == 'E')
+ 	for (j = XVECLEN (x, i) - 1; j >= 0; j--)
+ 	  ix86_set_move_mem_attrs_1 (XVECEXP (x, i, j), dstref, srcreg,
+ 				     dstreg, srcreg);
      }
  }
*** config/i386/i386.md	2001/02/21 18:20:17	1.218
--- config/i386/i386.md	2001/02/25 01:21:23
***************
*** 11123,11127 ****
--- 11123,11130 ----
    int align = 0;
    int count = -1;
+   rtx insns;
  
+   start_sequence ();
+ 
    if (GET_CODE (operands[3]) == CONST_INT)
      align = INTVAL (operands[3]);
***************
*** 11289,11292 ****
--- 11292,11301 ----
  	}
      }
+ 
+   insns = get_insns ();
+   end_sequence ();
+ 
+   ix86_set_move_mem_attrs (insns, operands[0], operands[1], destreg, srcreg);
+   emit_insns (insns);
    DONE;
  }")


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]