From: Randolph Chung <randolph@tausq.org>
To: parisc-linux@lists.parisc-linux.org
Subject: [parisc-linux] [gcc] should we teach gcc some new tricks?
Date: Thu, 24 Mar 2005 05:07:52 -0800 [thread overview]
Message-ID: <20050324130751.GK2485@tausq.org> (raw)
i've been looking at the extreme slowness of ext3 during some workloads.
came across this bit of code... not that it will make any difference,
but i wonder if we can make gcc a bit smarter?
given this bit of C code:
static inline int test_bit(int nr, const void * addr)
{
const unsigned char *ADDR = (const unsigned char *) addr;
return (ADDR[nr >> 3] >> (nr & 7)) & 1;
}
int proc1(int nr, int foo)
{
int ret;
char *buf1, *buf2;
if (test_bit(nr, buf1))
return 0;
if (foo)
ret = 1;
else
ret = !test_bit(nr, buf2);
return ret;
}
int proc2(int nr, int foo)
{
char *buf1, *buf2;
if (test_bit(nr, buf1))
return 0;
if (foo)
return 1;
else
return !test_bit(nr, buf2);
}
i would have expected gcc to produce the same code for proc1() and
proc2() (and in fact it does for 32-bit), but for 64-bit, proc2() is 2
insn shorter than proc1(). it seems like there are also some
opportunities for further optimizations if gcc can recognize that the
return value can only be 0 or 1, so the sign extension (?) extrd insn at
the end is not needed, and we can deposit the result directly into ret0
instead of r20. that should save us 2 insns.
.globl proc2
.type proc2, @function
proc2:
.PROC
.CALLINFO FRAME=0,NO_CALLS
.ENTRY
extrd,s %r26,63,32,%r26
extrw,u %r26,31,3,%r19
extrd,s %r25,63,32,%r25
mtsarcm %r19
extrd,s %r26,60,61,%r26
ldb %r26(%r20),%r19
extrw,s %r19,%sar,32,%r19
bb,*< %r19,63,.L10
ldi 0,%r28
ldi 1,%r28
cmpb,*<> %r0,%r25,.L10
ldi 0,%r20
ldb %r26(%r21),%r19
extrw,s %r19,%sar,32,%r19
extrd,s,*< %r19,63,1,%r0
ldi 1,%r20
extrd,s %r20,63,32,%r28
.L10:
bve,n (%r2)
.EXIT
.PROCEND
is this worth looking into? :)
randolph
--
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/
_______________________________________________
parisc-linux mailing list
parisc-linux@lists.parisc-linux.org
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux
next reply other threads:[~2005-03-24 13:07 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-24 13:07 Randolph Chung [this message]
2005-03-24 13:27 ` [parisc-linux] [gcc] should we teach gcc some new tricks? James A. Morrison
2005-03-24 16:19 ` John David Anglin
2005-03-24 16:59 ` Grant Grundler
2005-03-24 17:35 ` John David Anglin
2005-03-24 21:23 ` Grant Grundler
[not found] ` <200503242133.j2OLXl4R020985@hiauly1.hia.nrc.ca>
2005-03-24 22:33 ` Grant Grundler
2005-03-24 23:34 ` John David Anglin
2005-03-24 23:55 ` Randolph Chung
2005-03-24 23:59 ` Randolph Chung
2005-03-25 0:07 ` John David Anglin
2005-06-22 19:54 ` Joel Soete
2005-06-23 3:23 ` John David Anglin
2005-06-23 5:27 ` Grant Grundler
2005-06-23 6:10 ` Joel Soete
2005-03-24 19:37 ` James A. Morrison
2005-03-24 21:33 ` Grant Grundler
2005-03-26 8:55 ` Matthias Klose
2005-03-26 15:48 ` John David Anglin
2005-03-26 21:35 ` Grant Grundler
[not found] ` <16971.44399.144991.110733@gargle.gargle.HOWL>
2005-03-29 1:36 ` John David Anglin
2005-03-31 12:08 ` Michael S. Zick
2005-05-02 18:37 ` Joel Soete
2005-05-02 19:01 ` John David Anglin
2005-05-02 20:20 ` John David Anglin
2005-05-02 20:46 ` John David Anglin
2005-05-05 16:20 ` Joel Soete
2005-05-05 17:07 ` John David Anglin
2005-05-05 18:41 ` Joel Soete
[not found] <200505031334.j43DYRBT004104@hiauly1.hia.nrc.ca>
2005-05-03 17:58 ` Joel Soete
2005-05-03 19:00 ` John David Anglin
-- strict thread matches above, loose matches on Subject: below --
2005-06-23 7:19 Joel Soete
2005-06-23 13:09 ` John David Anglin
[not found] <42B91C1400000F85@mail-1-bnl.tiscali.it>
2005-06-25 6:46 ` John David Anglin
2005-06-25 8:29 ` Joel Soete
2005-07-01 13:43 ` Joel Soete
[not found] <42C81991.6030502@tiscali.be>
2005-07-03 18:47 ` John David Anglin
2005-07-04 14:51 ` Joel Soete
2005-07-05 14:59 ` Joel Soete
2005-07-07 1:27 ` John David Anglin
[not found] <200507051816.j65IGuIY028621@hiauly1.hia.nrc.ca>
2005-07-06 16:40 ` Joel Soete
2005-07-06 17:00 ` John David Anglin
[not found] <42B91C1400005075@mail-1-bnl.tiscali.it>
2005-07-09 15:42 ` Joel Soete
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=20050324130751.GK2485@tausq.org \
--to=randolph@tausq.org \
--cc=parisc-linux@lists.parisc-linux.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