diff options
author | James Newling <james.newling@gmail.com> | 2025-07-21 05:40:02 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-21 05:40:02 -0700 |
commit | 6edc1faf3b9238a231f1aca10d447be8ab826816 (patch) | |
tree | cb1b7b22a5a7328c2d4ea01b72efaf823ceb7032 /llvm/lib/Bitcode/Reader/BitcodeReader.cpp | |
parent | 401b5ccf6b507ed36e959e7ae2f4b5e052647196 (diff) | |
download | llvm-6edc1faf3b9238a231f1aca10d447be8ab826816.zip llvm-6edc1faf3b9238a231f1aca10d447be8ab826816.tar.gz llvm-6edc1faf3b9238a231f1aca10d447be8ab826816.tar.bz2 |
[mlir][llvm dialect] Verify element type of nested types (#148975)
Before this PR, this was valid
```
%0 = llvm.mlir.constant(dense<[1, 2]> : vector<2xi32>) : vector<2xf32>
```
but this was not:
```
%0 = llvm.mlir.constant(1 : i32) : f32
```
because only scalar types were checked for compatibility, not the element types of nested types. Another additional check that this PR adds is to verify the float semantics. Before this PR,
```
%cst = llvm.mlir.constant(1.0 : bf16) : f16
```
was considered valid (because bf16 and f16 both have 16 bits), but with this PR it is not considered valid. This PR also moves all tests on the verifier of the llvm constant op into a single file. To summarize the state after this PR.
Invalid:
```mlir
%0 = llvm.mlir.constant(dense<[128, 1024]> : vector<2xi32>) :
vector<2xf32>
%0 = llvm.mlir.constant(dense<[128., 1024.]> : vector<2xbf16>) :
vector<2xf16>
```
Valid:
```mlir
%0 = llvm.mlir.constant(dense<[128., 1024.]> : vector<2xf32>) :
vector<2xi32>
%0 = llvm.mlir.constant(dense<[128, 1024]> : vector<2xi64>) :
vector<2xi8>
```
and identical valid/invalid cases for the scalar cases.
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
0 files changed, 0 insertions, 0 deletions