aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2018-01-21 18:41:21 +0000
committergingerBill <bill@gingerbill.org>2018-01-21 18:41:21 +0000
commitaa9c9eda9e2ca1e20356927f0a014cbf1e559205 (patch)
treeb15e25059a5729c229108fae419290574b05d043 /src
parent1353d6189455697e87237f74f6e68a781c563182 (diff)
Fix boolean casting
Diffstat (limited to 'src')
-rw-r--r--src/ir.cpp11
1 files changed, 2 insertions, 9 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index 63888c8dd..1d04ddec3 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -3053,10 +3053,8 @@ irValue *ir_emit_conv(irProcedure *proc, irValue *value, Type *t) {
return ir_emit(proc, ir_instr_conv(proc, kind, value, src_type, t));
}
- // boolean -> boolean
- if (is_type_boolean(src) && is_type_boolean(dst)) {
- GB_ASSERT(src->kind == Type_Basic &&
- dst->kind == Type_Basic);
+ // boolean -> boolean/integer
+ if (is_type_boolean(src) && (is_type_boolean(dst) || is_type_integer(dst))) {
GB_ASSERT(src != t_llvm_bool);
irValue *b = ir_emit(proc, ir_instr_binary_op(proc, Token_NotEq, value, v_zero, t_llvm_bool));
@@ -3064,11 +3062,6 @@ irValue *ir_emit_conv(irProcedure *proc, irValue *value, Type *t) {
}
- // boolean -> integer
- if (is_type_boolean(src) && is_type_integer(dst)) {
- return ir_emit(proc, ir_instr_conv(proc, irConv_zext, value, src_type, t));
- }
-
// integer -> boolean
if (is_type_integer(src) && is_type_boolean(dst)) {
return ir_emit_comp(proc, Token_NotEq, value, v_zero);