Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Misc] Refactored flattend_values() to avoid potential conflicts in f…
…lattened statements (#6749) Issue: #5819 Overriding the flattened statement `stmt` of an `Expression` can cause conflicts, for example: ``` @ti.kernel def test(): x = ti.Vector([1, 2, 3, 4]) tmp = x + x[0] # implicit broadcast ``` In `x + x[0]`, the `x` on the lhs serves as rvalue whereas the `x` in the `x[0]` serves as a lvalue, so the result of `flatten_rvalue()` and `flatten_lvalue()` will override each other. To avoid such conflicts, this PR refactored the `flatten_values()` functions: 1. Flattened statement `stmt` of an `Expression` will only get modified by `Expression::flatten()`, any other overriding will be forbidden. 2. `flatten_rvalue()` and `flatten_lvalue()` now returns the flattened statement as the result. External users such as `irpass::lower_ast()` will turn to use the returned statement. Co-authored-by: Yi Xu <xy_xuyi@foxmail.com>
- Loading branch information