This adds a new SIR optimization pass that removes unnecessary assignment statements in the SIR in loop body functions.
@harumichi can you try this for your use case and make sure its sufficient?
Note: Because of various complexities in the way that loop bodies are called and how they reference symbols in the calling process (see comment in the patch), this patch is only applied to innermost loop body functions at the moment. Rather than trying to make this pass interprocedural to support other functions, it will be better to simplify the SIR/code generation by making the loop body function a closure over the values it accesses, and have the code generation access those values as parameters of this closure without requiring specific naming conventions (currently, the variable names in the loop body function must match variable names in the calling function, which makes deleting those variables more complex).
This adds a new SIR optimization pass that removes unnecessary assignment statements in the SIR in loop body functions.
@harumichi can you try this for your use case and make sure its sufficient?
Note: Because of various complexities in the way that loop bodies are called and how they reference symbols in the calling process (see comment in the patch), this patch is only applied to innermost loop body functions at the moment. Rather than trying to make this pass interprocedural to support other functions, it will be better to simplify the SIR/code generation by making the loop body function a closure over the values it accesses, and have the code generation access those values as parameters of this closure without requiring specific naming conventions (currently, the variable names in the loop body function must match variable names in the calling function, which makes deleting those variables more complex).