[clang] [clang][bytecode][HLSL] Complete the HLSL aggregate splat and elementwise cast implementations, and enable the new constant interpreter on all HLSL tests with static asserts (PR #189126)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 17 03:52:08 PDT 2026
================
@@ -991,20 +931,14 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *E) {
if (!this->emitSetLocal(PT_Ptr, SrcOffset, E))
return false;
- unsigned NumElems = std::min(SrcNumElems, DestNumElems);
- for (unsigned I = 0; I != NumElems; ++I) {
- if (!this->emitGetLocal(PT_Ptr, SrcOffset, E))
- return false;
- if (!this->emitArrayElemPop(SrcElemT, I, E))
- return false;
- if (SrcElemT != DestElemT) {
- if (!this->emitPrimCast(SrcElemT, DestElemT, DestElemType, E))
- return false;
- }
- if (!this->emitInitElem(DestElemT, I, E))
- return false;
- }
- return true;
+ // Only flatten as many source elements as the destination requires.
+ unsigned MaxElems = countHLSLFlatElements(DestType);
+
+ SmallVector<HLSLFlatElement, 16> Elements;
----------------
tbaederr wrote:
Does a `.reserve(MaxElems)` make sense here?
https://github.com/llvm/llvm-project/pull/189126
More information about the cfe-commits
mailing list