fix(vmi,ptodsl): correct GS8 lowering and With slot liveness - #1340
fix(vmi,ptodsl): correct GS8 lowering and With slot liveness#1340Zhendong404 wants to merge 1 commit into
Conversation
3b5bbc9 to
87c8f9a
Compare
mouliangyu
left a comment
There was a problem hiding this comment.
发现两个需要在合入前处理的问题:GS8 的普通 vlds 会把 compact load 的实际读取范围扩大到完整 vector footprint;With/AsyncWith 的 slot liveness 对多 context item 的绑定顺序处理不正确。
验证:LLVM 19.1.7 下重建 pto-test-opt 成功,11 个受影响的 VMI lit 用例通过;新增 PTODSL probe 可单独生成两个 scf.for。现有测试主要验证 IR 形态,未覆盖下面的内存边界和多 item with 场景。
| .create<VsldbOp>(op->getLoc(), vregType, | ||
| /*updated_base=*/Type{}, slotBase, | ||
| zeroI16, zeroI16, *slotMask) | ||
| .create<VldsOp>(op->getLoc(), vregType, |
There was a problem hiding this comment.
这里的 NORM vlds 会读取完整 vector footprint(例如 f32 carrier 为 256B),而 group_slot_load 的语义只保证 compact 的 group scalar 可读。忽略尾部 result lanes 并不会抑制对应内存访问,因此位于 UB 尾部的合法 compact source 可能触发地址越界;原 masked vsldb 至多访问选中的 32B block。请保留受限读取范围,或者明确增加并验证 source 后方 256B 可读的契约,同时补一个 UB 边界 runtime case。现有 docs/designs/vmi-layout-lowering-cases.md 也仍规定此处使用单个 32B vsldb。
|
|
||
|
|
||
| def _slot_live_before_stmt(stmt, live_after, static_env, static_iters) -> set[_SubscriptSlot]: | ||
| if isinstance(stmt, (ast.With, ast.AsyncWith)): |
There was a problem hiding this comment.
这里没有遵循 Python with item 从左到右求值、每项立即绑定 optional_vars 的语义。例如 with cm() as values, cm(values[0]): pass 中,第二项的 values[0] 不是 with 之前的 live-in,但当前实现会把它加入 context_loads,纯 AST probe 也确实返回该 slot。这可能生成未定义或多余的 loop carry。建议从 body_live 开始逆序遍历 items:先 kill 当前 optional_vars 的绑定,再加入该项 context_expr 的 loads,并覆盖 subscript 绑定目标。
dbeb86b to
309ad3d
Compare
309ad3d to
d112ac0
Compare
Summary
This PR keeps the two changes from
tilekernels-vmi-perfthat are still in scope, rebased onto the currentmain:With/AsyncWithstatements, with regression coverage.The previously included fp8/f16 deinterleaved cast-layout commit has been removed because that issue is being handled separately. No byte-widening vgather changes are included; those overlap with PTOAS PR #1315.
Validation
ninja -C build pto-test-optllvm-lit -v build/test/lit/vmi_new/vmi_to_vpto_group_slot_load.pto— PASSPYTHONPATH=build/python:$PYTHONPATH .venv/bin/python ptodsl/tests/test_jit_compile.py— PASSllvm-lit -q build/test/lit/vmi_new— 514/526 passed; 12 remaining failures are in existing group-slot/optimization paths.