[ARM] arm memcpy of aligned data
authorMike Stump <mikestump@comcast.net>
Mon, 17 Aug 2015 09:39:58 +0000 (09:39 +0000)
committerKyrylo Tkachov <ktkachov@gcc.gnu.org>
Mon, 17 Aug 2015 09:39:58 +0000 (09:39 +0000)
2015-08-17  Mike Stump  <mikestump@comcast.net>

* config/arm/arm.c (arm_block_move_unaligned_straight):
Emit normal move instead of unaligned load when source or destination
are appropriately aligned.

2015-08-17 Mike Stump  <mikestump@comcast.net>
           Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

* gcc.target/arm/memcpy-aligned-1.c: New test.

Co-Authored-By: Kyrylo Tkachov <kyrylo.tkachov@arm.com>
From-SVN: r226935

gcc/ChangeLog
gcc/config/arm/arm.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/arm/memcpy-aligned-1.c [new file with mode: 0644]

index 20b87d7cae96e3732cb27852128e8a34ea85a319..66bfd50a5468b62f709c216945000eeb07d0a9da 100644 (file)
@@ -1,3 +1,9 @@
+2015-08-17  Mike Stump  <mikestump@comcast.net>
+
+       * config/arm/arm.c (arm_block_move_unaligned_straight):
+       Emit normal move instead of unaligned load when source or destination
+       are appropriately aligned.
+
 2015-08-17  Richard Biener  <rguenther@suse.de>
            Naveen H.S  <Naveen.Hurugalawadi@caviumnetworks.com>
 
index 6e15bf272aa30208f21d44d8fd869f6ed07a03d1..8ded4946a6a3117e467f55d0f8b933d1b41e6d3e 100644 (file)
@@ -14412,7 +14412,10 @@ arm_block_move_unaligned_straight (rtx dstbase, rtx srcbase,
                                srcoffset + j * UNITS_PER_WORD - src_autoinc);
          mem = adjust_automodify_address (srcbase, SImode, addr,
                                           srcoffset + j * UNITS_PER_WORD);
-         emit_insn (gen_unaligned_loadsi (regs[j], mem));
+         if (src_aligned)
+           emit_move_insn (regs[j], mem);
+         else
+           emit_insn (gen_unaligned_loadsi (regs[j], mem));
        }
       srcoffset += words * UNITS_PER_WORD;
     }
@@ -14431,7 +14434,10 @@ arm_block_move_unaligned_straight (rtx dstbase, rtx srcbase,
                                dstoffset + j * UNITS_PER_WORD - dst_autoinc);
          mem = adjust_automodify_address (dstbase, SImode, addr,
                                           dstoffset + j * UNITS_PER_WORD);
-         emit_insn (gen_unaligned_storesi (mem, regs[j]));
+         if (dst_aligned)
+           emit_move_insn (mem, regs[j]);
+         else
+           emit_insn (gen_unaligned_storesi (mem, regs[j]));
        }
       dstoffset += words * UNITS_PER_WORD;
     }
index 28a231cc93540e015088f6fea50f35a01cab5552..394a42fafdd6c74337d28ba07003ee6e03b264f2 100644 (file)
@@ -1,3 +1,8 @@
+2015-08-17 Mike Stump  <mikestump@comcast.net>
+           Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
+
+       * gcc.target/arm/memcpy-aligned-1.c: New test.
+
 2015-08-16  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
 
        PR fortran/54656
diff --git a/gcc/testsuite/gcc.target/arm/memcpy-aligned-1.c b/gcc/testsuite/gcc.target/arm/memcpy-aligned-1.c
new file mode 100644 (file)
index 0000000..852b391
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -save-temps" } */
+
+void *memcpy (void *dest, const void *src, unsigned int n);
+
+void foo (char *dst, int i)
+{
+  memcpy (dst, &i, sizeof (i));
+}
+
+/* { dg-final { scan-assembler-times "str\t" 1 } } */
+/* { dg-final { scan-assembler-not "ldr\t" } } */