@@ -5720,19 +5720,37 @@ pub const FuncGen = struct {
5720
5720
const array_ty = self .air .typeOf (bin_op .lhs );
5721
5721
const array_llvm_val = try self .resolveInst (bin_op .lhs );
5722
5722
const rhs = try self .resolveInst (bin_op .rhs );
5723
+ const array_llvm_ty = try self .dg .lowerType (array_ty );
5724
+ const elem_ty = array_ty .childType ();
5723
5725
if (isByRef (array_ty )) {
5724
- const array_llvm_ty = try self .dg .lowerType (array_ty );
5725
5726
const indices : [2 ]* llvm.Value = .{ self .context .intType (32 ).constNull (), rhs };
5726
5727
const elem_ptr = self .builder .buildInBoundsGEP (array_llvm_ty , array_llvm_val , & indices , indices .len , "" );
5727
- const elem_ty = array_ty .childType ();
5728
5728
if (isByRef (elem_ty )) {
5729
5729
if (canElideLoad (self , body_tail ))
5730
5730
return elem_ptr ;
5731
5731
5732
5732
const target = self .dg .module .getTarget ();
5733
5733
return self .loadByRef (elem_ptr , elem_ty , elem_ty .abiAlignment (target ), false );
5734
5734
} else {
5735
+ const lhs_index = Air .refToIndex (bin_op .lhs ).? ;
5735
5736
const elem_llvm_ty = try self .dg .lowerType (elem_ty );
5737
+ if (self .air .instructions .items (.tag )[lhs_index ] == .load ) {
5738
+ const load_data = self .air .instructions .items (.data )[lhs_index ];
5739
+ const load_ptr = load_data .ty_op .operand ;
5740
+ const load_ptr_tag = self .air .instructions .items (.tag )[Air .refToIndex (load_ptr ).? ];
5741
+ switch (load_ptr_tag ) {
5742
+ .struct_field_ptr ,
5743
+ .struct_field_ptr_index_0 ,
5744
+ .struct_field_ptr_index_1 ,
5745
+ .struct_field_ptr_index_2 ,
5746
+ .struct_field_ptr_index_3 = > {
5747
+ const load_ptr_inst = try self .resolveInst (load_ptr );
5748
+ const gep = self .builder .buildInBoundsGEP (array_llvm_ty , load_ptr_inst , & indices , indices .len , "" );
5749
+ return self .builder .buildLoad (elem_llvm_ty , gep , "" );
5750
+ },
5751
+ else = > {}
5752
+ }
5753
+ }
5736
5754
return self .builder .buildLoad (elem_llvm_ty , elem_ptr , "" );
5737
5755
}
5738
5756
}
0 commit comments