diff mbox

[ARM] Improve optimization to transform TST into LSLS

Message ID 19496.36022.174178.20635@pilspetsen.it.uu.se
State New
Headers show

Commit Message

Mikael Pettersson June 28, 2010, 11:51 a.m. UTC
Richard Earnshaw writes:
 > We recently added a pattern to the Thumb2 machine description to try to 
 > transform TST reg, # (1 << n) into LSLS reg, #(31-n).  Subsequent 
 > discussions on another patch led me to realize that this patch could 
 > probably be done a better way.  Experimentation bears this out: the 
 > following patch saves a further 0.1% when compiling CSiBE.
 > 
 > This version of the patch uses a peephole2 rather than a combine pattern 
 > to spot the optimization.  This has two benefits:
 > 1) The pattern will not be used if there's no scratch available 
 > (probably better, since tst only costs 2 bytes, but spilling can often 
 > cost significantly more).
 > 2) It gives rise to further optimization opportunities, such as 
 > if-conversion, that the other patch did not support.
 > 
 > Tested on arm-eabi and committed to trunk.
 > 
 > R.
 > 
 > 2010-06-24  Richard Earnshaw  <rearnsha@arm.com>
 > 
 > 	* thumb2.md (thumb2_tlobits_cbranch): Delete.
 > 	(peephole2 to convert zero_extract/compare of single bit to
 > 	 lshift/compare): New.

There was a followup bug fix (PR44227) to the patch that added
thumb2_tlobits_cbranch, which added a Thumb-2 'Pu' constraint
used only in thumb2_tlobits_cbranch.  After your patch above
this constraint is unused, so the following patch deletes it.

