[Oberon] Constant folding, Re: Bit-fiddling: SETs and type casts in Oberon-07
Paul Reed
paulreed at paddedcell.com
Tue Aug 9 10:25:18 CEST 2022
Hi Jörg,
> ... CHR( ORD(ch) - ORD(“a”) + ORD(“A”) );
>
> ...the compiler folds these constants into one value
Should perhaps, but doesn't (the Oberon-07 compilers anyway): there is
some associative and even commutative constant folding which could be
done, but isn't currently. RISC ORTool gives:
PROCEDURE P;
VAR ch: CHAR;
BEGIN ch := CHR( ORD(ch) - ORD("a") + ORD("A") );
END P;
2 90E00004 LDR R0 SP 4
3 40090061 SUB R0 R0 97
4 40080041 ADD R0 R0 65
5 B0E00004 STR R0 SP 4
Cheers,
Paul
More information about the Oberon
mailing list