public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR 91684
@ 2019-09-07  4:40 Bernd Edlinger
  2019-09-07 18:32 ` Bernd Edlinger
  0 siblings, 1 reply; 2+ messages in thread
From: Bernd Edlinger @ 2019-09-07  4:40 UTC (permalink / raw)
  To: gcc-patches, Richard Earnshaw, Kyrill Tkachov

[-- Attachment #1: Type: text/plain, Size: 299 bytes --]

Hi,

this fixes PR 91684, where an only 4-byte aligned memory is used with movdi,
which is formally invalid for strict alignment, but okay for prefer_ldrd_strd
targets.


Boot-strapped and reg-tested on arm-linux-gnueabihf.
Patch was approved via BZ.
Applied to trunk.


Thanks
Bernd.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch-pr91684.diff --]
[-- Type: text/x-patch; name="patch-pr91684.diff", Size: 1378 bytes --]

2019-09-06  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	* config/arm/arm.c (arm_block_set_aligned_non_vect): Use
	gen_unaligned_storedi for 4-byte aligned addresses.

testsuite:
2019-09-06  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	* gcc.target/arm/pr91684.c: New test.

Index: gcc/config/arm/arm.c
===================================================================
--- gcc/config/arm/arm.c	(revision 275409)
+++ gcc/config/arm/arm.c	(working copy)
@@ -30352,7 +30352,10 @@ arm_block_set_aligned_non_vect (rtx dstbase,
 	{
 	  addr = plus_constant (Pmode, dst, i);
 	  mem = adjust_automodify_address (dstbase, DImode, addr, i);
-	  emit_move_insn (mem, reg);
+	  if (MEM_ALIGN (mem) >= 2 * BITS_PER_WORD)
+	    emit_move_insn (mem, reg);
+	  else
+	    emit_insn (gen_unaligned_storedi (mem, reg));
 	}
     }
   else
Index: gcc/testsuite/gcc.target/arm/pr91684.c
===================================================================
--- gcc/testsuite/gcc.target/arm/pr91684.c	(revision 0)
+++ gcc/testsuite/gcc.target/arm/pr91684.c	(working copy)
@@ -0,0 +1,15 @@
+/* { dg-do compile }  */
+/* { dg-require-effective-target arm_ldrd_strd_ok } */
+/* { dg-options "-O3" } */
+
+typedef struct { int a, b, c; } S;
+
+void g (S *s);
+void bug1 (void)
+{
+  S s;
+  __builtin_memset (&s, 0, sizeof (S)); 
+  g (&s);
+}
+
+/* { dg-final { scan-assembler-times "strd" 1 } } */

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix PR 91684
  2019-09-07  4:40 [PATCH] Fix PR 91684 Bernd Edlinger
@ 2019-09-07 18:32 ` Bernd Edlinger
  0 siblings, 0 replies; 2+ messages in thread
From: Bernd Edlinger @ 2019-09-07 18:32 UTC (permalink / raw)
  To: gcc-patches, Richard Earnshaw, Kyrill Tkachov

I just noticed that the effective target is not right,
this needs to be prefer_ldrd_strd instead of arm_ldrd_strd_ok,
otherwise the ldrd is not generated.

Committed the following fix to the test case as obvious:

Index: gcc.target/arm/pr91684.c
===================================================================
--- gcc.target/arm/pr91684.c	(revision 275488)
+++ gcc.target/arm/pr91684.c	(revision 275489)
@@ -1,5 +1,5 @@
 /* { dg-do compile }  */
-/* { dg-require-effective-target arm_ldrd_strd_ok } */
+/* { dg-require-effective-target arm_prefer_ldrd_strd } */
 /* { dg-options "-O3" } */
 
 typedef struct { int a, b, c; } S;
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 275488)
+++ ChangeLog	(revision 275489)
@@ -1,3 +1,7 @@
+2019-09-07  Bernd Edlinger  <bernd.edlinger@hotmail.de>
+
+	* gcc.target/arm/pr91684.c: Use effective-target arm_prefer_ldrd_strd.
+
 2019-09-07  David Edelsohn  <dje.gcc@gmail.com>
 
 	* g++.dg/cpp2a/decomp2.C: Add TLS options.


On 9/7/19 6:39 AM, Bernd Edlinger wrote:
> Hi,
> 
> this fixes PR 91684, where an only 4-byte aligned memory is used with movdi,
> which is formally invalid for strict alignment, but okay for prefer_ldrd_strd
> targets.
> 
> 
> Boot-strapped and reg-tested on arm-linux-gnueabihf.
> Patch was approved via BZ.
> Applied to trunk.
> 
> 
> Thanks
> Bernd.
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-09-07 18:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-07  4:40 [PATCH] Fix PR 91684 Bernd Edlinger
2019-09-07 18:32 ` Bernd Edlinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).