🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by marvinw Wed, 09 Sep 1992 00:09
gcc-2.2.2 -O2 and non-optimal code
#1097
Author: 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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads