From: Michael Meissner <meissner@cygnus.com>
To: kiskra@ernie.icslab.agh.edu.pl
Cc: egcs@cygnus.com
Subject: Loop optimizer misses simple optimisation?
Date: Tue, 28 Apr 1998 19:49:00 -0000 [thread overview]
Message-ID: <199804282300.TAA31208@tiktok.cygnus.com> (raw)
In-Reply-To: <Pine.GSO.3.95.980428154521.25424H-100000@ernie>
Kamil Iskra writes:
|
| Hi,
|
| In a debate on comp.sys.amiga.programmer, a debate that I would sum up as
| "Does GCC really optimize so well as some people claim?" I came across a
| relatively simple source where GCC indeed does perform rather poorly:
It depends on the machine. I believe that GCC doesn't do as good of a
job with udivmod operations where it produces two outputs, as on
machines where it has a more normal division instruction (with
possibly a remainder instruction).
| #define N (1UL<<22)
| #define eN N
|
| unsigned char a[N + 1];
|
| main ()
| {
| unsigned int i;
|
| for (i = 2; i <= (1UL << 11); i++)
| if (a[i])
| {
| unsigned int j;
| for (j = 2; j <= eN / i; j++)
| a[i * j] = 0;
| }
| }
For example, the powerpc-eabi-gcc compiler generates:
.file "foo.c"
# rs6000/powerpc options: -msdata=data -G 8
# GNU C version egcs-2.91.24 19980418 (gcc2 ss-980401 experimental) (powerpc-eabi) compiled by GNU C version egcs-2.90.27 980315 (egcs-1.0.2 release).
# options passed: -O2 -fverbose-asm
# options enabled: -fdefer-pop -fomit-frame-pointer -fcse-follow-jumps
# -fcse-skip-blocks -fexpensive-optimizations -fthread-jumps
# -fstrength-reduce -fpeephole -fforce-mem -ffunction-cse -finline
# -fkeep-static-consts -fcaller-saves -fpcc-struct-return
# -frerun-cse-after-loop -frerun-loop-opt -fschedule-insns
# -fschedule-insns2 -fsched-interblock -fsched-spec -fsjlj-exceptions
# -fcommon -fverbose-asm -fgnu-linker -fregmove -fargument-alias -mpowerpc
# -mnew-mnemonics -meabi -mcall-sysv -msdata=data
gcc2_compiled.:
.section ".text"
.align 2
.globl main
.type main,@function
main:
stwu 1,-8(1)
mflr 0
stw 0,12(1)
bl __eabi
addis 9,0,a@ha
addi 9,9,a@l
li 8,2
lis 3,0x40
li 5,0
add 6,9,8
mr 4,3
li 7,4
.L5:
lbz 0,0(6)
addi 6,6,1
cmpwi 0,0,0
bc 12,2,.L4
divwu 0,3,8
li 10,2
cmplw 0,10,0
bc 12,1,.L4
divwu 0,4,8
add 11,7,9
.L10:
addi 10,10,1
cmplw 0,10,0
stb 5,0(11)
add 11,11,8
bc 4,1,.L10
.L4:
addi 8,8,1
cmplwi 0,8,2048
addi 7,7,2
bc 4,1,.L5
lwz 0,12(1)
mtlr 0
addi 1,1,8
blr
.Lfe1:
.size main,.Lfe1-main
.comm a,4194305,1
.ident "GCC: (GNU) egcs-2.91.24 19980418 (gcc2 ss-980401 experimental)"
--
Michael Meissner, Cygnus Solutions (Massachusetts office)
4th floor, 955 Massachusetts Avenue, Cambridge, MA 02139, USA
meissner@cygnus.com, 617-354-5416 (office), 617-354-7161 (fax)
next prev parent reply other threads:[~1998-04-28 19:49 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-04-28 7:23 Kamil Iskra
1998-04-28 19:14 ` Richard Henderson
1998-04-29 14:48 ` PÃ¥l-Kristian Engstad
1998-04-29 16:08 ` Richard Henderson
1998-04-28 19:49 ` Michael Meissner [this message]
1998-04-29 15:21 ` Jim Wilson
1998-05-02 6:13 ` Kamil Iskra
1998-05-03 14:15 ` Jeffrey A Law
1998-05-03 15:32 ` Jim Wilson
1998-05-03 20:10 ` Jeffrey A Law
1998-05-06 7:42 ` Was: " John Vickers
1998-05-06 9:19 ` Jeffrey A Law
1998-05-06 11:36 ` Joern Rennecke
1998-05-07 5:15 ` John Vickers
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=199804282300.TAA31208@tiktok.cygnus.com \
--to=meissner@cygnus.com \
--cc=egcs@cygnus.com \
--cc=kiskra@ernie.icslab.agh.edu.pl \
/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).