http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59363

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ubizjak at gmail dot com

--- Comment #18 from H.J. Lu <hjl.tools at gmail dot com> ---
emit_memset generates

(insn 22 21 23 (set (mem/c:DI (reg:DI 85) [2 xecfg+32 S8 A128])
        (reg:DI 86)) z.i:12 -1
     (nil))

(insn 23 22 24 (parallel [
            (set (reg:DI 85)
                (plus:DI (reg:DI 85)
                    (const_int 8 [0x8])))
            (clobber (reg:CC 17 flags))
        ]) z.i:12 -1
     (nil))

(insn 24 23 25 (set (mem/c:DI (reg:DI 85) [2 xecfg+32 S8 A128])
        (reg:DI 86)) z.i:12 -1
     (nil))

Both addresses are pointing to xecfg+32.  gen_strset is expanded
to

  (set (mem:DI (match_operand:P 1 "register_operand" "0")) 
        (match_operand:DI 2 "register_operand" "a")) 
   (set (match_operand:P 0 "register_operand" "=D") 
        (plus:P (match_dup 1)
                (const_int 8)))

The destination register is incremented by 8 bytes. But we failed
to adjust its address. This patch:

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index aa221df..d395a99 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -22806,6 +22806,8 @@ emit_memset (rtx destmem, rtx destptr, rtx
promoted_val,
       if (piece_size <= GET_MODE_SIZE (word_mode))
     {
       emit_insn (gen_strset (destptr, dst, promoted_val));
+      dst = adjust_automodify_address_nv (dst, move_mode, destptr,
+                          piece_size);
       continue;
     }

changes the expansion to
(insn 22 21 23 (set (mem/c:DI (reg:DI 85) [2 xecfg+32 S8 A128])
        (reg:DI 86)) z.i:12 -1
     (nil))

(insn 23 22 24 (parallel [
            (set (reg:DI 85)
                (plus:DI (reg:DI 85)
                    (const_int 8 [0x8])))
            (clobber (reg:CC 17 flags))
        ]) z.i:12 -1
     (nil))

(insn 24 23 25 (set (mem/c:DI (reg:DI 85) [2 xecfg+40 S8 A64])
        (reg:DI 86)) z.i:12 -1
     (nil))

The second address is now xecfg+40 and the testcase works.

Reply via email to