Skip to content

Commit d2a22f5

Browse files
committed
Remove remainders from when booleans were i8
1 parent b8ef5cf commit d2a22f5

File tree

6 files changed

+12
-21
lines changed

6 files changed

+12
-21
lines changed

src/librustc/middle/trans/adt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ pub fn trans_case<'a>(bcx: &'a Block<'a>, r: &Repr, discr: Disr)
618618
RawNullablePointer { .. } |
619619
StructWrappedNullablePointer { .. } => {
620620
assert!(discr == 0 || discr == 1);
621-
_match::single_result(Result::new(bcx, C_i1(bcx.ccx(), discr != 0)))
621+
_match::single_result(Result::new(bcx, C_bool(bcx.ccx(), discr != 0)))
622622
}
623623
}
624624
}

src/librustc/middle/trans/base.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -539,8 +539,8 @@ pub fn compare_scalar_values<'a>(
539539
// We don't need to do actual comparisons for nil.
540540
// () == () holds but () < () does not.
541541
match op {
542-
ast::BiEq | ast::BiLe | ast::BiGe => return C_i1(cx.ccx(), true),
543-
ast::BiNe | ast::BiLt | ast::BiGt => return C_i1(cx.ccx(), false),
542+
ast::BiEq | ast::BiLe | ast::BiGe => return C_bool(cx.ccx(), true),
543+
ast::BiNe | ast::BiLt | ast::BiGt => return C_bool(cx.ccx(), false),
544544
// refinements would be nice
545545
_ => die(cx)
546546
}
@@ -1014,7 +1014,7 @@ pub fn call_memcpy(cx: &Block, dst: ValueRef, src: ValueRef, n_bytes: ValueRef,
10141014
let dst_ptr = PointerCast(cx, dst, Type::i8p(ccx));
10151015
let size = IntCast(cx, n_bytes, ccx.int_type);
10161016
let align = C_i32(ccx, align as i32);
1017-
let volatile = C_i1(ccx, false);
1017+
let volatile = C_bool(ccx, false);
10181018
Call(cx, memcpy, [dst_ptr, src_ptr, size, align, volatile], []);
10191019
}
10201020

@@ -1059,7 +1059,7 @@ fn memzero(b: &Builder, llptr: ValueRef, ty: Type) {
10591059
let llzeroval = C_u8(ccx, 0);
10601060
let size = machine::llsize_of(ccx, ty);
10611061
let align = C_i32(ccx, llalign_of_min(ccx, ty) as i32);
1062-
let volatile = C_i1(ccx, false);
1062+
let volatile = C_bool(ccx, false);
10631063
b.call(llintrinsicfn, [llptr, llzeroval, size, align, volatile], []);
10641064
}
10651065

src/librustc/middle/trans/common.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,10 +526,6 @@ pub fn C_nil(ccx: &CrateContext) -> ValueRef {
526526
}
527527

528528
pub fn C_bool(ccx: &CrateContext, val: bool) -> ValueRef {
529-
C_integral(Type::bool(ccx), val as u64, false)
530-
}
531-
532-
pub fn C_i1(ccx: &CrateContext, val: bool) -> ValueRef {
533529
C_integral(Type::i1(ccx), val as u64, false)
534530
}
535531

src/librustc/middle/trans/expr.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ fn trans_index<'a>(bcx: &'a Block<'a>,
505505

506506
let bounds_check = ICmp(bcx, lib::llvm::IntUGE, ix_val, len);
507507
let expect = ccx.get_intrinsic(&("llvm.expect.i1"));
508-
let expected = Call(bcx, expect, [bounds_check, C_i1(ccx, false)], []);
508+
let expected = Call(bcx, expect, [bounds_check, C_bool(ccx, false)], []);
509509
let bcx = with_cond(bcx, expected, |bcx| {
510510
controlflow::trans_fail_bounds_check(bcx, index_expr.span, ix_val, len)
511511
});
@@ -1149,13 +1149,7 @@ fn trans_unary<'a>(bcx: &'a Block<'a>,
11491149
match op {
11501150
ast::UnNot => {
11511151
let datum = unpack_datum!(bcx, trans(bcx, sub_expr));
1152-
let llresult = if ty::type_is_bool(un_ty) {
1153-
let val = datum.to_llscalarish(bcx);
1154-
Xor(bcx, val, C_bool(ccx, true))
1155-
} else {
1156-
// Note: `Not` is bitwise, not suitable for logical not.
1157-
Not(bcx, datum.to_llscalarish(bcx))
1158-
};
1152+
let llresult = Not(bcx, datum.to_llscalarish(bcx));
11591153
immediate_rvalue_bcx(bcx, llresult, un_ty).to_expr_datumblock()
11601154
}
11611155
ast::UnNeg => {

src/librustc/middle/trans/glue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ fn trans_struct_drop_flag<'a>(bcx: &'a Block<'a>,
234234
-> &'a Block<'a> {
235235
let repr = adt::represent_type(bcx.ccx(), t);
236236
let drop_flag = adt::trans_drop_flag_ptr(bcx, &*repr, v0);
237-
with_cond(bcx, IsNotNull(bcx, Load(bcx, drop_flag)), |cx| {
237+
with_cond(bcx, Load(bcx, drop_flag), |cx| {
238238
trans_struct_drop(cx, t, v0, dtor_did, class_did, substs)
239239
})
240240
}

src/librustc/middle/trans/intrinsic.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ pub fn trans_intrinsic(ccx: &CrateContext,
150150
let src_ptr = PointerCast(bcx, get_param(decl, first_real_arg + 1), Type::i8p(ccx));
151151
let count = get_param(decl, first_real_arg + 2);
152152
let llfn = ccx.get_intrinsic(&name);
153-
Call(bcx, llfn, [dst_ptr, src_ptr, Mul(bcx, size, count), align, C_i1(ccx, volatile)], []);
153+
Call(bcx, llfn,
154+
[dst_ptr, src_ptr, Mul(bcx, size, count), align, C_bool(ccx, volatile)], []);
154155
RetVoid(bcx);
155156
}
156157

@@ -171,13 +172,13 @@ pub fn trans_intrinsic(ccx: &CrateContext,
171172
let val = get_param(decl, first_real_arg + 1);
172173
let count = get_param(decl, first_real_arg + 2);
173174
let llfn = ccx.get_intrinsic(&name);
174-
Call(bcx, llfn, [dst_ptr, val, Mul(bcx, size, count), align, C_i1(ccx, volatile)], []);
175+
Call(bcx, llfn, [dst_ptr, val, Mul(bcx, size, count), align, C_bool(ccx, volatile)], []);
175176
RetVoid(bcx);
176177
}
177178

178179
fn count_zeros_intrinsic(bcx: &Block, name: &'static str) {
179180
let x = get_param(bcx.fcx.llfn, bcx.fcx.arg_pos(0u));
180-
let y = C_i1(bcx.ccx(), false);
181+
let y = C_bool(bcx.ccx(), false);
181182
let llfn = bcx.ccx().get_intrinsic(&name);
182183
let llcall = Call(bcx, llfn, [x, y], []);
183184
Ret(bcx, llcall);

0 commit comments

Comments
 (0)