Nov. 19, 2015
9:29 p.m.
SSA form? Le 19/11/15 22:14, Nicolai Hess a écrit :
What is the purpose of replacing expressions, used as limits in a to:do: call with by a new temporary variable?
For example:
OCOpalExamples>>#exampleToDoArgumentLimitIsExpression the code is
exampleToDoArgumentLimitIsExpression | count sum | count := 10. sum := 0. 1 to: count - 1 do: [ :each | sum := sum + each]. ^sum
the decompiled bytecode :
exampleToDoArgumentLimitIsExpression | tmp1 tmp2 tmp3 | tmp1 := 10. tmp2 := 0. tmp3 := tmp1 - 1. 1 to: tmp3 do: [ :tmp4 | tmp2 := tmp2 + tmp4 ]. ^ tmp2
So, the expression (count - 1) in the to:do: loop is replaced by a new temporay (tmp3).
Ok, but why ?