Tested by successfully building a cross to arm-linux-gnueabi.
(A reference to an undefined constraint causes a build error so
this shows there aren't any.)

Ok for trunk?  (I don't have svn write access.)

gcc/

2010-06-28  Mikael Pettersson  <mikpe@it.uu.se>

	* config/arm/constraints.md (Pu): Delete constraint.

Comments

Richard Earnshaw June 28, 2010, 9:26 p.m. UTC | #1
On 28/06/10 12:51, Mikael Pettersson wrote:
>
> Richard Earnshaw writes:
>   >  We recently added a pattern to the Thumb2 machine description to try to
>   >  transform TST reg, # (1<<  n) into LSLS reg, #(31-n).  Subsequent
>   >  discussions on another patch led me to realize that this patch could
>   >  probably be done a better way.  Experimentation bears this out: the
>   >  following patch saves a further 0.1% when compiling CSiBE.
>   >
>   >  This version of the patch uses a peephole2 rather than a combine pattern
>   >  to spot the optimization.  This has two benefits:
>   >  1) The pattern will not be used if there's no scratch available
>   >  (probably better, since tst only costs 2 bytes, but spilling can often
>   >  cost significantly more).
>   >  2) It gives rise to further optimization opportunities, such as
>   >  if-conversion, that the other patch did not support.
>   >
>   >  Tested on arm-eabi and committed to trunk.
>   >
>   >  R.
>   >
>   >  2010-06-24  Richard Earnshaw<rearnsha@arm.com>
>   >
>   >  	* thumb2.md (thumb2_tlobits_cbranch): Delete.
>   >  	(peephole2 to convert zero_extract/compare of single bit to
>   >  	lshift/compare): New.
>
> There was a followup bug fix (PR44227) to the patch that added
> thumb2_tlobits_cbranch, which added a Thumb-2 'Pu' constraint
> used only in thumb2_tlobits_cbranch.  After your patch above
> this constraint is unused, so the following patch deletes it.
>
> Tested by successfully building a cross to arm-linux-gnueabi.
> (A reference to an undefined constraint causes a build error so
> this shows there aren't any.)
>
> Ok for trunk?  (I don't have svn write access.)
>
> gcc/
>
> 2010-06-28  Mikael Pettersson<mikpe@it.uu.se>
>
> 	* config/arm/constraints.md (Pu): Delete constraint.
>
> --- gcc-4.6-20100626/gcc/config/arm/constraints.md.~1~	2010-06-20 01:00:31.000000000 +0200
> +++ gcc-4.6-20100626/gcc/config/arm/constraints.md	2010-06-28 12:58:01.000000000 +0200
> @@ -31,7 +31,7 @@
>   ;; The following multi-letter normal constraints have been used:
>   ;; in ARM/Thumb-2 state: Da, Db, Dc, Dn, Dl, DL, Dv, Dy
>   ;; in Thumb-1 state: Pa, Pb
> -;; in Thumb-2 state: Ps, Pt, Pu, Pv, Pw, Px
> +;; in Thumb-2 state: Ps, Pt, Pv, Pw, Px
>
>   ;; The following memory constraints have been used:
>   ;; in ARM/Thumb-2 state: Q, Ut, Uv, Uy, Un, Um, Us
> @@ -158,11 +158,6 @@
>     (and (match_code "const_int")
>          (match_test "TARGET_THUMB2&&  ival>= -7&&  ival<= 7")))
>
> -(define_constraint "Pu"
> -  "@internal In Thumb-2 state a constant in the range +1 to +8"
> -  (and (match_code "const_int")
> -       (match_test "TARGET_THUMB2&&  ival>= 1&&  ival<= 8")))
> -
>   (define_constraint "Pv"
>     "@internal In Thumb-2 state a constant in the range -255 to 0"
>     (and (match_code "const_int")
>
>

This is OK, but I seem remember you've posted a number of patches now. 
Do you (or your employer, if any) have a copyright assignment with the 
FSF?  If not, then I think it's time to get one sorted out.

R.
Paolo Bonzini June 29, 2010, 8:37 a.m. UTC | #2
On 06/28/2010 11:26 PM, Richard Earnshaw wrote:
> Do you (or your employer, if any) have a copyright assignment with the
> FSF?

I couldn't find any record for either Mikael or (for GCC) Uppsala 
University.

Paolo
Mikael Pettersson June 29, 2010, 11:47 a.m. UTC | #3
Richard Earnshaw writes:
 > This is OK, but I seem remember you've posted a number of patches now. 
 > Do you (or your employer, if any) have a copyright assignment with the 
 > FSF?  If not, then I think it's time to get one sorted out.

No I don't have one yet.  I'll see about getting that process started.
Paolo Bonzini June 29, 2010, 1:56 p.m. UTC | #4
On 06/29/2010 01:47 PM, Mikael Pettersson wrote:
> Richard Earnshaw writes:
>> This is OK, but I seem remember you've posted a number of patches now.
>> Do you (or your employer, if any) have a copyright assignment with the
>> FSF?  If not, then I think it's time to get one sorted out.
>
> No I don't have one yet.  I'll see about getting that process started.

I'll take care of it.

Paolo
diff mbox

Patch

--- gcc-4.6-20100626/gcc/config/arm/constraints.md.~1~	2010-06-20 01:00:31.000000000 +0200
+++ gcc-4.6-20100626/gcc/config/arm/constraints.md	2010-06-28 12:58:01.000000000 +0200
@@ -31,7 +31,7 @@ 
 ;; The following multi-letter normal constraints have been used:
 ;; in ARM/Thumb-2 state: Da, Db, Dc, Dn, Dl, DL, Dv, Dy
 ;; in Thumb-1 state: Pa, Pb
-;; in Thumb-2 state: Ps, Pt, Pu, Pv, Pw, Px
+;; in Thumb-2 state: Ps, Pt, Pv, Pw, Px
 
 ;; The following memory constraints have been used:
 ;; in ARM/Thumb-2 state: Q, Ut, Uv, Uy, Un, Um, Us
@@ -158,11 +158,6 @@ 
   (and (match_code "const_int")
        (match_test "TARGET_THUMB2 && ival >= -7 && ival <= 7")))
 
-(define_constraint "Pu"
-  "@internal In Thumb-2 state a constant in the range +1 to +8"
-  (and (match_code "const_int")
-       (match_test "TARGET_THUMB2 && ival >= 1 && ival <= 8")))
-
 (define_constraint "Pv"
   "@internal In Thumb-2 state a constant in the range -255 to 0"
   (and (match_code "const_int")