From 1300678a36bf8d7081647aef3e2a37dbd496aaf5 Mon Sep 17 00:00:00 2001 From: Ronan Date: Wed, 8 Oct 2025 11:19:13 +0200 Subject: `ExprLoweringVisitorBase::getDefaultVal(Type*)` use `MakeVector/MatrixFromScalar` (#8512) - Allows using `Vector/Matrix` type with yet unresolved dimensions - Simpler implementation and in-line with default `Array` - Added `test/bugs/gh-8512.slang` --- source/slang/slang-lower-to-ir.cpp | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) (limited to 'source') diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index d3f7d4e4c..c4492cfbb 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -4948,34 +4948,17 @@ struct ExprLoweringVisitorBase : public ExprVisitor } else if (auto vectorType = as(type)) { - UInt elementCount = (UInt)getIntVal(vectorType->getElementCount()); - auto irDefaultValue = getSimpleVal(context, getDefaultVal(vectorType->getElementType())); - - List args; - for (UInt ee = 0; ee < elementCount; ++ee) - { - args.add(irDefaultValue); - } return LoweredValInfo::simple( - getBuilder()->emitMakeVector(irType, args.getCount(), args.getBuffer())); + getBuilder()->emitMakeVectorFromScalar(irType, irDefaultValue)); } else if (auto matrixType = as(type)) { - UInt rowCount = (UInt)getIntVal(matrixType->getRowCount()); - - auto rowType = matrixType->getRowType(); - - auto irDefaultValue = getSimpleVal(context, getDefaultVal(rowType)); - - List args; - for (UInt rr = 0; rr < rowCount; ++rr) - { - args.add(irDefaultValue); - } + auto irDefaultValue = + getSimpleVal(context, getDefaultVal(matrixType->getElementType())); return LoweredValInfo::simple( - getBuilder()->emitMakeMatrix(irType, args.getCount(), args.getBuffer())); + getBuilder()->emitMakeMatrixFromScalar(irType, irDefaultValue)); } else if (auto arrayType = as(type)) { -- cgit v1.2.3