Generate vector constructions more efficiently when sizes match

When two vectors are the same size, there is no need to extract the
components and construct a new vector.
This commit is contained in:
Arcady Goldmints-Orlov 2024-06-21 14:07:50 -04:00 committed by arcady-lunarg
parent 2d8b71fc63
commit 33d517470e
13 changed files with 1777 additions and 1867 deletions

View file

@ -3424,6 +3424,12 @@ Id Builder::createConstructor(Decoration precision, const std::vector<Id>& sourc
if (sources.size() == 1 && isScalar(sources[0]) && numTargetComponents > 1)
return smearScalar(precision, sources[0], resultTypeId);
// Special case: 2 vectors of equal size
if (sources.size() == 1 && isVector(sources[0]) && numTargetComponents == getNumComponents(sources[0])) {
assert(resultTypeId == getTypeId(sources[0]));
return sources[0];
}
// accumulate the arguments for OpCompositeConstruct
std::vector<Id> constituents;
Id scalarTypeId = getScalarTypeId(resultTypeId);