@@ -5839,19 +5839,37 @@ pub const FuncGen = struct {
5839
5839
const array_ty = self.air.typeOf(bin_op.lhs);
5840
5840
const array_llvm_val = try self.resolveInst(bin_op.lhs);
5841
5841
const rhs = try self.resolveInst(bin_op.rhs);
5842
+ const array_llvm_ty = try self.dg.lowerType(array_ty);
5843
+ const elem_ty = array_ty.childType();
5842
5844
if (isByRef(array_ty)) {
5843
- const array_llvm_ty = try self .dg .lowerType (array_ty );
5844
5845
const indices: [2]*llvm.Value = .{ self.context.intType(32).constNull(), rhs };
5845
5846
const elem_ptr = self.builder.buildInBoundsGEP(array_llvm_ty, array_llvm_val, &indices, indices.len, "");
5846
- const elem_ty = array_ty .childType ();
5847
5847
if (isByRef(elem_ty)) {
5848
5848
if (canElideLoad(self, body_tail))
5849
5849
return elem_ptr;
5850
5850
5851
5851
const target = self.dg.module.getTarget();
5852
5852
return self.loadByRef(elem_ptr, elem_ty, elem_ty.abiAlignment(target), false);
5853
5853
} else {
5854
+ const lhs_index = Air.refToIndex(bin_op.lhs).?;
5854
5855
const elem_llvm_ty = try self.dg.lowerType(elem_ty);
5856
+ if (self.air.instructions.items(.tag)[lhs_index] == .load) {
5857
+ const load_data = self.air.instructions.items(.data)[lhs_index];
5858
+ const load_ptr = load_data.ty_op.operand;
5859
+ const load_ptr_tag = self.air.instructions.items(.tag)[Air.refToIndex(load_ptr).?];
5860
+ switch (load_ptr_tag) {
5861
+ .struct_field_ptr,
5862
+ .struct_field_ptr_index_0,
5863
+ .struct_field_ptr_index_1,
5864
+ .struct_field_ptr_index_2,
5865
+ .struct_field_ptr_index_3 => {
5866
+ const load_ptr_inst = try self.resolveInst(load_ptr);
5867
+ const gep = self.builder.buildInBoundsGEP(array_llvm_ty, load_ptr_inst, &indices, indices.len, "");
5868
+ return self.builder.buildLoad(elem_llvm_ty, gep, "");
5869
+ },
5870
+ else => {}
5871
+ }
5872
+ }
5855
5873
return self.builder.buildLoad(elem_llvm_ty, elem_ptr, "");
5856
5874
}
5857
5875
}
0 commit comments