[Oberon] FPGA - Oberon-7 - Loops

Chris Burrows chris at cfbsoftware.com
Tue Oct 23 12:44:39 CEST 2018

> -----Original Message-----
> From: Oberon [mailto:oberon-bounces at lists.inf.ethz.ch] On Behalf Of
> Tomas Kral
> Sent: Tuesday, 23 October 2018 7:02 PM
> To: Oberon at lists.inf.ethz.ch
> Subject: [Oberon] FPGA - Oberon-7 - Loops
> Hi,
> I am trying to optimise some code. I realise, the usual suspect for
> slow performance may be hidden somewhere inside inner loops.
> FOR a := 0 TO <expression> DO END;
> a := 0; WHILE a <= <expression> DO INC(a) END; a := 0; REPEAT INC(a)
> UNTIL a > <expression>;
> Expression is constant to the loop, how does compiler handle it?

The compiler does exactly what you have instructed it to do. i.e. it
recomputes the expression for every iteration of the loop. 

> When does it pay to compute expression outside the loop?

Most of the time if not always if you are sure the expression is not
affected by the loop and performance is more important to you than code
size. The more iterations there are in the loop and the more complex the
expression is the better the performance gain will be.

Chris Burrows
CFB Software

More information about the Oberon mailing list