Skip to content

[LinxV5] TSCATTER/TGATHER 编译失败:B.IOR indexed 绑定被 asm matcher 拒绝(Match Instruction Error) #70

Description

@zzzyh222

1. 版本信息 / Branch & Version Info

组件 分支 Commit
llvm-project temp/shared-tload-integration-20260811 86959776b(clang 15.0.4 linx64v5-musl-local)
Linx-TileOP-API linx 8b2ee78
SuperScalarModel detached a68dba29(gfrun 侧;本问题在编译期) a68dba29
SuperNPUBench release_ver0812 e13d54d
平台 Linux x86_64 + gcc

2. 现象 / Symptom

TSCATTER(dst, src, off) 头文件模板存在,但任何调用 TU 都在编译期被 LinxV5 asm matcher 拒绝

/home/.../include/tileop-api/jcore/template_asm.hpp:6600:6: error: Match Instruction Error!
    "B.IOR [%7],[]\n"
     ^
<inline asm>:6:1: note: instantiated into assembly here
B.IOR [u#1],[]
  • 失败发生在 汇编/匹配阶段B.IOR [u#1],[] indexed 绑定不被 matcher 识别),不是仿真器运行期;
  • TGATHER(selector 111)同样受影响(其 asm 也含 indexed B.IOR/offset 绑定);
  • TSCAN 等在方案中新增/已有指令正常编译,仅 indexed IOR 绑定类会失败。

3. 最小复现 / Minimal Repro(test_tscatter.cpp

#include <common/pto_tileop.hpp>
#include "benchmark.h"
#include <cstdint>
#define OUT_BASE 0x4000802000ULL

int main() {
    using U = uint32_t;
    constexpr int P = 128;
    using t  = Tile<Location::Vec, U, 1, P, BLayout::RowMajor>;
    using gt = global_tensor<U, RowMajor<1, P>>;
    static volatile U src_d[P], off_d[P];
    for (int j = 0; j < P; ++j) { src_d[j] = j + 3; off_d[j] = (j * 7) % P; }
    static U c1[P], c2[P];
    for (int j = 0; j < P; ++j) { c1[j] = src_d[j]; c2[j] = off_d[j]; }
    BENCHSTART;
    t s; { gt g(c1); TLOAD(s, g); }
    t o; { gt g(c2); TLOAD(o, g); }
    t dst;
    TSCATTER(dst, s, o);
    { gt go(reinterpret_cast<U*>(OUT_BASE)); TSTORE(go, dst); }
    BENCHEND;
    return 0;
}

编译命令(配置 COMPILER_DIR=/home/.../linx_blockisa_llvm_musl/bin):

R=<supernpu/one-level-arch>
$COMPILER_DIR/clang++ -c -mlxbc -fenable-matrix -O2 \
  -mllvm -enable-all-vector-as-tilereg=true \
  -mllvm -linxv5-enable-HL-Inst-Opt=true \
  -mllvm -linxv5-enable-dim-opt=true \
  -mllvm -linxv5-enable-ldst-bridge=false \
  -mllvm -linxv5-enable-continuous-mem-opt=true \
  -mllvm -linxv5-enable-tile-clock-hand=false \
  -mllvm -linxv5-enable-simt-clock-hand=true \
  -mllvm -enable-misched=false \
  -std=c++20 -D__linx -DENABLE_TENSOR_INSTR \
  -I$R/include -I$R/test/common -I$R/test/common/src -I$R/kernels -I$R/models \
  test_tscatter.cpp -o test_tscatter.o

实际输出(编译即失败,无 ELF 产出):

template_asm.hpp:6600:6: error: Match Instruction Error!
    "B.IOR [%7],[]\n"
B.IOR [u#1],[]
1 error generated.

4. 根因 / Root Cause

  • 定位于 jcore/template_asm.hppTSCATTER(6600) 模板:B.IOR [%7],[]source-only / indexed tile-offset 绑定不被当前 LinxV5 asm matcher 支持;
  • [PTO v0.58][MC] Canonicalize B.IOS/B.IOT/B.IOR assembly and disassembly #38(Canonicalize B.IOS/B.IOT/B.IOR assembly)相关:该 issue 关注 canonical 化,本问题为 matcher 对 indexed IOR 形式不支持,二者应一起评估;
  • 非 QLI 头文件结构问题(区别于 linx-toolchain-build#1 的 guard/重复定义 bug)。

5. 影响 / Impact

阻塞「radix-select 逐元素单趟散写(prefix-sum + indexed scatter)」类 kernel 的编译与落地;以及任何使用 TSCATTER/TGATHER index-offset 绑定的算子。

6. 期望修复 / Expected Fix

  • LinxV5 后端支持 B.IOR [reg],[] 的 indexed/source 绑定(TSCATTER selector 112、TGATHER selector 111);
  • 增加跨越模型的最小 scatter/gather 差分用例。

7. 后续验证说明 / Later Verification Note

本复现已于本地版本 8b2ee78 / 86959776b 确认;后续会拉取库上最新工具链(origin/dev-llvm15_56 / Linx-TileOP-API origin/linx)重跑同一 test_tscatter.cpp,若新版已支持将在此 issue 更新结果。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions