Messages in this thread |  | | Date | Sun, 24 Jan 1999 10:45:43 +0100 | | From | ralf@uni-kobl ... | | Subject | Re: Structure vs purism ? |
| |
On Fri, Jan 22, 1999 at 12:53:59AM -0600, Thomas E. Dodd /CSDC wrote:
> Stefan Monnier wrote:
> > I think a lot of the goto's could be removed as soon as there is a > > decent possibility to tell the compiler to optimize for a certain > > case. This was discussed on the egcs lists some time ago IIRC. > > > > > compare against a final value because on most/many/(all?) processors > > > the flags change automatically when decrementing to zero or decrementing > > > to a negative number. > > > > MIPS and Alpha don't have `flags'. But I still agree that it's most of the > > time cheaper to check against 0 than against any other value. > > Then how do you get a beq or bne instruction? > There must be a status register that knows if > the last operation resulted in 0.
beq / bne have three operands, two registers that are being compared and one branch target. There also is a register that is hardwired to zero, so branches based on a comparison with zero are just as fast as with any other number. That's for both Alpha and MIPS.
MIPS FPUs are a bit different, they rely on a status register which has one status bit (MIPS I - III) or eight (MIPS IV instruction set). Compare instructions set or clear such a flag. The branch instructions then can branch depending on wether such a flag is set or cleared. MIPS IV allows to specify for compares and branches which of the flags should be used by an instruction. Dunno about the Alpha, the Alpha manuals is 3m away from here and I won't get up from my warm bed for just that :-)
Ralf
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
|  |