public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ian Lance Taylor <ian@airs.com>
To: "Matt Lee" <reachmatt.lee@gmail.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: Question about RTL for bitwise AND
Date: Tue, 18 Apr 2006 04:33:00 -0000	[thread overview]
Message-ID: <m3vet7lcz6.fsf@gossamer.airs.com> (raw)
In-Reply-To: <e94302560604141449r5d6dddber613363b8cb59b4a4@mail.gmail.com>

"Matt Lee" <reachmatt.lee@gmail.com> writes:

> Thanks again. I do agree that my costs calculation do not recurse into
> the sub-expressions, but I was just mimicing other ports in this
> regard (see rs6000 for instance) . They do not recurse into
> sub-expressions as well.

In the current mainline, the costs calculation in rs6000.c returns
false for AND and friends.  I haven't looked at the 3.4 sources (I
don't have them checked out).

> Also, I think I traced the problem to fold-const.c::fold_single_bit_test()
> 
>       /* If we have (A & C) != 0 or (A & C) == 0 and C is a power of
>          2, then fold the expression into shifts and logical operations.  */
>       tem = fold_single_bit_test (code, arg0, arg1, type);
>       if (tem)
>         return tem;

You're right, it looks like this is fixed in 4.1 and current mainline
with the patch in PR 14846.

> On a related note, it looks the if-conversion phase as well, chooses
> to use a bunch of shifts and other logical operations to convert a
> branch into linear code. This is fine, except that the resultant
> operations prove more expensive than a branch. I will take a closer
> look at the IFCVT_* macros and see if one of them is useful for
> catching these conditions.

If-conversion also uses costs to make these determinations.  The thing
to tweak is BRANCH_COST, and perhaps MAX_CONDITIONAL_EXECUTE.

Hope this helps.

Ian

      reply	other threads:[~2006-04-18  4:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-13 16:57 Matt Lee
2006-04-13 20:29 ` Ian Lance Taylor
2006-04-13 23:31   ` Matt Lee
2006-04-14  3:21     ` Ian Lance Taylor
2006-04-14 21:49       ` Matt Lee
2006-04-18  4:33         ` Ian Lance Taylor [this message]

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=m3vet7lcz6.fsf@gossamer.airs.com \
    --to=ian@airs.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=reachmatt.lee@gmail.com \
    /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).