about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2021-07-06 21:55:03 +0200
committerNikita Popov <nikita.ppv@gmail.com>2021-07-09 22:15:05 +0200
commit2ce1addeba5030eaa5d5dbdf2cc2a9c53a107c06 (patch)
tree8f6db1222a8d5c52dd1b59e2658e8474b22c5c50
parent208173f8e99bf91d122e4636d501d7d8701f22f1 (diff)
downloadrust-2ce1addeba5030eaa5d5dbdf2cc2a9c53a107c06.tar.gz
rust-2ce1addeba5030eaa5d5dbdf2cc2a9c53a107c06.zip
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.
-rw-r--r--compiler/rustc_codegen_ssa/src/mir/operand.rs9
1 files changed, 4 insertions, 5 deletions
diff --git a/compiler/rustc_codegen_ssa/src/mir/operand.rs b/compiler/rustc_codegen_ssa/src/mir/operand.rs
index 3481b36bcc0..3c42b2cc2ea 100644
--- a/compiler/rustc_codegen_ssa/src/mir/operand.rs
+++ b/compiler/rustc_codegen_ssa/src/mir/operand.rs
@@ -291,11 +291,10 @@ impl<'a, 'tcx, V: CodegenObject> OperandValue<V> {
             OperandValue::Ref(r, None, source_align) => {
                 if flags.contains(MemFlags::NONTEMPORAL) {
                     // HACK(nox): This is inefficient but there is no nontemporal memcpy.
-                    // FIXME: Don't access pointer element type.
-                    let ty = bx.element_type(bx.val_ty(r));
-                    let val = bx.load(ty, r, source_align);
-                    let ptr = bx.pointercast(dest.llval, bx.type_ptr_to(ty));
-                    bx.store_with_flags(val, ptr, dest.align, flags);
+                    let ty = bx.backend_type(dest.layout);
+                    let ptr = bx.pointercast(r, bx.type_ptr_to(ty));
+                    let val = bx.load(ty, ptr, source_align);
+                    bx.store_with_flags(val, dest.llval, dest.align, flags);
                     return;
                 }
                 base::memcpy_ty(bx, dest.llval, dest.align, r, source_align, dest.layout, flags)