🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #1097

gcc-2.2.2 -O2 and non-optimal code

#1097
From: marvinw
Date: Wed, 09 Sep 1992 00:09
94 lines
2306 bytes
We are using gcc as a cross-compiler, the host is sparc and the target is mips.
The target assembler is a modified version of the OSF assembler, ours produces
coff instead of rose object format.  In the following test case gcc does not
produce very good code even with the optimizer turned on.  With proper code
scheduling and register allocation all of the nops could be eliminated.

		Marvin Wyckoff
		marvinw@orca.wv.tek.com
		503-685-2985

---------------------------------------------------------------------------
intrepid% uname -a
SunOS intrepid 4.1A.1 4.1.1 sun4

intrepid% cat config.status
#!/bin/sh
# GCC was configured as follows:
../configure --host=sparc --target=mips-mips-bsd

intrepid% ./gcc -B./ -S -O2 -msoft-float -g m.c
m.c:1137: warning: static declaration for `miRoundCap' follows non-static

---------------------- sched.c ----------------------------------
char arr[10];
char n;
main()
{
	n = arr[0];
	arr[0] = arr[3];
	arr[3] = n;
	n = arr[2];
	arr[2] = arr[1];
	arr[1] = n;
}
---------------------- sched.s ----------------------------------
	.file	1 "sched.c"

 # GNU C 2.2.2 [AL 1.1, MM 19] BSD Mips compiled by CC

 # Cc1 defaults:

 # Cc1 arguments (-G value = 8, Cpu = default, ISA = 1):
 # -mgas -mgpopt -quiet -dumpbase -O2 -o

gcc2_compiled.:
	.text
	.align	2
	.globl	main

	.comm	arr,16

	.comm	n,8

	.text

	.loc	1 4
	.ent	main
main:
	.frame	$sp,0,$31
	.mask	0x00000000,0
	.fmask	0x00000000,0
	la	$2,arr
	.set	noreorder
	lbu	$3,0($2)
	nop
	.set	reorder
	sb	$3,n
	.set	noreorder
	lbu	$3,arr+3
	nop
	.set	reorder
	sb	$3,0($2)
	.set	noreorder
	lbu	$3,n
	nop
	.set	reorder
	sb	$3,arr+3
	.set	noreorder
	lbu	$3,arr+2
	nop
	.set	reorder
	sb	$3,n
	.set	noreorder
	lbu	$3,arr+1
	nop
	.set	reorder
	sb	$3,arr+2
	.set	noreorder
	lbu	$3,n
	nop
	.set	reorder
	sb	$3,arr+1
	j	$31
	.end	main
Technical Details
Message-ID: <9209090018.AA04722@intrepid18.WV.TEK.COM_>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!intrepid18.wv.tek.COM!marvinw

Show Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!intrepid18.wv.tek.COM!marvinw
From: marvinw@intrepid18.wv.tek.COM
Subject: gcc-2.2.2 -O2 and non-optimal code
Message-ID: <9209090018.AA04722@intrepid18.WV.TEK.COM_>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Wed, 9 Sep 1992 00:09:40 GMT
Approved: bug-gcc@prep.ai.mit.edu
Lines: 95