llvm / llvm/llvm-project

[CIR] Upstream missing support for vector type operations

Open
#192,311 1 comment 1 reaction 1 assignee Claimed by @AmrDeveloper View on GitHub
ClangIR
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

### Overview

Upstream code from the incubator project to replace errorNYI calls in the
CIR codegen implementation for various vector type operations, including:
- Vec3 load/store with widening to vec4 when `PreserveVec3Type` is disabled
- ExtVector element store via read/modify/write shuffle
(`emitStoreThroughExtVectorComponentLValue`)
- ExtVectorBoolType handling in ext vector element loads
- Nested ext vector element access (compositing indices for non-simple lvalues)
- Vector ternary operator (`cir::VecTernaryOp`) for OpenCL/SVE vector
conditions in `?:` expressions
- `__builtin_astype` / `as_type` for bitcasting between vector types

Upstream NYI locations:
- `CIRGenExpr.cpp` — `emitStoreThroughLValue`: non-simple lvalue (ExtVectorElt)
- `CIRGenExpr.cpp` — `emitStoreOfScalar`: Vec3 widening to vec4 before store
- `CIRGenExpr.cpp` — `emitLoadOfScalar`: Vec3 load with shuffle back to
original size
- `CIRGenExpr.cpp` — `emitLoadOfExtVectorElementLValue`: ExtVectorBoolType
shuffle result
- `CIRGenExpr.cpp` — `emitExtVectorElementExpr`: non-simple nested ext vector
element access
- `CIRGenExprScalar.cpp` — `VisitAbstractConditionalOperator`: vector ternary
and SVE vector ternary
- `CIRGenExprScalar.cpp` — `VisitAsTypeExpr`: `__builtin_astype` bitcast

### Suggested minimal test case

```cpp
void test_ext_vector_element(float4 *p) {
p->xy = p->zw;
}

float4 test_vec_ternary(int4 cond, float4 a, float4 b) {
return cond ? a : b;
}
```

### Existing incubator tests

- `clang/test/CIR/CodeGen/vectype-ext.cpp`
- `clang/test/CIR/CodeGen/vector-ext-element.cpp`
- `clang/test/CIR/CodeGen/vectype.cpp`
- `clang/test/CIR/CodeGen/OpenCL/as_type.cl`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.