public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch ARM 1/6] Canonicalize neon_vaba and neon_vabal patterns.
@ 2012-07-30 11:45 Ramana Radhakrishnan
  2012-08-03 15:01 ` Richard Earnshaw
  0 siblings, 1 reply; 3+ messages in thread
From: Ramana Radhakrishnan @ 2012-07-30 11:45 UTC (permalink / raw)
  To: gcc-patches; +Cc: Patch Tracking, Richard Earnshaw

> Patch 1 fixes up the vaba and vabal patterns to use a canonical RTL
> form with the first operand to the plus being the more complex one.

This patch canonicalizes the instruction patterns for the
vaba and vabal intrinsics so that the more complex operand
to plus is the first operand. This prevents needless
splitting in combine.

For reference, this was found by the new test in gcc.target/neon/vaba*.c
and gcc.target/neon/vabal*.c from patch #4.


Ok ?

regards,
Ramana

2012-07-27  Ramana Radhakrishnan  <ramana.radhakrishnan@linaro.org>

	* config/arm/neon.md (neon_vaba<mode>): Change to define_expand.
	  (neon_vabal<mode>): Likewise.
	  (neon_vaba_internal<mode>): New internal pattern.
	  (neon_vabal_internal<mode>): New internal pattern.
---
 gcc/config/arm/neon.md |   61 ++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 46 insertions(+), 15 deletions(-)

diff --git a/gcc/config/arm/neon.md b/gcc/config/arm/neon.md
index 7142c98..1ffbb7d 100644
--- a/gcc/config/arm/neon.md
+++ b/gcc/config/arm/neon.md
@@ -2335,29 +2335,60 @@
   [(set_attr "neon_type" "neon_int_5")]
 )

-(define_insn "neon_vaba<mode>"
+(define_expand "neon_vaba<mode>"
+   [(match_operand:VDQIW 0 "s_register_operand" "")
+    (match_operand:VDQIW 1 "s_register_operand" "")
+    (match_operand:VDQIW 2 "s_register_operand" "")
+    (match_operand:VDQIW 3 "s_register_operand" "")
+    (match_operand:SI 4 "immediate_operand" "")]
+  "TARGET_NEON"
+  "{
+    emit_insn (gen_neon_vaba_internal<mode> (operands[0], operands[2],
+    	      				     operands[3], operands[4],
+    	      				     operands[1]));
+    DONE;
+   }"
+)
+
+(define_insn "neon_vaba_internal<mode>"
   [(set (match_operand:VDQIW 0 "s_register_operand" "=w")
-        (plus:VDQIW (match_operand:VDQIW 1 "s_register_operand" "0")
-                    (unspec:VDQIW [(match_operand:VDQIW 2
"s_register_operand" "w")
-		                   (match_operand:VDQIW 3 "s_register_operand" "w")
-                                   (match_operand:SI 4
"immediate_operand" "i")]
-		                  UNSPEC_VABD)))]
+        (plus:VDQIW (unspec:VDQIW
+		    [(match_operand:VDQIW 1 "s_register_operand" "w")
+		     (match_operand:VDQIW 2 "s_register_operand" "w")
+                     (match_operand:SI 3 "immediate_operand" "i")] UNSPEC_VABD)
+		    (match_operand:VDQIW 4 "s_register_operand" "0")))]
   "TARGET_NEON"
-  "vaba.%T4%#<V_sz_elem>\t%<V_reg>0, %<V_reg>2, %<V_reg>3"
+  "vaba.%T3%#<V_sz_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
   [(set (attr "neon_type")
      (if_then_else (match_test "<Is_d_reg>")
                    (const_string "neon_vaba") (const_string "neon_vaba_qqq")))]
 )

-(define_insn "neon_vabal<mode>"
+(define_expand "neon_vabal<mode>"
+  [(match_operand:<V_widen> 0 "s_register_operand" "")
+   (match_operand:<V_widen> 1 "s_register_operand" "")
+   (match_operand:VW	     2 "s_register_operand" "")
+   (match_operand:VW 	     3 "s_register_operand" "")
+   (match_operand:SI 	     4 "immediate_operand"  "")]
+  "TARGET_NEON"
+  "{
+    emit_insn (gen_neon_vabal_internal<mode> (operands[0], operands[2],
+    	      				      operands[3], operands[4],
+    	      				      operands[1]));
+    DONE;
+   }"
+)
+
+(define_insn "neon_vabal_internal<mode>"
   [(set (match_operand:<V_widen> 0 "s_register_operand" "=w")
-        (plus:<V_widen> (match_operand:<V_widen> 1 "s_register_operand" "0")
-                        (unspec:<V_widen> [(match_operand:VW 2
"s_register_operand" "w")
-                                           (match_operand:VW 3
"s_register_operand" "w")
-                                           (match_operand:SI 4
"immediate_operand" "i")]
-                          UNSPEC_VABDL)))]
-  "TARGET_NEON"
-  "vabal.%T4%#<V_sz_elem>\t%q0, %P2, %P3"
+        (plus:<V_widen> (unspec:<V_widen>
+			[(match_operand:VW 1 "s_register_operand" "w")
+                         (match_operand:VW 2 "s_register_operand" "w")
+                         (match_operand:SI 3 "immediate_operand" "i")]
+			 		     			UNSPEC_VABDL)
+			 (match_operand:<V_widen> 4 "s_register_operand" "0")))]
+  "TARGET_NEON"
+  "vabal.%T3%#<V_sz_elem>\t%q0, %P1, %P2"
   [(set_attr "neon_type" "neon_vaba")]
 )

-- 
1.7.4.1

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

* Re: [Patch ARM 1/6] Canonicalize neon_vaba and neon_vabal patterns.
  2012-07-30 11:45 [Patch ARM 1/6] Canonicalize neon_vaba and neon_vabal patterns Ramana Radhakrishnan
@ 2012-08-03 15:01 ` Richard Earnshaw
  2012-08-08 14:18   ` Ramana Radhakrishnan
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Earnshaw @ 2012-08-03 15:01 UTC (permalink / raw)
  To: Ramana Radhakrishnan; +Cc: gcc-patches, Patch Tracking

On 30/07/12 12:43, Ramana Radhakrishnan wrote:
>> Patch 1 fixes up the vaba and vabal patterns to use a canonical RTL
>> form with the first operand to the plus being the more complex one.
> 
> This patch canonicalizes the instruction patterns for the
> vaba and vabal intrinsics so that the more complex operand
> to plus is the first operand. This prevents needless
> splitting in combine.
> 
> For reference, this was found by the new test in gcc.target/neon/vaba*.c
> and gcc.target/neon/vabal*.c from patch #4.
> 
> 
> Ok ?
> 
> regards,
> Ramana
> 
> 2012-07-27  Ramana Radhakrishnan  <ramana.radhakrishnan@linaro.org>
> 
> 	* config/arm/neon.md (neon_vaba<mode>): Change to define_expand.
> 	  (neon_vabal<mode>): Likewise.
> 	  (neon_vaba_internal<mode>): New internal pattern.
> 	  (neon_vabal_internal<mode>): New internal pattern.

In principle, this is OK.  I think you could have achieved the same
effect more simply though by just re-ordering the RTL but keeping the
operand numbers the same.

R.

> ---
>  gcc/config/arm/neon.md |   61 ++++++++++++++++++++++++++++++++++++-----------
>  1 files changed, 46 insertions(+), 15 deletions(-)
> 
> diff --git a/gcc/config/arm/neon.md b/gcc/config/arm/neon.md
> index 7142c98..1ffbb7d 100644
> --- a/gcc/config/arm/neon.md
> +++ b/gcc/config/arm/neon.md
> @@ -2335,29 +2335,60 @@
>    [(set_attr "neon_type" "neon_int_5")]
>  )
> 
> -(define_insn "neon_vaba<mode>"
> +(define_expand "neon_vaba<mode>"
> +   [(match_operand:VDQIW 0 "s_register_operand" "")
> +    (match_operand:VDQIW 1 "s_register_operand" "")
> +    (match_operand:VDQIW 2 "s_register_operand" "")
> +    (match_operand:VDQIW 3 "s_register_operand" "")
> +    (match_operand:SI 4 "immediate_operand" "")]
> +  "TARGET_NEON"
> +  "{
> +    emit_insn (gen_neon_vaba_internal<mode> (operands[0], operands[2],
> +    	      				     operands[3], operands[4],
> +    	      				     operands[1]));
> +    DONE;
> +   }"
> +)
> +
> +(define_insn "neon_vaba_internal<mode>"
>    [(set (match_operand:VDQIW 0 "s_register_operand" "=w")
> -        (plus:VDQIW (match_operand:VDQIW 1 "s_register_operand" "0")
> -                    (unspec:VDQIW [(match_operand:VDQIW 2
> "s_register_operand" "w")
> -		                   (match_operand:VDQIW 3 "s_register_operand" "w")
> -                                   (match_operand:SI 4
> "immediate_operand" "i")]
> -		                  UNSPEC_VABD)))]
> +        (plus:VDQIW (unspec:VDQIW
> +		    [(match_operand:VDQIW 1 "s_register_operand" "w")
> +		     (match_operand:VDQIW 2 "s_register_operand" "w")
> +                     (match_operand:SI 3 "immediate_operand" "i")] UNSPEC_VABD)
> +		    (match_operand:VDQIW 4 "s_register_operand" "0")))]
>    "TARGET_NEON"
> -  "vaba.%T4%#<V_sz_elem>\t%<V_reg>0, %<V_reg>2, %<V_reg>3"
> +  "vaba.%T3%#<V_sz_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
>    [(set (attr "neon_type")
>       (if_then_else (match_test "<Is_d_reg>")
>                     (const_string "neon_vaba") (const_string "neon_vaba_qqq")))]
>  )
> 
> -(define_insn "neon_vabal<mode>"
> +(define_expand "neon_vabal<mode>"
> +  [(match_operand:<V_widen> 0 "s_register_operand" "")
> +   (match_operand:<V_widen> 1 "s_register_operand" "")
> +   (match_operand:VW	     2 "s_register_operand" "")
> +   (match_operand:VW 	     3 "s_register_operand" "")
> +   (match_operand:SI 	     4 "immediate_operand"  "")]
> +  "TARGET_NEON"
> +  "{
> +    emit_insn (gen_neon_vabal_internal<mode> (operands[0], operands[2],
> +    	      				      operands[3], operands[4],
> +    	      				      operands[1]));
> +    DONE;
> +   }"
> +)
> +
> +(define_insn "neon_vabal_internal<mode>"
>    [(set (match_operand:<V_widen> 0 "s_register_operand" "=w")
> -        (plus:<V_widen> (match_operand:<V_widen> 1 "s_register_operand" "0")
> -                        (unspec:<V_widen> [(match_operand:VW 2
> "s_register_operand" "w")
> -                                           (match_operand:VW 3
> "s_register_operand" "w")
> -                                           (match_operand:SI 4
> "immediate_operand" "i")]
> -                          UNSPEC_VABDL)))]
> -  "TARGET_NEON"
> -  "vabal.%T4%#<V_sz_elem>\t%q0, %P2, %P3"
> +        (plus:<V_widen> (unspec:<V_widen>
> +			[(match_operand:VW 1 "s_register_operand" "w")
> +                         (match_operand:VW 2 "s_register_operand" "w")
> +                         (match_operand:SI 3 "immediate_operand" "i")]
> +			 		     			UNSPEC_VABDL)
> +			 (match_operand:<V_widen> 4 "s_register_operand" "0")))]
> +  "TARGET_NEON"
> +  "vabal.%T3%#<V_sz_elem>\t%q0, %P1, %P2"
>    [(set_attr "neon_type" "neon_vaba")]
>  )
> 




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

* Re: [Patch ARM 1/6] Canonicalize neon_vaba and neon_vabal patterns.
  2012-08-03 15:01 ` Richard Earnshaw
