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
Following some recent investigations on code generation around unboxed products array by @mshinwell , I found out that at least some functions in cmm_helpers.ml use the bind function a bit too eagerly, which can degrade the generated code when other functions are also used (e.g. int_array_ref and other array indexing functions).
For more explanations, the bind function is used to introduce let-bindings in cmm expressions, and is meant to be used to avoid duplicating a cmm expression, as well as ensure that the expression is actually evaluated, and that its evaluation is done in a coherent order (though that last point is still a bit unclear). So in practice these should only be used if the bound value (or the variable created for the binding) is used at least twice, or has effects/co-effects. When that is not the case, and the bound expression is only used once (and is pure, which happens reasonably frequently for expressions for e.g. array indexes), that prevents some (most ?) of the peephole optimizations, particularly around addressing in the case of array loads (but there may be other impacts).
Therefore, uses of int_array_ref and other related functions (e.g. array_indexing) should be reviewed to see whether some binds can be removed.
The text was updated successfully, but these errors were encountered:
Following some recent investigations on code generation around unboxed products array by @mshinwell , I found out that at least some functions in
cmm_helpers.ml
use thebind
function a bit too eagerly, which can degrade the generated code when other functions are also used (e.g.int_array_ref
and other array indexing functions).For more explanations, the
bind
function is used to introduce let-bindings in cmm expressions, and is meant to be used to avoid duplicating a cmm expression, as well as ensure that the expression is actually evaluated, and that its evaluation is done in a coherent order (though that last point is still a bit unclear). So in practice these should only be used if the bound value (or the variable created for the binding) is used at least twice, or has effects/co-effects. When that is not the case, and the bound expression is only used once (and is pure, which happens reasonably frequently for expressions for e.g. array indexes), that prevents some (most ?) of the peephole optimizations, particularly around addressing in the case of array loads (but there may be other impacts).Therefore, uses of
int_array_ref
and other related functions (e.g.array_indexing
) should be reviewed to see whether somebind
s can be removed.The text was updated successfully, but these errors were encountered: