Program Specialization
Program-Transformation.Org: The Program Transformation Wiki
ProgramSpecialization is used where a variable is known to often hold one particular
value. In this case, it is possible to generate code taking advantage of this
constant value, e.g. not passing a parameter, using immediate addressing modes,
eliminating the evaulation of an if-then-else statement and one of the clauses,
(either the
then or
else clauses) etc. For example, if you have code like
if (extendedBehavior)
doExtended();
else
x = 11;
and extendedBehavior is often false, then you can
specialize the above code
to just "x=11;". Usually, the assumption can't be proved (e.g. that
extendedBehavior is false), so the specialized code has to be protected by a
guard, which essentially says "if extendedBehavior is true, branch to the non specialized code; else branch to the specialized code".
Under appropriate circumstances, the performance gain from specialization can be quite considerable.
See also
PartialEvaluation,
ProgramSpecialization (a synonym for
PartialEvaluation).
--
MikeVanEmmerik - 03 Dec 2001
(Specialization is not a
WikiName; renamed the topic to
ProgramSpecialization --
EelcoVisser - 04 Dec 2001)
CategoryOptimization
Transform.ProgramSpecialization moved from Transform.Specialization on 04 Dec 2001 - 10:50 by EelcoVisser -
put it back