Skip to content

Commit f13306e

Browse files
committed
Switch boolean operands to 1-bit, as llvm prefers. Will promote to 8-bit when storing to memory.
1 parent 5a4cb3e commit f13306e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/comp/middle/trans.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ fn T_nil() -> TypeRef {
6262
ret llvm.LLVMVoidType();
6363
}
6464

65+
fn T_i1() -> TypeRef {
66+
ret llvm.LLVMInt1Type();
67+
}
68+
6569
fn T_i8() -> TypeRef {
6670
ret llvm.LLVMInt8Type();
6771
}
@@ -161,9 +165,9 @@ fn C_integral(int i, TypeRef t) -> ValueRef {
161165

162166
fn C_bool(bool b) -> ValueRef {
163167
if (b) {
164-
ret C_integral(1, T_i8());
168+
ret C_integral(1, T_i1());
165169
} else {
166-
ret C_integral(0, T_i8());
170+
ret C_integral(0, T_i1());
167171
}
168172
}
169173

@@ -274,8 +278,7 @@ fn trans_unary(@block_ctxt cx, ast.unop op, &ast.expr e) -> ValueRef {
274278
ret cx.build.Not(trans_expr(cx, e));
275279
}
276280
case (ast.not) {
277-
ret cx.build.And(C_bool(true),
278-
cx.build.Not(trans_expr(cx, e)));
281+
ret cx.build.Not(trans_expr(cx, e));
279282
}
280283
case (ast.neg) {
281284
// FIXME: switch by signedness.

0 commit comments

Comments
 (0)