@ 2012-08-08 14:18   ` Ramana Radhakrishnan
  0 siblings, 0 replies; 3+ messages in thread
From: Ramana Radhakrishnan @ 2012-08-08 14:18 UTC (permalink / raw)
  To: Richard Earnshaw; +Cc: gcc-patches, Patch Tracking

On 3 August 2012 16:00, Richard Earnshaw <rearnsha@arm.com> wrote:
> On 30/07/12 12:43, Ramana Radhakrishnan wrote:
>>> Patch 1 fixes up the vaba and vabal patterns to use a canonical RTL
>>> form with the first operand to the plus being the more complex one.
>>
>> This patch canonicalizes the instruction patterns for the
>> vaba and vabal intrinsics so that the more complex operand
>> to plus is the first operand. This prevents needless
>> splitting in combine.
>>
>> For reference, this was found by the new test in gcc.target/neon/vaba*.c
>> and gcc.target/neon/vabal*.c from patch #4.
>>
>>
>> Ok ?
>>
>> regards,
>> Ramana
>>
>> 2012-07-27  Ramana Radhakrishnan  <ramana.radhakrishnan@linaro.org>
>>
>>       * config/arm/neon.md (neon_vaba<mode>): Change to define_expand.
>>         (neon_vabal<mode>): Likewise.
>>         (neon_vaba_internal<mode>): New internal pattern.
>>         (neon_vabal_internal<mode>): New internal pattern.
>
> In principle, this is OK.  I think you could have achieved the same
> effect more simply though by just re-ordering the RTL but keeping the
> operand numbers the same.


Indeed - this look better ?


diff --git a/gcc/config/arm/neon.md b/gcc/config/arm/neon.md
index 7142c98..9e82564 100644
--- a/gcc/config/arm/neon.md
+++ b/gcc/config/arm/neon.md
@@ -2337,11 +2337,11 @@

 (define_insn "neon_vaba<mode>"
   [(set (match_operand:VDQIW 0 "s_register_operand" "=w")
-        (plus:VDQIW (match_operand:VDQIW 1 "s_register_operand" "0")
-                    (unspec:VDQIW [(match_operand:VDQIW 2
"s_register_operand" "w")
-                                  (match_operand:VDQIW 3
"s_register_operand" "w")
-                                   (match_operand:SI 4
"immediate_operand" "i")]
-                                 UNSPEC_VABD)))]
+        (plus:VDQIW (unspec:VDQIW
+                   [(match_operand:VDQIW 2 "s_register_operand" "w")
+                    (match_operand:VDQIW 3 "s_register_operand" "w")
+                     (match_operand:SI 4 "immediate_operand" "i")] UNSPEC_VABD)
+                   (match_operand:VDQIW 1 "s_register_operand" "0")))]
   "TARGET_NEON"
   "vaba.%T4%#<V_sz_elem>\t%<V_reg>0, %<V_reg>2, %<V_reg>3"
   [(set (attr "neon_type")
@@ -2351,13 +2351,13 @@

 (define_insn "neon_vabal<mode>"
   [(set (match_operand:<V_widen> 0 "s_register_operand" "=w")
-        (plus:<V_widen> (match_operand:<V_widen> 1 "s_register_operand" "0")
-                        (unspec:<V_widen> [(match_operand:VW 2
"s_register_operand" "w")
-                                           (match_operand:VW 3
"s_register_operand" "w")
-                                           (match_operand:SI 4
"immediate_operand" "i")]
-                          UNSPEC_VABDL)))]
+        (plus:<V_widen> (unspec:<V_widen>
+                       [(match_operand:VW 2 "s_register_operand" "w")
+                         (match_operand:VW 3 "s_register_operand" "w")
+                         (match_operand:SI 4 "immediate_operand"
"i")] UNSPEC_VABDL)
+                        (match_operand:<V_widen> 1 "s_register_operand" "0")))]
   "TARGET_NEON"
-  "vabal.%T4%#<V_sz_elem>\t%q0, %P2, %P3"
+  "vabal.%T4%#<V_sz_elem>\t%q0, %P1, %P2"
   [(set_attr "neon_type" "neon_vaba")]
 )


Ramana

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

end of thread, other threads:[~2012-08-08 14:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-30 11:45 [Patch ARM 1/6] Canonicalize neon_vaba and neon_vabal patterns Ramana Radhakrishnan
2012-08-03 15:01 ` Richard Earnshaw
2012-08-08 14:18   ` Ramana Radhakrishnan

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).