You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Data Flow optimization needs to be expanded to handle the following construct:
i = rand(10)
a = i
i = rand(20)
b = i
print(a, b)
Currently, this code produces:
op rand i 10 0
set a i
op rand i 20 0
print a
print i
end
Of course, the source code typically doesn't contain such constructs, but this essentially is what some other optimizations, such as inlining function calls or unrolling a list iteration loop with modification may produce. We'd want to replace op rand i 10 0 with op rand a 10 0 and drop the set a i.
The text was updated successfully, but these errors were encountered:
A new optimization - "backpropagation" - was added to the Data Flow Optimization.
Up to now, Data Flow Optimization was only able to modify instruction arguments based on the data flow analyzed up to the instruction being inspected. A special mode was added which allows to modify instructions prior to the one being inspected: when a set instruction assigning a source variable to a target variable is encountered, the original instruction producing ("defining") the source variable is found. If the target variable's value is not needed between the assignments, and the source variable is not needed elsewhere, the set is dropped and the source variable is replaced with the target variable in the defining instruction.
The code above now produces (although in this particular example the compiled variable names match better the "spirit" of the source code, in general this is not guaranteed):
op rand :a 10 0
op rand :b 20 0
print :a
print :b
Will be included in version 3.1.0 as an experimental feature.
The Data Flow optimization needs to be expanded to handle the following construct:
Currently, this code produces:
Of course, the source code typically doesn't contain such constructs, but this essentially is what some other optimizations, such as inlining function calls or unrolling a list iteration loop with modification may produce. We'd want to replace
op rand i 10 0
withop rand a 10 0
and drop theset a i
.The text was updated successfully, but these errors were encountered: