Skip to content

Commit 2ce1add

Browse files
committed
Don't access pointer element type for nontemporal store
Simply shift the bitcast from the store to the load, so that we can use the destination type. I'm not sure the bitcast is really necessary, but keeping it for now.
1 parent 208173f commit 2ce1add

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

compiler/rustc_codegen_ssa/src/mir/operand.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,10 @@ impl<'a, 'tcx, V: CodegenObject> OperandValue<V> {
291291
OperandValue::Ref(r, None, source_align) => {
292292
if flags.contains(MemFlags::NONTEMPORAL) {
293293
// HACK(nox): This is inefficient but there is no nontemporal memcpy.
294-
// FIXME: Don't access pointer element type.
295-
let ty = bx.element_type(bx.val_ty(r));
296-
let val = bx.load(ty, r, source_align);
297-
let ptr = bx.pointercast(dest.llval, bx.type_ptr_to(ty));
298-
bx.store_with_flags(val, ptr, dest.align, flags);
294+
let ty = bx.backend_type(dest.layout);
295+
let ptr = bx.pointercast(r, bx.type_ptr_to(ty));
296+
let val = bx.load(ty, ptr, source_align);
297+
bx.store_with_flags(val, dest.llval, dest.align, flags);
299298
return;
300299
}
301300
base::memcpy_ty(bx, dest.llval, dest.align, r, source_align, dest.layout, flags)

0 commit comments

Comments
 (0)