diff mbox

[ARM] Enable ldrd/strd peephole rules unconditionally

Message ID AM4PR0701MB2162B43415765B385CCE048DE4B90@AM4PR0701MB2162.eurprd07.prod.outlook.com
State New
Headers show

Commit Message

Bernd Edlinger Nov. 9, 2016, 12:58 p.m. UTC
Hi!


This patch enables the ldrd/strd peephole rules unconditionally.

It is meant to fix cases, where the patch to reduce the sha512
stack usage splits ldrd/strd instructions into separate ldr/str insns,
but is technically independent from the other patch:

See https://gcc.gnu.org/ml/gcc-patches/2016-11/msg00523.html

It was necessary to change check_effective_target_arm_prefer_ldrd_strd
to retain the true prefer_ldrd_strd tuning flag.


Bootstrapped and reg-tested on arm-linux-gnueabihf.
Is it OK for trunk?


Thanks
Bernd.

Comments

Kyrill Tkachov Nov. 17, 2016, 9:23 a.m. UTC | #1
On 09/11/16 12:58, Bernd Edlinger wrote:
> Hi!

>

>

> This patch enables the ldrd/strd peephole rules unconditionally.

>

> It is meant to fix cases, where the patch to reduce the sha512

> stack usage splits ldrd/strd instructions into separate ldr/str insns,

> but is technically independent from the other patch:

>

> See https://gcc.gnu.org/ml/gcc-patches/2016-11/msg00523.html

>

> It was necessary to change check_effective_target_arm_prefer_ldrd_strd

> to retain the true prefer_ldrd_strd tuning flag.

>

>

> Bootstrapped and reg-tested on arm-linux-gnueabihf.

> Is it OK for trunk?


This is ok.
Thanks,
Kyrill

> Thanks

> Bernd.
Christophe Lyon Nov. 18, 2016, 11:58 a.m. UTC | #2
On 17 November 2016 at 10:23, Kyrill Tkachov
<kyrylo.tkachov@foss.arm.com> wrote:
>

> On 09/11/16 12:58, Bernd Edlinger wrote:

>>

>> Hi!

>>

>>

>> This patch enables the ldrd/strd peephole rules unconditionally.

>>

>> It is meant to fix cases, where the patch to reduce the sha512

>> stack usage splits ldrd/strd instructions into separate ldr/str insns,

>> but is technically independent from the other patch:

>>

>> See https://gcc.gnu.org/ml/gcc-patches/2016-11/msg00523.html

>>

>> It was necessary to change check_effective_target_arm_prefer_ldrd_strd

>> to retain the true prefer_ldrd_strd tuning flag.

>>

>>

>> Bootstrapped and reg-tested on arm-linux-gnueabihf.

>> Is it OK for trunk?

>

>

> This is ok.

> Thanks,

> Kyrill

>


Hi Bernd,

Since you committed this patch (r242549), I'm seeing the new test
failing on some arm*-linux-gnueabihf configurations:

FAIL:  gcc.target/arm/pr53447-5.c scan-assembler-times ldrd 10
FAIL:  gcc.target/arm/pr53447-5.c scan-assembler-times strd 9

See http://people.linaro.org/~christophe.lyon/cross-validation/gcc/trunk/242549/report-build-info.html
for a map of failures.

Am I missing something?

Thanks,

Christophe


>> Thanks

>> Bernd.

>

>
diff mbox

Patch

2016-11-02  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	PR target/77308
	* config/arm/arm.md (*thumb2_ldrd, *thumb2_ldrd_base,
	*thumb2_ldrd_base_neg, *thumb2_strd, *thumb2_strd_base,
	*thumb2_strd_base_neg): Recognize insn regardless of
	current_tune->prefer_ldrd_strd.
	* config/arm/ldrdstrd.md: Enable all ldrd/strd peephole rules
	whenever possible.

testsuite:
2016-11-02  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	PR target/77308
	* gcc.target/arm/pr53447-5.c: New test.
	* lib/target-supports.exp
	(check_effective_target_arm_prefer_ldrd_strd): Adjust.

