[Mlir-commits] [mlir] [mlir][ABI] Fix scalable vector mapping in ABITypeMapper (PR #206617)

Federico Bruzzone llvmlistbot at llvm.org
Tue Jun 30 05:03:17 PDT 2026


================

----------------
FedericoBruzzone wrote:

If I'm not missing something, with `llvm::ElementCount` we cannot express: `<[2]x[4]xf32>` (both dimensions scalable). I.e.,
- runtime = (vscale * 2) * (vscale * 4) = vscale^2 * 8
- getScalable(8) = vscale * 8 x (off by a factor of vscale)
A single ElementCount has only one "scalable" bit, so vscale^2 cannot be expressed.

The following test should pass, but it doesn't:
```
TEST_F(ABITypeMapperTest, MapMultiScalableVectorReturnsNull) {
  DataLayout dl(module);
  ABITypeMapper mapper(dl);

  auto f32 = Float32Type::get(&ctx);
  auto vec = VectorType::get({2, 4}, f32, /*scalableDims=*/{true, true});
  const llvm::abi::Type *result = mapper.map(vec);

  // (vscale*2)*(vscale*4) = vscale^2*8,
  // ElementCount -> must return nullptr
  EXPECT_EQ(result, nullptr);
}
```

Possible paths: (i) we could assert `llvm::count(type.getScalableDims(), true) > 1` + the new test, or (ii) "fix" the `llvm:ElementCount`.

---

But again, is this correct?



https://github.com/llvm/llvm-project/pull/206617


More information about the Mlir-commits mailing list