[Top][All Lists]

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

[avr-gcc-list] Small super-optimizer results

From: Paulo Marques
Subject: [avr-gcc-list] Small super-optimizer results
Date: Mon, 11 Jul 2011 19:02:06 +0100
User-agent: Thunderbird (X11/20090817)

Hi, all

Some time ago I toyed with trying to build a super-optimizer for the
avr. The project didn't went very far, but it produced a few small bits
of code that I think are worth sharing.

Basically I was trying to produce functions to multiply an 8 bit value
by 8 bit constants with a 16 bit result in avr families without a mul

Most of the solutions it found were obvious (x0, x2, x3, x4, etc.), but
a few were not so obvious:

multiply x129:
  MOV r2, r0
  ADD r0, r0
  ADC r1, r2
  ROR r1
  ROR r0

multiply x254
  NEG r0
  SBC r1, r0
  SBC r0, r1
  SBC r1, r2

multiply x255
  NEG r0
  SBC r1, r0

The superoptimizer was only allowed to use a subset of available
instructions so it is not guaranteed that these are optimal sequences.

The functions assume that the value to be multiplied is passed as r0 and
all other registers are zero. So for instance in the multiply x254, the
r2 reference could in fact be __zero_reg__ and the working registers
should not be r1:r0 at all (because "r0" is the "__zero_reg__").

I hope someone finds this to be useful anyway,

Paulo Marques
Software Development Department - Grupo PIE, S.A.
Phone: +351 252 290600, Fax: +351 252 290601
Web: www.grupopie.com

"Nostalgia isn't what it used to be."

reply via email to

[Prev in Thread] Current Thread [Next in Thread]