Skip to content

Commit

Permalink
Optimize access of array member in a structure.
Browse files Browse the repository at this point in the history
  • Loading branch information
shwqf committed Dec 25, 2022
1 parent aaa4c51 commit 2b3f986
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/codegen/llvm.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5865,17 +5865,13 @@ pub const FuncGen = struct {
const load_ptr = load_data.ty_op.operand;
const load_ptr_tag = self.air.instructions.items(.tag)[Air.refToIndex(load_ptr).?];
switch (load_ptr_tag) {
.struct_field_ptr,
.struct_field_ptr_index_0,
.struct_field_ptr_index_1,
.struct_field_ptr_index_2,
.struct_field_ptr_index_3 => {
.struct_field_ptr, .struct_field_ptr_index_0, .struct_field_ptr_index_1, .struct_field_ptr_index_2, .struct_field_ptr_index_3 => {
const load_ptr_inst = try self.resolveInst(load_ptr);
const gep = self.builder.buildInBoundsGEP(array_llvm_ty, load_ptr_inst, &indices, indices.len, "");
array_llvm_val.removeUnusedLoadArray();
return self.builder.buildLoad(elem_llvm_ty, gep, "");
},
else => {}
else => {},
}
}
const elem_ptr = self.builder.buildInBoundsGEP(array_llvm_ty, array_llvm_val, &indices, indices.len, "");
Expand Down

0 comments on commit 2b3f986

Please sign in to comment.