Skip to content

Fix scf.for loop-carried memref reconciliation#262

Closed
HecreReed wants to merge 2 commits into
hw-native-sys:mainfrom
HecreReed:codex/fix-scf-for-memref-reconcile
Closed

Fix scf.for loop-carried memref reconciliation#262
HecreReed wants to merge 2 commits into
hw-native-sys:mainfrom
HecreReed:codex/fix-scf-for-memref-reconcile

Conversation

@HecreReed
Copy link
Copy Markdown
Collaborator

Summary

  • reconcile scf.for loop-carried iter_arg/result types after PTOViewToMemref rewrites tile values to memrefs
  • add a reduced .pto regression for loop-carried tile_buf values
  • verify the reported qwen3_decode_layer_incore_0.pto now compiles on top of origin/main

Root cause

PTOViewToMemref already had a post-rewrite fixup for scf.if, but not for scf.for. When loop-carried tile_buf values were rewritten to memrefs inside the loop body, the pass left the scf.for init operand, region iter_arg, yield operand, and op result out of sync.

Verification

  • cmake --build /tmp/ptoas-qwen-repro.oy3rK0/build-fix --target ptoas -j8
  • ptoas /tmp/ptoas-qwen-repro.oy3rK0/fix-branch/test/basic/scf_for_tile_iter_arg_reconcile.pto 2>&1 1>/dev/null | FileCheck /tmp/ptoas-qwen-repro.oy3rK0/fix-branch/test/basic/scf_for_tile_iter_arg_reconcile.pto
  • ptoas /Users/laoda/Downloads/qwen3_decode_layer_incore_0.pto -o /tmp/qwen-fix.cpp

@HecreReed HecreReed closed this Mar 14, 2026
Zhendong404 pushed a commit to Zhendong404/PTOAS that referenced this pull request May 17, 2026
* Add OP for TMrgSort

* Add OP for TMrgSort | fix review

* Add constraints to tmov template for UB2UB ND2ND only

Add constraint function to restrict template_tmov_basic to only support:
- UB2UB: Both src and dst must be in Unified Buffer (memory_space="ub")
- ND2ND: Both tiles must have N-dimensional layout (s_layout=NONE_BOX)

Other scenarios (GM2UB, UB2GM, specialized layouts) require different
implementation paths and are explicitly rejected by this constraint.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: caojian5 <caojian5@huawei.com>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant