aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Rubin <daviru007@icloud.com>2024-07-15 03:37:06 -0700
committerDavid Rubin <daviru007@icloud.com>2024-07-26 04:05:41 -0700
commit81ca3a1d594cb25dcd7dbedf175dd9931cad0d0f (patch)
treea192c596e186cca2bcd37808eeda28a456613ad2 /src
parentcde6956b2128d9c28b00e0e25e27346abd1c3a88 (diff)
downloadzig-81ca3a1d594cb25dcd7dbedf175dd9931cad0d0f.tar.gz
zig-81ca3a1d594cb25dcd7dbedf175dd9931cad0d0f.zip
riscv: fix logic bug in `ptr_elem_ptr`
I was doing duplicate work with `elemOffset` multiplying by the abi size and then the `ptr_add` `genBinOp` also multiplying. This led to having writes happening in the wrong place.
Diffstat (limited to 'src')
-rw-r--r--src/arch/riscv64/CodeGen.zig18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/arch/riscv64/CodeGen.zig b/src/arch/riscv64/CodeGen.zig
index 34c782f66b..beff7ec879 100644
--- a/src/arch/riscv64/CodeGen.zig
+++ b/src/arch/riscv64/CodeGen.zig
@@ -3620,15 +3620,13 @@ fn airPtrElemPtr(func: *Func, inst: Air.Inst.Index) !void {
defer if (base_ptr_lock) |lock| func.register_manager.unlockReg(lock);
if (elem_ptr_ty.ptrInfo(zcu).flags.vector_index != .none) {
- break :result if (func.reuseOperand(inst, extra.lhs, 0, base_ptr_mcv))
- base_ptr_mcv
- else
- try func.copyToNewRegister(inst, base_ptr_mcv);
+ // break :result if (func.reuseOperand(inst, extra.lhs, 0, base_ptr_mcv))
+ // base_ptr_mcv
+ // else
+ // try func.copyToNewRegister(inst, base_ptr_mcv);
+ @panic("audit");
}
- const elem_ty = base_ptr_ty.elemType2(zcu);
- const elem_abi_size = elem_ty.abiSize(pt);
- const index_ty = func.typeOf(extra.rhs);
const index_mcv = try func.resolveInst(extra.rhs);
const index_lock: ?RegisterLock = switch (index_mcv) {
.register => |reg| func.register_manager.lockRegAssumeUnused(reg),
@@ -3636,10 +3634,6 @@ fn airPtrElemPtr(func: *Func, inst: Air.Inst.Index) !void {
};
defer if (index_lock) |lock| func.register_manager.unlockReg(lock);
- const offset_reg = try func.elemOffset(index_ty, index_mcv, elem_abi_size);
- const offset_reg_lock = func.register_manager.lockRegAssumeUnused(offset_reg);
- defer func.register_manager.unlockReg(offset_reg_lock);
-
const result_reg, const result_lock = try func.allocReg(.int);
defer func.register_manager.unlockReg(result_lock);
@@ -3647,7 +3641,7 @@ fn airPtrElemPtr(func: *Func, inst: Air.Inst.Index) !void {
.ptr_add,
base_ptr_mcv,
base_ptr_ty,
- .{ .register = offset_reg },
+ index_mcv,
Type.usize,
result_reg,
);