This is for my own benefit and note-taking, but I've just found another use for pure functions.

Though this is not exactly how the compiler source is structured, you get situations such as this.

RegName := debug_regname(taicpu(p).oper[0]^.reg); { 32-bit register name }
DebugMsg(SPeepholeOptimization + PreMessage + RegName + ',' + RegName + ' (removes REX prefix)', p);

When not in debug mode, DebugMsg is just a null procedure that does nothing (as is debug_regname, but let's ignore that for the moment).

One of the definitions of pure functions is that it has no side-effects, so if it can be shown that RegName is not used after its assignment, and a pure function is being used to assign said value, then the entire call can be safely removed, since it won't affect any other part of the program.

If anyone is able to notice potential areas where pure functions can optimise a program, sound off!

Gareth aka. Kit


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

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to