| ... | @@ -17578,10 +17578,13 @@ fn storePtr2( | ... | @@ -17578,10 +17578,13 @@ fn storePtr2( |
| 17578 | // To generate better code for tuples, we detect a tuple operand here, and | 17578 | // To generate better code for tuples, we detect a tuple operand here, and |
| 17579 | // analyze field loads and stores directly. This avoids an extra allocation + memcpy | 17579 | // analyze field loads and stores directly. This avoids an extra allocation + memcpy |
| 17580 | // which would occur if we used `coerce`. | 17580 | // which would occur if we used `coerce`. |
| 17581 | // However, we avoid this mechanism if the destination element type is | 17581 | // However, we avoid this mechanism if the destination element type is a tuple, |
| 17582 | // the same tuple as the source, because the regular store will be better for this case. | 17582 | // because the regular store will be better for this case. |
| | 17583 | // If the destination type is a struct we don't want this mechanism to trigger, because |
| | 17584 | // this code does not handle tuple-to-struct coercion which requires dealing with missing |
| | 17585 | // fields. |
| 17583 | const operand_ty = sema.typeOf(uncasted_operand); | 17586 | const operand_ty = sema.typeOf(uncasted_operand); |
| 17584 | if (operand_ty.isTuple() and !elem_ty.eql(operand_ty)) { | 17587 | if (operand_ty.isTuple() and elem_ty.zigTypeTag() == .Array) { |
| 17585 | const tuple = operand_ty.tupleFields(); | 17588 | const tuple = operand_ty.tupleFields(); |
| 17586 | for (tuple.types) |_, i_usize| { | 17589 | for (tuple.types) |_, i_usize| { |
| 17587 | const i = @intCast(u32, i_usize); | 17590 | const i = @intCast(u32, i_usize); |
| ... | @@ -17595,6 +17598,7 @@ fn storePtr2( | ... | @@ -17595,6 +17598,7 @@ fn storePtr2( |
| 17595 | } | 17598 | } |
| 17596 | | 17599 | |
| 17597 | // TODO do the same thing for anon structs as for tuples above. | 17600 | // TODO do the same thing for anon structs as for tuples above. |
| | 17601 | // However, beware of the need to handle missing/extra fields. |
| 17598 | | 17602 | |
| 17599 | // Detect if we are storing an array operand to a bitcasted vector pointer. | 17603 | // Detect if we are storing an array operand to a bitcasted vector pointer. |
| 17600 | // If so, we instead reach through the bitcasted pointer to the vector pointer, | 17604 | // If so, we instead reach through the bitcasted pointer to the vector pointer, |