Skip to content

fix(vpto): attach vscatter memory effects during lowering - #1188

Draft
mouliangyu wants to merge 2 commits into
hw-native-sys:mainfrom
mouliangyu:codex/fix-vscatter-cse-regression
Draft

fix(vpto): attach vscatter memory effects during lowering#1188
mouliangyu wants to merge 2 commits into
hw-native-sys:mainfrom
mouliangyu:codex/fix-vscatter-cse-regression

Conversation

@mouliangyu

@mouliangyu mouliangyu commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

背景

旧版 Bisheng 没有正确把 vscatter 建模为通过 destination pointer 写内存,可能导致 EarlyCSE 将 scatter 之后的同址 load 错误消除。PTOAS 已为最终 LLVM intrinsic 补充 memory attributes,但原实现是在 LLVM IR 导出后遍历函数名追加属性,且没有覆盖实际 CSE 序列的回归测试。

修改

  • 在 CANN 9.0.0 与 9.0.0-beta.1 两条 VPTO LLVM lowering 路径中,由 PlannedDecl 在 intrinsic 声明物化时直接附加 memory_effects(argMem = write)no_unwind
  • 删除 LLVM module 生成后按 llvm.hivm.vscatter.* 名字遍历并补属性的逻辑。
  • 将 LLVM 21 的 memory(argmem: write) 转换为 Bisheng LLVM 15 可解析的 writeonly argmemonly
  • 新增最小 lit 回归,覆盖同址 vlds -> vscatter -> mem_bar(VST_VLD) -> vlds,并检查最终 declaration 的 nounwind writeonly argmemonly

验证

  • cmake --build .work/build --target PTOASPythonCore -j4:PASS。
  • 新增回归的 CANN 9.0.0 与 9.0.0-beta.1 两条 RUN: 命令:PASS。
  • vscatter_low_width_vpto_llvm.pto 的 CANN 9.0.0 与 9.0.0-beta.1 两条 RUN: 命令:PASS。
  • Bisheng 15.0.5:bisheng -target hiipu64-hisilicon-cce -O2 -S -emit-llvm ...,优化后仍保留 2 次同址 vldsx1vscatterargmemonly nounwind writeonly

@mouliangyu mouliangyu changed the title test(vpto): cover vscatter memory effects for EarlyCSE fix(vpto): attach vscatter memory effects during lowering Aug 7, 2026
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