diff options
| author | gingerBill <bill@gingerbill.org> | 2019-07-15 21:32:38 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2019-07-15 21:32:38 +0100 |
| commit | d471a5904198ab6f935ad1baef5269036160e634 (patch) | |
| tree | 4c7e05f4f30d0e803d96ca1837fb7f297ffc3629 /src/ir.cpp | |
| parent | f25818e9230b77bbe3a3422c75d1544c9b417fcf (diff) | |
IR fix array comparisons
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 481114d80..82f9fa755 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -4118,18 +4118,23 @@ irValue *ir_emit_comp(irProcedure *proc, TokenKind op_kind, irValue *left, irVal irValue *cmp = ir_emit_comp(proc, op_kind, x, y); res = ir_emit_arith(proc, cmp_op, res, cmp, t_bool); } + + return ir_emit_conv(proc, res, t_bool); } else { + irValue *val = ir_add_local_generated(proc, t_bool, false); + ir_emit_store(proc, val, res); auto loop_data = ir_loop_start(proc, count); - - 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); - res = ir_emit_arith(proc, cmp_op, res, cmp, t_bool); - + { + 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); + ir_emit_store(proc, val, ir_emit_conv(proc, new_res, t_bool)); + } ir_loop_end(proc, loop_data); - } - return ir_emit_conv(proc, res, t_bool); + return ir_emit_load(proc, val); + } } if (is_type_string(a)) { |