public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Earnshaw <rearnsha@arm.com>
To: Chung-Lin Tang <cltang@codesourcery.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Canonicalize compares in combine [3/3] ARM backend part
Date: Wed, 15 Jun 2011 13:58:00 -0000	[thread overview]
Message-ID: <4DF8AFAC.4000806@arm.com> (raw)
In-Reply-To: <4DB19D15.9020509@codesourcery.com>

On 22/04/11 16:21, Chung-Lin Tang wrote:
> Hi Richard, this part's for you.
> 
> The ARM backend changes needed are very little after the prior patches,
> basically just a case in arm_canonicalize_comparison() to detect
> (zero_extend:SI (subreg:QI (reg:SI ...) 0)), and swap it into (and:SI
> (reg:SI) #255).
> 
> Had we not tried the combine modifications, this testcase probably could
> have also be solved by implementing another version of the corresponding
> *andsi3_compare0/_scratch patterns, with ZERO_EXTEND in the body, and
> "ands" in the output assembly. Maybe that's an acceptable solution too...
> 
> About the (ab)use of CANONICALIZE_COMPARISON, if it really should be
> another macro/hook, then this ARM patch will need updating, but the code
> should be similar.
> 
> Thanks,
> Chung-Lin
> 
> 
> 3-arm-parts.diff
> 
> 
> Index: config/arm/arm.c
> ===================================================================
> --- config/arm/arm.c	(revision 172860)
> +++ config/arm/arm.c	(working copy)
> @@ -3276,6 +3276,19 @@
>        return code;
>      }
>  
> +  /* If *op0 is (zero_extend:SI (subreg:QI (reg:SI) 0)) and comparing
> +     with const0_rtx, change it to (and:SI (reg:SI) (const_int 255)),
> +     to facilitate possible combining with a cmp into 'ands'.  */
> +  if (mode == SImode
> +      && GET_CODE (*op0) == ZERO_EXTEND
> +      && GET_CODE (XEXP (*op0, 0)) == SUBREG
> +      && GET_MODE (XEXP (*op0, 0)) == QImode
> +      && GET_MODE (SUBREG_REG (XEXP (*op0, 0))) == SImode
> +      && SUBREG_BYTE (XEXP (*op0, 0)) == 0
> +      && *op1 == const0_rtx)
> +    *op0 = gen_rtx_AND (SImode, SUBREG_REG (XEXP (*op0, 0)),
> +			GEN_INT (255));
> +

This is wrong for big-endian code.  You should use subreg_lowpart_p to
check the subreg expression (after you've checked that you do have a
subreg, of course).

R.

  parent reply	other threads:[~2011-06-15 13:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-22 16:23 Chung-Lin Tang
2011-05-09 16:45 ` Ping " Chung-Lin Tang
2011-06-02  4:59   ` Chung-Lin Tang
2011-06-15 13:58 ` Richard Earnshaw [this message]
2011-07-18  8:32   ` Chung-Lin Tang
2011-07-18  9:37 Richard Earnshaw
2011-07-18 14:30 ` Chung-Lin Tang
2011-07-18 18:40   ` Richard Earnshaw

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DF8AFAC.4000806@arm.com \
    --to=rearnsha@arm.com \
    --cc=cltang@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).