From patchwork Mon Jun 28 11:51:18 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [ARM] Improve optimization to transform TST into LSLS Date: Mon, 28 Jun 2010 01:51:18 -0000 From: Mikael Pettersson X-Patchwork-Id: 57132 Message-Id: <19496.36022.174178.20635@pilspetsen.it.uu.se> To: Richard Earnshaw Cc: GCC Patches 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 > > * 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 * 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")