[Oberon] Numeric CASE vs IF THEN ELSE Performance

John R. Strohm strohm at airmail.net
Sun Jun 10 19:17:41 CEST 2018


Andreas Pirklbauer said:
>  > If you compile this example on your implementation you
> > will be able to compare the code generated by each.
>  >
>  > If you look at the disassembler listing you will see that
>  > another CASE benefit (particularly useful in embedded
>  > systems) is that it uses significantly less code space
>  > than IF THEN ELSE as long as the selections are not
>  > too sparse. The total code generated for each version
>  > of the Soundex procedures is:
>  >
>  > IF-THEN-ELSE: 420 Bytes
>  > CASE: 240 Bytes
>
>Thx. That’s a helpful hint. Unfortunately my compiler (so far) only
>implements the "jump-table technique", so it does not fare well (in
>terms of code-space requirements) in cases where the sparseness
>of values in the case-label range is high, as outlined in [1].
>
>A proper comparison with your technique (using a modified BR
>instruction) would probably have to implement some of the other
>techniques suggested in [1], such as the search tree (effectively
>leading to a modern version of the paper in the process..).
>
>But your numbers are appealing indeed!
>
>-ap
>
>[1]  http://bernd-oppolzer.de/CaseStmts.pdf
>("The implementation of Case Statements in Pascal”)

As I understand it, the assumption in Oberon is that the programmer is part 
of the optimization process, in that he/she is expected to understand that 
sparseness in the CASE selection range will lead to large jump tables, which 
means that a sparse selection should be implemented with an IF-THEN-ELSE 
chain or even tree.


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus



More information about the Oberon mailing list