@@ -5746,19 +5746,37 @@ pub const FuncGen = struct {
5746
5746
const array_ty = self .air .typeOf (bin_op .lhs );
5747
5747
const array_llvm_val = try self .resolveInst (bin_op .lhs );
5748
5748
const rhs = try self .resolveInst (bin_op .rhs );
5749
+ const array_llvm_ty = try self .dg .lowerType (array_ty );
5750
+ const elem_ty = array_ty .childType ();
5749
5751
if (isByRef (array_ty )) {
5750
- const array_llvm_ty = try self .dg .lowerType (array_ty );
5751
5752
const indices : [2 ]* llvm.Value = .{ self .context .intType (32 ).constNull (), rhs };
5752
5753
const elem_ptr = self .builder .buildInBoundsGEP (array_llvm_ty , array_llvm_val , & indices , indices .len , "" );
5753
- const elem_ty = array_ty .childType ();
5754
5754
if (isByRef (elem_ty )) {
5755
5755
if (canElideLoad (self , body_tail ))
5756
5756
return elem_ptr ;
5757
5757
5758
5758
const target = self .dg .module .getTarget ();
5759
5759
return self .loadByRef (elem_ptr , elem_ty , elem_ty .abiAlignment (target ), false );
5760
5760
} else {
5761
+ const lhs_index = Air .refToIndex (bin_op .lhs ).? ;
5761
5762
const elem_llvm_ty = try self .dg .lowerType (elem_ty );
5763
+ if (self .air .instructions .items (.tag )[lhs_index ] == .load ) {
5764
+ const load_data = self .air .instructions .items (.data )[lhs_index ];
5765
+ const load_ptr = load_data .ty_op .operand ;
5766
+ const load_ptr_tag = self .air .instructions .items (.tag )[Air .refToIndex (load_ptr ).? ];
5767
+ switch (load_ptr_tag ) {
5768
+ .struct_field_ptr ,
5769
+ .struct_field_ptr_index_0 ,
5770
+ .struct_field_ptr_index_1 ,
5771
+ .struct_field_ptr_index_2 ,
5772
+ .struct_field_ptr_index_3 = > {
5773
+ const load_ptr_inst = try self .resolveInst (load_ptr );
5774
+ const gep = self .builder .buildInBoundsGEP (array_llvm_ty , load_ptr_inst , & indices , indices .len , "" );
5775
+ return self .builder .buildLoad (elem_llvm_ty , gep , "" );
5776
+ },
5777
+ else = > {}
5778
+ }
5779
+ }
5762
5780
return self .builder .buildLoad (elem_llvm_ty , elem_ptr , "" );
5763
5781
}
5764
5782
}
0 commit comments