[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference hydra::amiga_v1

Title:AMIGA NOTES
Notice:Join us in the *NEW* conference - HYDRA::AMIGA_V2
Moderator:HYDRA::MOORE
Created:Sat Apr 26 1986
Last Modified:Wed Feb 05 1992
Last Successful Update:Fri Jun 06 1997
Number of topics:5378
Total number of notes:38326

807.0. "Internals of various C generation" by WHYVAX::KRUGER () Wed Oct 14 1987 21:42

    The benchmark below shows the basic allocation strategy of two
    compilers: Green Hills (the one Sun markets) and Gnu. Richard Stallman
    wins, of course! Actually the lack of optimization in Green Hills
    surprised me.....
    
    From:	DECWRL::"friedman@sabbath.rutgers.edu" "Gadi   17-Sep-87 1315 EDT" 17-SEP-1987 13:22
To:	16bits::kruger
Subj:	C code

 
Dov,
   here is some sample output from the two compilers.
I had to input the a & b values because GnuCC would optimize
so much, it would calculate the final result since it knew the
values of a & b.  and the code would be 3 lines.  If you want
my to try your code, send my a copy.
 
                           Gadi
 
 
 
#include <stdio.h>
#include <math.h>
 
main()
{
  int a,b,c;
  c = 2;
  scanf ("%d%d",a,b);
  a=(a+b)*c/(a+b);
  c = (a-5)*(a+(a+(a+(a+(a-b)*b)*b)*b)*(a-b));
  c = c+2*c+(((a+b)+((a+b)/(a+a+a))*(a+a))*(b+a));
  printf("%d%d\n",c);
}
 
 
---------------------------------------------------------------
code generated by cc
 
LL0:
	.data
	.text
|#PROC# 04
	.globl	_main
_main:
|#PROLOGUE# 0
	link	a6,#0
	addl	#-LF75,sp
	moveml	#LS75,sp@
|#PROLOGUE# 1
	movl	#0x2,a6@(-0xc)
	.data1
L78:
	.ascii	"%d%d\0"
	.text
	movl	a6@(-0x8),sp@-
	movl	a6@(-0x4),sp@-
	pea	L78
	jbsr	_scanf
	lea	sp@(0xc),sp
	movl	a6@(-0x4),d0
	addl	a6@(-0x8),d0
	mulsl	a6@(-0xc),d0
	movl	a6@(-0x4),d1
	addl	a6@(-0x8),d1
	divsl	d1,d0
	movl	d0,a6@(-0x4)
	movl	a6@(-0x4),d0
	subl	a6@(-0x8),d0
	mulsl	a6@(-0x8),d0
	addl	a6@(-0x4),d0
	mulsl	a6@(-0x8),d0
	addl	a6@(-0x4),d0
	mulsl	a6@(-0x8),d0
	addl	a6@(-0x4),d0
	movl	a6@(-0x4),d1
	subl	a6@(-0x8),d1
	mulsl	d1,d0
	addl	a6@(-0x4),d0
	movl	a6@(-0x4),d1
	subql	#0x5,d1
	mulsl	d1,d0
	movl	d0,a6@(-0xc)
	movl	a6@(-0x4),d0
	addl	a6@(-0x8),d0
	movl	a6@(-0x4),d1
	addl	a6@(-0x4),d1
	addl	a6@(-0x4),d1
	divsl	d1,d0
	movl	a6@(-0x4),d1
	addl	a6@(-0x4),d1
	mulsl	d1,d0
	movl	a6@(-0x4),d1
	addl	a6@(-0x8),d1
	addl	d1,d0
	movl	a6@(-0x8),d1
	addl	a6@(-0x4),d1
	mulsl	d1,d0
	movl	a6@(-0xc),d1
	asll	#0x1,d1
	addl	a6@(-0xc),d1
	addl	d1,d0
	movl	d0,a6@(-0xc)
	.data1
L80:
	.ascii	"%d%d\12\0"
	.text
	movl	a6@(-0xc),sp@-
	pea	L80
	jbsr	_printf
	addqw	#0x8,sp
LE75:
	unlk	a6
	rts
	LF75 = 12
	LS75 = 0x0
	LFF75 = 12
	LSS75 = 0x0
	LP75 =	0x14
	.data
 
---------------------------------------------------------------
code generated by gcc
 
#NO_APP
.globl _main
.text
LC0:
	.ascii "%d%d\0"
.text
LC1:
	.ascii "%d%d\12\0"
.text
	.even
_main:
	link a6,#-12
	moveml #0x3800,sp@-
	moveq #2,d4
	movl d4,a6@(-12)
	movl a6@(-8),sp@-
	movl a6@(-4),sp@-
	pea LC0
	jbsr _scanf
	movl d0,d0
	movl a6@(-4),d0
	addl a6@(-8),d0
	mulsl a6@(-12),d0
	movl a6@(-4),d1
	addl a6@(-8),d1
	movl d0,d4
	divsl d1,d4
	movl d4,a6@(-4)
	movl a6@(-4),d0
	subql #5,d0
	movl a6@(-4),d1
	subl a6@(-8),d1
	mulsl a6@(-8),d1
	addl a6@(-4),d1
	mulsl a6@(-8),d1
	addl a6@(-4),d1
	mulsl a6@(-8),d1
	addl a6@(-4),d1
	movl a6@(-4),d2
	subl a6@(-8),d2
	mulsl d2,d1
	addl a6@(-4),d1
	movl d0,d4
	mulsl d1,d4
	movl d4,a6@(-12)
	movl a6@(-12),d0
	asll #1,d0
	addl a6@(-12),d0
	movl a6@(-4),d1
	addl a6@(-8),d1
	movl a6@(-4),d2
	addl a6@(-8),d2
	movl a6@(-4),d3
	addl a6@(-4),d3
	addl a6@(-4),d3
	divsl d3,d2
	movl a6@(-4),d3
	addl a6@(-4),d3
	mulsl d3,d2
	addl d2,d1
	movl a6@(-8),d2
	addl a6@(-4),d2
	mulsl d2,d1
	movl d0,d4
	addl d1,d4
	movl d4,a6@(-12)
	movl a6@(-12),sp@-
	pea LC1
	jbsr _printf
	movl d0,d2
L1:
	moveml a6@(-24),#0x1c
	unlk a6
	rts
 
 
------------------------------------------------------------------
code generated by cc -O
 
	.data
	.text
LL0:
|#PROC# 04
	.data1
L78:
	.ascii	"%d%d\0"
	.data1
L80:
	.ascii	"%d%d\12\0"
	LF75	=	12
	LS75	=	0
	LFF75	=	12
	LSS75	=	0
	LP75	=	20
	.data
	.text
	.globl	_main
_main:
|#PROLOGUE# 0
	link	a6,#-12
|#PROLOGUE# 1
	moveq	#2,d1
	movl	d1,a6@(-12)
	movl	a6@(-8),sp@-
	movl	a6@(-4),sp@-
	pea	L78
	jbsr	_scanf
	lea	sp@(12),sp
	movl	a6@(-4),d0
	addl	a6@(-8),d0
	mulsl	a6@(-12),d0
	movl	a6@(-4),d1
	addl	a6@(-8),d1
	divsl	d1,d0
	movl	d0,a6@(-4)
	subl	a6@(-8),d0
	mulsl	a6@(-8),d0
	addl	a6@(-4),d0
	mulsl	a6@(-8),d0
	addl	a6@(-4),d0
	mulsl	a6@(-8),d0
	addl	a6@(-4),d0
	movl	a6@(-4),d1
	subl	a6@(-8),d1
	mulsl	d1,d0
	addl	a6@(-4),d0
	movl	a6@(-4),d1
	subql	#5,d1
	mulsl	d1,d0
	movl	d0,a6@(-12)
	movl	a6@(-4),d0
	addl	a6@(-8),d0
	movl	a6@(-4),d1
	addl	d1,d1
	addl	a6@(-4),d1
	divsl	d1,d0
	movl	a6@(-4),d1
	addl	d1,d1
	mulsl	d1,d0
	movl	a6@(-4),d1
	addl	a6@(-8),d1
	addl	d1,d0
	movl	a6@(-8),d1
	addl	a6@(-4),d1
	mulsl	d1,d0
	movl	a6@(-12),d1
	asll	#1,d1
	addl	a6@(-12),d1
	addl	d1,d0
	movl	d0,a6@(-12)
	movl	d0,sp@-
	pea	L80
	jbsr	_printf
	addqw	#8,sp
	unlk	a6
	rts
 
----------------------------------------------------------------------
code generated by gcc -O
 
#NO_APP
.globl _main
.text
LC0:
	.ascii "%d%d\0"
.text
LC1:
	.ascii "%d%d\12\0"
.text
	.even
_main:
	link a6,#0
	moveml #0x3c00,sp@-
	moveq #2,d4
	movl d2,sp@-
	movl d3,sp@-
	pea LC0
	jbsr _scanf
	movl d3,d1
	addl d2,d1
	movl d1,d0
	mulsl d4,d0
	movl d0,d3
	divsl d1,d3
	movl d3,d2
	subql #5,d2
	movl d3,d1
	subl d2,d1
	movl d1,d0
	mulsl d2,d0
	addl d3,d0
	mulsl d2,d0
	addl d3,d0
	mulsl d2,d0
	addl d3,d0
	mulsl d1,d0
	addl d3,d0
	movl d2,d4
	mulsl d0,d4
	movl d4,a1
	lea a1@(d4:l:2),a0
	addl d3,d2
	movl d3,d1
	addl d3,d1
	movl d1,d0
	addl d3,d0
	movl d2,d5
	divsl d0,d5
	movl d5,d0
	mulsl d1,d0
	addl d0,d2
	movl d2,d0
	addl d3,d0
	mulsl d0,d2
	pea a0@(d2:l)
	pea LC1
	jbsr _printf
	moveml a6@(-16),#0x3c
	unlk a6
	rts
 
========================================================================
Received: from SABBATH.RUTGERS.EDU by decwrl.dec.com (5.54.4/4.7.34)
	id AA17272; Thu, 17 Sep 87 10:14:56 PDT
Received: by sabbath.rutgers.edu (5.54/1.14) 
	id AA04108; Thu, 17 Sep 87 13:15:24 EDT
Message-Id: <8709171715.AA04108@sabbath.rutgers.edu>
T.RTitleUserPersonal
Name
DateLines