about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs8
-rw-r--r--compiler/rustc_codegen_cranelift/src/value_and_place.rs10
2 files changed, 9 insertions, 9 deletions
diff --git a/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs b/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs
index 3e658cb1211..31f7e0d4e37 100644
--- a/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs
+++ b/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs
@@ -1132,14 +1132,15 @@ pub(crate) fn codegen_intrinsic_call<'tcx>(
             let is_eq_value =
                 if size == Size::ZERO {
                     // No bytes means they're trivially equal
-                    fx.bcx.ins().bconst(types::B1, true)
+                    fx.bcx.ins().iconst(types::I8, 1)
                 } else if let Some(clty) = type_by_size(size) {
                     // Can't use `trusted` for these loads; they could be unaligned.
                     let mut flags = MemFlags::new();
                     flags.set_notrap();
                     let lhs_val = fx.bcx.ins().load(clty, flags, lhs_ref, 0);
                     let rhs_val = fx.bcx.ins().load(clty, flags, rhs_ref, 0);
-                    fx.bcx.ins().icmp(IntCC::Equal, lhs_val, rhs_val)
+                    let eq = fx.bcx.ins().icmp(IntCC::Equal, lhs_val, rhs_val);
+                    fx.bcx.ins().bint(types::I8, eq)
                 } else {
                     // Just call `memcmp` (like slices do in core) when the
                     // size is too large or it's not a power-of-two.
@@ -1150,7 +1151,8 @@ pub(crate) fn codegen_intrinsic_call<'tcx>(
                     let returns = vec![AbiParam::new(types::I32)];
                     let args = &[lhs_ref, rhs_ref, bytes_val];
                     let cmp = fx.lib_call("memcmp", params, returns, args)[0];
-                    fx.bcx.ins().icmp_imm(IntCC::Equal, cmp, 0)
+                    let eq = fx.bcx.ins().icmp_imm(IntCC::Equal, cmp, 0);
+                    fx.bcx.ins().bint(types::I8, eq)
                 };
             ret.write_cvalue(fx, CValue::by_val(is_eq_value, ret.layout()));
         };
diff --git a/compiler/rustc_codegen_cranelift/src/value_and_place.rs b/compiler/rustc_codegen_cranelift/src/value_and_place.rs
index b6f5f5707fb..ae8ccc626b4 100644
--- a/compiler/rustc_codegen_cranelift/src/value_and_place.rs
+++ b/compiler/rustc_codegen_cranelift/src/value_and_place.rs
@@ -437,12 +437,6 @@ impl<'tcx> CPlace<'tcx> {
                 | (types::F32, types::I32)
                 | (types::I64, types::F64)
                 | (types::F64, types::I64) => fx.bcx.ins().bitcast(dst_ty, data),
-
-                // Widen an abstract SSA boolean to something that can be stored in memory
-                (types::B1, types::I8 | types::I16 | types::I32 | types::I64 | types::I128) => {
-                    fx.bcx.ins().bint(dst_ty, data)
-                }
-
                 _ if src_ty.is_vector() && dst_ty.is_vector() => {
                     fx.bcx.ins().raw_bitcast(dst_ty, data)
                 }
@@ -459,6 +453,10 @@ impl<'tcx> CPlace<'tcx> {
                     ptr.store(fx, data, MemFlags::trusted());
                     ptr.load(fx, dst_ty, MemFlags::trusted())
                 }
+
+                // `CValue`s should never contain SSA-only types, so if you ended
+                // up here having seen an error like `B1 -> I8`, then before
+                // calling `write_cvalue` you need to add a `bint` instruction.
                 _ => unreachable!("write_cvalue_transmute: {:?} -> {:?}", src_ty, dst_ty),
             };
             //fx.bcx.set_val_label(data, cranelift_codegen::ir::ValueLabel::new(var.index()));