🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #6610

Re: C compilers code generation

#6610
From: Rev. Ben A. Mesander
Date: Wed, 14 Nov 1990 05:34
66 lines
2422 bytes
>In article <1149@teslab.lab.OZ> andrew@teslab.lab.OZ (Andrew Phillips) writes:
>Over the years I have been intrigued by the code generated by
>different C compilers, and have been comparing Lattice C code with
>Aztec C.  From the first it always seemed that Lattice performed more
>optimizations but that Aztec did better simply because of better code
>generation.  Nowadays, they seem to be much closer, producing
>reasonable code with simple optimizations - but there is a lot of
>room for improvement.

Fascinating! Here's the output that the GCC port I'm working on produces
when the following C code is compiled:
main()
{
	register short i, k;
	int flags[8190];

	i=10;

	for (k = i+i; k <= 8190; k += i)
		flags[k] = 0;
}

#NO_APP
gcc_compiled.:
.text
	.even
.globl _main
_main:
	link a6,#-32760
	movel d2,sp@-
	moveq #10,d2
	moveq #20,d1
L5:
	movew d1,d0
	extl d0
	asll #2,d0
	lea a6@(0,d0:l),a0
	clrl a0@(-32760)
	addw d2,d1
	cmpw #8190,d1
	jle L5
	movel a6@(-32764),d2
	unlk a6
	rts

(Note that GCC uses a different assembler language format than Amigans
 usually use - however, it doesn't look _too_ different)

Before anyone gets excited, I can produce this sort of assembler code,
but I can't do anything with it yet. No, I'm not the author of the port
either, I just be an alpha-tester. Andrew, if you posted your entire
test program, I'll compile it for you so that results are directly
comparable to the Lattice or Aztec runs.

The following cretinous invocation of the GNU compiler was used (the
front-end doesn't work right yet...) Optimization is turned on.

/cpp test2.c -I include:/compiler_headers |
/cc1 -O -m68000 -msoft-fload -o test2.s

>Andrew Phillips (andrew@teslab.lab.oz.au) Phone +61 (Aust) 2 (Sydney) 289 8712

--
| ben@epmooch.UUCP   (Ben Mesander)       | "Cash is more important than |
| ben%servalan.UUCP@uokmax.ecn.uoknor.edu |  your mother." - Al Shugart, |
| !chinet!uokmax!servalan!epmooch!ben     |  CEO, Seagate Technologies   |
Technical Details
Message-ID: <ben.3412@epmooch.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!maverick.ksu.ksu.edu!unmvax!uokmax!servalan!epmooch!ben
References: <1149@teslab.lab.OZ>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!maverick.ksu.ksu.edu!unmvax!uokmax!servalan!epmooch!ben
From: ben@epmooch.UUCP (Rev. Ben A. Mesander)
Newsgroups: comp.sys.amiga.tech
Subject: Re: C compilers code generation
Message-ID: <ben.3412@epmooch.UUCP>
Date: 14 Nov 90 05:34:55 GMT
References: <1149@teslab.lab.OZ>
Lines: 66