about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2024-06-22 17:02:38 +0200
committerRalf Jung <post@ralfj.de>2024-06-22 17:11:55 +0200
commitdd2bd5bb7df300f655b596c287d6ca9eb642ff38 (patch)
tree1b5bbb48538f0a610dd17413c72449fa2840d811 /src
parented83f1acced66941bfc58ce4e884d46d9e96bf64 (diff)
downloadrust-dd2bd5bb7df300f655b596c287d6ca9eb642ff38.tar.gz
rust-dd2bd5bb7df300f655b596c287d6ca9eb642ff38.zip
evaluate arguments first, not inside the logic
Diffstat (limited to 'src')
-rw-r--r--src/tools/miri/src/shims/x86/mod.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/tools/miri/src/shims/x86/mod.rs b/src/tools/miri/src/shims/x86/mod.rs
index 7bccf71f043..afaf59eaadb 100644
--- a/src/tools/miri/src/shims/x86/mod.rs
+++ b/src/tools/miri/src/shims/x86/mod.rs
@@ -64,15 +64,20 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
             "addcarryx.u32" | "addcarryx.u64" => {
                 this.expect_target_feature_for_intrinsic(link_name, "adx")?;
 
-                if unprefixed_name.ends_with("64") && this.tcx.sess.target.arch != "x86_64" {
+                let is_u64 = unprefixed_name.ends_with("64");
+                if is_u64 && this.tcx.sess.target.arch != "x86_64" {
                     return Ok(EmulateItemResult::NotSupported);
                 }
 
                 let [c_in, a, b, out] = this.check_shim(abi, Abi::Unadjusted, link_name, args)?;
+                let out = this.deref_pointer_as(
+                    out,
+                    if is_u64 { this.machine.layouts.u64 } else { this.machine.layouts.u32 },
+                )?;
 
                 let (sum, c_out) = carrying_add(this, c_in, a, b, mir::BinOp::AddWithOverflow)?;
                 this.write_scalar(c_out, dest)?;
-                this.write_immediate(*sum, &this.deref_pointer_as(out, sum.layout)?)?;
+                this.write_immediate(*sum, &out)?;
             }
 
             // Used to implement the `_mm_pause` function.