[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MiNT] C bit



Hello,

here something about how the gcc 2.8.1 can optimize code. The original
code comes from older versions of MiNT (now this part is inlined in one of
the assembly modules):

C listing:

ulong	uptime = 0;
short	uptimetick = 200;

void calc_load_average()
{
	/* snip */

	uptime++;
	uptimetick += 200;
	if (uptime % 5) return;

	/* snip */
	...

Compiler output (-m68030 -O3):

_calc_load_average:
	...
	move.l	_uptime,a0
	lea	$0001(a0),a1
	move.l	a1,_uptime
	add.w	#$00c8,_uptimetick
	move.l	a0,d1
	addq.l	#$01,d1
	move.l	d1,d2
	mulu.l	#$cccccccd,d0-d2
	lsr.l	#$02,d0
	move.l	d0,a1
	lea	(a1,d0.l*4),a1
	move.l	a1,d0
	cmp.l	d1,d0
	bne.s	L459
	...

Comments?

--
Konrad M.Kokoszkiewicz
|mail: draco@atari.org                  |  Atari Falcon030 user   |
|http://www.obta.uw.edu.pl/~draco/      | Moderator gregis LATINE |
|http://draco.atari.org                 |       (loquentium)      |

** Ea natura multitudinis est,
** aut servit humiliter, aut superbe dominatur (Liv. XXIV,25)
*************************************************************
** U pospolstwa normalne jest, ze albo sluzy ono unizenie,
** albo bezczelnie sie panoszy.