Index: gcc/config/arm/arm.md
===================================================================
--- gcc/config/arm/arm.md	(revision 241816)
+++ gcc/config/arm/arm.md	(working copy)
@@ -11636,7 +11636,6 @@ 
         (mem:SI (plus:SI (match_dup 1)
                          (match_operand:SI 4 "const_int_operand" ""))))]
   "TARGET_LDRD && TARGET_THUMB2 && reload_completed
-     && current_tune->prefer_ldrd_strd
      && ((INTVAL (operands[2]) + 4) == INTVAL (operands[4]))
      && (operands_ok_ldrd_strd (operands[0], operands[3],
                                   operands[1], INTVAL (operands[2]),
@@ -11653,7 +11652,6 @@ 
         (mem:SI (plus:SI (match_dup 1)
                          (const_int 4))))]
   "TARGET_LDRD && TARGET_THUMB2 && reload_completed
-     && current_tune->prefer_ldrd_strd
      && (operands_ok_ldrd_strd (operands[0], operands[2],
                                   operands[1], 0, false, true))"
   "ldrd%?\t%0, %2, [%1]"
@@ -11668,7 +11666,6 @@ 
    (set (match_operand:SI 2 "s_register_operand" "=r")
         (mem:SI (match_dup 1)))]
   "TARGET_LDRD && TARGET_THUMB2 && reload_completed
-     && current_tune->prefer_ldrd_strd
      && (operands_ok_ldrd_strd (operands[0], operands[2],
                                   operands[1], -4, false, true))"
   "ldrd%?\t%0, %2, [%1, #-4]"
@@ -11684,7 +11681,6 @@ 
                          (match_operand:SI 3 "const_int_operand" "")))
         (match_operand:SI 4 "s_register_operand" "r"))]
   "TARGET_LDRD && TARGET_THUMB2 && reload_completed
-     && current_tune->prefer_ldrd_strd
      && ((INTVAL (operands[1]) + 4) == INTVAL (operands[3]))
      && (operands_ok_ldrd_strd (operands[2], operands[4],
                                   operands[0], INTVAL (operands[1]),
@@ -11701,7 +11697,6 @@ 
                          (const_int 4)))
         (match_operand:SI 2 "s_register_operand" "r"))]
   "TARGET_LDRD && TARGET_THUMB2 && reload_completed
-     && current_tune->prefer_ldrd_strd
      && (operands_ok_ldrd_strd (operands[1], operands[2],
                                   operands[0], 0, false, false))"
   "strd%?\t%1, %2, [%0]"
@@ -11716,7 +11711,6 @@ 
    (set (mem:SI (match_dup 0))
         (match_operand:SI 2 "s_register_operand" "r"))]
   "TARGET_LDRD && TARGET_THUMB2 && reload_completed
-     && current_tune->prefer_ldrd_strd
      && (operands_ok_ldrd_strd (operands[1], operands[2],
                                   operands[0], -4, false, false))"
   "strd%?\t%1, %2, [%0, #-4]"
Index: gcc/config/arm/ldrdstrd.md
===================================================================
--- gcc/config/arm/ldrdstrd.md	(revision 241816)
+++ gcc/config/arm/ldrdstrd.md	(working copy)
@@ -29,9 +29,7 @@ 
         (match_operand:SI 2 "memory_operand" ""))
    (set (match_operand:SI 1 "arm_general_register_operand" "")
         (match_operand:SI 3 "memory_operand" ""))]
-  "TARGET_LDRD
-     && current_tune->prefer_ldrd_strd
-     && !optimize_function_for_size_p (cfun)"
+  "TARGET_LDRD"
   [(const_int 0)]
 {
   if (!gen_operands_ldrd_strd (operands, true, false, false))
@@ -63,9 +61,7 @@ 
 	(match_operand:SI 0 "arm_general_register_operand" ""))
    (set (match_operand:SI 3 "memory_operand" "")
 	(match_operand:SI 1 "arm_general_register_operand" ""))]
-  "TARGET_LDRD
-     && current_tune->prefer_ldrd_strd
-     && !optimize_function_for_size_p (cfun)"
+  "TARGET_LDRD"
   [(const_int 0)]
 {
   if (!gen_operands_ldrd_strd (operands, false, false, false))
@@ -102,9 +98,7 @@ 
         (match_operand:SI 5 "const_int_operand" ""))
    (set (match_operand:SI 3 "memory_operand" "")
         (match_dup 1))]
- "TARGET_LDRD
-  && current_tune->prefer_ldrd_strd
-  && !optimize_function_for_size_p (cfun)"
+  "TARGET_LDRD"
   [(const_int 0)]
 {
   if (!gen_operands_ldrd_strd (operands, false, true, false))
@@ -147,10 +141,8 @@ 
         (match_dup 0))
    (set (match_operand:SI 3 "memory_operand" "")
         (match_dup 1))]
- "TARGET_LDRD
-  && current_tune->prefer_ldrd_strd
-  && !optimize_function_for_size_p (cfun)"
-   [(const_int 0)]
+  "TARGET_LDRD"
+  [(const_int 0)]
 {
   if (!gen_operands_ldrd_strd (operands, false, true, false))
      FAIL;
@@ -197,8 +189,6 @@ 
 			   [(match_operand 6 "arm_general_register_operand" "")
 			    (match_operand 7 "arm_general_register_operand" "") ]))]
   "TARGET_LDRD && TARGET_ARM
-   && current_tune->prefer_ldrd_strd
-   && !optimize_function_for_size_p (cfun)
    && (  ((rtx_equal_p(operands[0], operands[6])) && (rtx_equal_p(operands[1], operands[7])))
         ||((rtx_equal_p(operands[0], operands[7])) && (rtx_equal_p(operands[1], operands[6]))))
    && (peep2_reg_dead_p (3, operands[0]) || rtx_equal_p (operands[0], operands[4]))
@@ -231,8 +221,6 @@ 
 				(match_operand 7 "arm_general_register_operand" "") ]))
        (clobber (reg:CC CC_REGNUM))])]
   "TARGET_LDRD && TARGET_ARM
-   && current_tune->prefer_ldrd_strd
-   && !optimize_function_for_size_p (cfun)
    && (  ((rtx_equal_p(operands[0], operands[6])) && (rtx_equal_p(operands[1], operands[7])))
        ||((rtx_equal_p(operands[0], operands[7])) && (rtx_equal_p(operands[1], operands[6]))))
    && (peep2_reg_dead_p (3, operands[0]) || rtx_equal_p (operands[0], operands[4]))
Index: gcc/testsuite/gcc.target/arm/pr53447-5.c
===================================================================
--- gcc/testsuite/gcc.target/arm/pr53447-5.c	(revision 0)
+++ gcc/testsuite/gcc.target/arm/pr53447-5.c	(working copy)
@@ -0,0 +1,19 @@ 
+/* { dg-do compile } */
+/* { dg-options "-Os -mthumb" } */
+/* { dg-require-effective-target arm_thumb2_ok } */
+
+void foo(long long* p)
+{
+  p[1] |= 0x100000001;
+  p[2] &= 0x100000001;
+  p[3] ^= 0x100000001;
+  p[4] += 0x100000001;
+  p[5] -= 0x100000001;
+  p[6] = ~p[6];
+  p[7] <<= 5;
+  p[8] >>= 5;
+  p[9] -= p[10];
+}
+
+/* { dg-final { scan-assembler-times "ldrd" 10 } } */
+/* { dg-final { scan-assembler-times "strd" 9 } } */
Index: gcc/testsuite/gb/target-supports.exp
--- gcc/testsuite/lib/target-supports.exp	(revision 241816)
+++ gcc/testsuite/lib/target-supports.exp	(working copy)
@@ -4317,7 +4317,7 @@ 
     }
 
     return [check_no_messages_and_pattern arm_prefer_ldrd_strd "strd\tr" assembly {
-        void foo (int *p) { p[0] = 1; p[1] = 0;}
+        void foo (void) { __asm__ ("" ::: "r4", "r5"); }
     }  "-O2 -mthumb" ]
 }