Hi,
  With stores, we can get (const_int 0) as the src which has a mode of
VOIDmode but this can be a valid store for optimizing into a store
pair.  This patch changes checking for the src mode to checking dest
mode instead which does not have this issue.  I added a testcase which
shows the issue where store pair was not being created before but is
after.

OK?  Build and tested for aarch64-elf with no regressions.

Thanks,
Andrew Pinski

ChangeLog:
* config/aarch64/aarch64.c (fusion_load_store): Check dest mode
instead of src mode.


* gcc.target/aarch64/store-pair-1.c: New testcase.
Index: testsuite/gcc.target/aarch64/store-pair-1.c
===================================================================
--- testsuite/gcc.target/aarch64/store-pair-1.c (revision 0)
+++ testsuite/gcc.target/aarch64/store-pair-1.c (revision 0)
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+int f(int *a, int b)
+{
+  a[28] = 0;
+  a[29] = b;
+  a[31] = 0;
+}
+
+/* We should be able to produce store pair for the store of 28/29 store. */
+{ dg-final { scan-assembler "stp\tw\[0-9\]+, w\[0-9\]+" } }
Index: config/aarch64/aarch64.c
===================================================================
--- config/aarch64/aarch64.c    (revision 219508)
+++ config/aarch64/aarch64.c    (working copy)
@@ -10520,8 +10520,8 @@ fusion_load_store (rtx_insn *insn, rtx *
   src = SET_SRC (x);
   dest = SET_DEST (x);
 
-  if (GET_MODE (src) != SImode && GET_MODE (src) != DImode
-      && GET_MODE (src) != SFmode && GET_MODE (src) != DFmode)
+  if (GET_MODE (dest) != SImode && GET_MODE (dest) != DImode
+      && GET_MODE (dest) != SFmode && GET_MODE (dest) != DFmode)
     return SCHED_FUSION_NONE;
 
   if (GET_CODE (src) == SIGN_EXTEND)

Reply via email to