Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
Due to multiple rounds of IPA with a reused function call graph, the same function is inlined multiple times leading to replication of operations. For most types of operations, common-subexpression elimination removes this redundancy, but for prints and rand without seeds this leads to unnecessary redundancy. For example,
s = "Debug info: " + sum(matrix(1,10,10)) z = foo(s); foo = function(String msg) return (boolean flag) { is_debug = TRUE; if( is_debug ) { print(msg); flag = TRUE; } else { flag = FALSE; } }
generates the following runtime plan with 3 replicated prints
PROGRAM
--MAIN PROGRAM
----GENERIC (lines 1-2) [recompile=false]
------(19) dg(rand) [10,10,1000,1000,100] [0,0,0 -> 0MB], CP
------(20) ua(+RC) (19) [0,0,-1,-1,-1] [0,0,0 -> 0MB], CP
------(21) b(+) (20) [0,0,-1,-1,-1] [0,0,0 -> 0MB], CP
------(5) u(print) (21) [-1,-1,-1,-1,-1] [0,0,0 -> 0MB]
------(7) TWrite z [0,0,-1,-1,-1] [0,0,0 -> 0MB], CP
------(5) u(print) (21) [-1,-1,-1,-1,-1] [0,0,0 -> 0MB]
------(7) TWrite z [0,0,-1,-1,-1] [0,0,0 -> 0MB], CP
------(5) u(print) (21) [-1,-1,-1,-1,-1] [0,0,0 -> 0MB]
------(7) TWrite z [0,0,-1,-1,-1] [0,0,0 -> 0MB], CP