perf(vmi): optimize carrier-preserving integer casts - #1077
Merged
Conversation
This was referenced Jul 30, 2026
mouliangyu
force-pushed
the
codex/optimize-integer-cast-layouts
branch
from
August 3, 2026 05:23
2007527 to
388b787
Compare
mouliangyu
force-pushed
the
codex/optimize-integer-cast-layouts
branch
from
August 3, 2026 12:30
c378bd5 to
6546355
Compare
A5 板测成功
|
A3 板测失败
失败用例
|
A3 板测失败详情:PR #1077comm_p2p_binding_variants
comm_p2p
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
部分整数 cast 只改变逻辑元素解释,不需要执行实际的
vcvt:contiguous -> lane_stride=2/4可以直接复用物理 carrier。lane_stride=2/4,且 carrier gap 中的高位已知为 0 时,vcvt EVEN/P0也是冗余的。仅凭 lane-stride layout 不能推断 gap 为 0,因此 widening 优化采用保守且单一的准入规则:只接受由 canonical zero-filling producer 构造的 carrier,不追踪普通计算的数据流。
修改
u16/u32 -> u8/u16的 NOSAT 2x/4x narrowing 直接复用或 bitcast source carrier;SAT narrowing 继续生成vcvt。vcvtemission 选择策略。VPTOOptimizeVcvt由独立的 part 规范化与 zero-gap extension folding patterns 组成,通过 greedy rewrite driver 执行;cast 形状匹配与 producer provenance 分层处理。VPTOOptimizeVcvtpass,识别以下 unsigned zero-gap widening:u8 lane_stride=2 -> u16 contiguousu16 lane_stride=2 -> u32 contiguousu8 lane_stride=4 -> u32 contiguousisCanonicalZeroGapCarrier准入,只接受:vlds UNPK_B8/UNPK_B16/UNPK4vzunpack链vcvt(2x 使用EVEN,4x 使用P0)EVEN、4x widening 使用P0。vcvt。lane_stride -> contiguouscast 关系,使一物理 chunk 的 load-extension-store 能自然选择 zero-fill unpack load。测试
UNPK_B8、UNPK_B16、UNPK4load,且不含vcvt/vzunpack。vzunpack链、真实 narrowingvcvt、unknown gap、signed、mask 和 part 条件。vcvt正向覆盖u16 -> u8 -> u16、u32 -> u8 -> u32;错误的ODDpart 不建立 aligned zero gap。验证
cmake --build build --target PTOASPythonCore pto-test-opt -j4llvm-lit -sv -j 32 build/test/lit/vmi_new:446/446 passedvpto_optimize_vcvt、vmi_zero_gap_extui_load、vmi_lane_stride_dense_load_store,3/3 passedgit diff --checkRelates to #1024.