@@ -279,34 +279,22 @@ class SILCloner : protected SILInstructionVisitor<ImplClass> {
279
279
if (type->getNumElements () == 0 ) return false ;
280
280
281
281
// Do a first pass over the tuple elements to check out the
282
- // non-expansions. If there's more than one of them, or any of them
283
- // is labeled, we definitely stay a tuple and don't need to substitute
284
- // any of the expansions.
285
- unsigned numScalarElements = 0 ;
286
- for (auto index : indices (type->getElements ())) {
287
- auto eltType = type.getElementType (index);
288
- // Ignore pack expansions in this pass.
289
- if (isa<PackExpansionType>(eltType)) continue ;
290
-
291
- // If there's a labeled scalar element, we'll stay a tuple.
292
- if (type->getElement (index).hasName ()) return false ;
293
-
294
- // If there are multiple scalar elements, we'll stay a tuple.
295
- if (++numScalarElements > 1 ) return false ;
296
- }
297
-
298
- assert (numScalarElements <= 1 );
299
-
300
- // We must have expansions if we got here: if all the elements were
301
- // scalar, and none of them were labelled, and there wasn't more than
302
- // one of them, and there was at least one of them, then somehow
303
- // we had a tuple with a single unlabeled element.
282
+ // non-expansions. If there's more than one of them we definitely
283
+ // stay a tuple and don't need to substitute any of the expansions.
284
+ unsigned numScalarElements = type->getNumScalarElements ();
285
+ if (numScalarElements > 1 )
286
+ return false ;
304
287
305
288
// Okay, we need to substitute the count types for the expansions.
306
289
for (auto index : indices (type->getElements ())) {
307
290
// Ignore non-expansions because we've already counted them.
308
291
auto expansion = dyn_cast<PackExpansionType>(type.getElementType (index));
309
- if (!expansion) continue ;
292
+ if (!expansion) {
293
+ // If we have a non-expansion with a label, we stay a tuple.
294
+ if (type->getElement (index).hasName ())
295
+ return false ;
296
+ continue ;
297
+ }
310
298
311
299
// Substitute the shape class of the expansion.
312
300
auto newShapeClass = getOpASTType (expansion.getCountType ());
0 commit comments