diff options
| author | gingerBill <bill@gingerbill.org> | 2019-07-27 10:44:40 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2019-07-27 10:44:40 +0100 |
| commit | 14059583cdb3039a16979f97c4fd1907fc069662 (patch) | |
| tree | 0092cfd53f701768e5e0510f30d6fdb2e40b5a9e /src/ir.cpp | |
| parent | f3bffb98101e3a584c8a5e8a6389c608ffe64c40 (diff) | |
Fix array comparisons
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 8c5dcb963..973aa7476 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -4111,14 +4111,17 @@ irValue *ir_emit_comp(irProcedure *proc, TokenKind op_kind, irValue *left, irVal if (inline_array_arith) { // inline + irValue *val = ir_add_local_generated(proc, t_bool, false); + ir_emit_store(proc, val, res); for (i32 i = 0; i < count; i++) { irValue *x = ir_emit_load(proc, ir_emit_array_epi(proc, lhs, i)); irValue *y = ir_emit_load(proc, ir_emit_array_epi(proc, rhs, i)); irValue *cmp = ir_emit_comp(proc, op_kind, x, y); - res = ir_emit_arith(proc, cmp_op, res, cmp, t_bool); + irValue *new_res = ir_emit_arith(proc, cmp_op, ir_emit_load(proc, val), cmp, t_bool); + ir_emit_store(proc, val, ir_emit_conv(proc, new_res, t_bool)); } - return ir_emit_conv(proc, res, t_bool); + return ir_emit_load(proc, val); } else { irValue *val = ir_add_local_generated(proc, t_bool, false); ir_emit_store(proc, val, res); @@ -4127,7 +4130,7 @@ irValue *ir_emit_comp(irProcedure *proc, TokenKind op_kind, irValue *left, irVal irValue *x = ir_emit_load(proc, ir_emit_array_ep(proc, lhs, loop_data.idx)); irValue *y = ir_emit_load(proc, ir_emit_array_ep(proc, rhs, loop_data.idx)); irValue *cmp = ir_emit_comp(proc, op_kind, x, y); - irValue *new_res = ir_emit_arith(proc, cmp_op, res, cmp, t_bool); + irValue *new_res = ir_emit_arith(proc, cmp_op, res, ir_emit_load(proc, val), t_bool); ir_emit_store(proc, val, ir_emit_conv(proc, new_res, t_bool)); } ir_loop_end(proc, loop_data); |