Repository: bytecodealliance/wasmtime
Pull request #6053 (2023-03-17 18:28:08)

craneleft: cancel `ineg` when args to `imul`
```
;; ineg(x) * ineg(y) == x*y.
```


Patch:
diff --git a/cranelift/codegen/src/dominator_tree.rs b/cranelift/codegen/src/dominator_tree.rs
index a4985261a..135697497 100644
--- a/cranelift/codegen/src/dominator_tree.rs
+++ b/cranelift/codegen/src/dominator_tree.rs
@@ -2,7 +2,7 @@
 
 use crate::entity::SecondaryMap;
 use crate::flowgraph::{BlockPredecessor, ControlFlowGraph};
-use crate::ir::{Block, ExpandedProgramPoint, Function, Inst, Layout, ProgramOrder, Value};
+use crate::ir::{Block, Function, Inst, Layout, ProgramPoint};
 use crate::packed_option::PackedOption;
 use crate::timing;
 use alloc::vec::Vec;
@@ -88,7 +88,7 @@ impl DominatorTree {
     }
 
     /// Compare two blocks relative to the reverse post-order.
-    fn rpo_cmp_block(&self, a: Block, b: Block) -> Ordering {
+    pub fn rpo_cmp_block(&self, a: Block, b: Block) -> Ordering {
         self.nodes[a].rpo_number.cmp(&self.nodes[b].rpo_number)
     }
 
@@ -100,13 +100,13 @@ impl DominatorTree {
     /// If `a` and `b` belong to the same block, compare their relative position in the block.
     pub fn rpo_cmp<A, B>(&self, a: A, b: B, layout: &Layout) -> Ordering
     where
-        A: Into<ExpandedProgramPoint>,
-        B: Into<ExpandedProgramPoint>,
+        A: Into<ProgramPoint>,
+        B: Into<ProgramPoint>,
     {
         let a = a.into();
         let b = b.into();
         self.rpo_cmp_block(layout.pp_block(a), layout.pp_block(b))
-            .then(layout.cmp(a, b))
+            .then(layout.pp_cmp(a, b))
     }
 
     /// Returns `true` if `a` dominates `b`.
@@ -120,21 +120,21 @@ impl DominatorTree {
     /// An instruction is considered to dominate itself.
     pub fn dominates<A, B>(&self, a: A, b: B, layout: &Layout) -> bool
     where
-        A: Into<ExpandedProgramPoint>,
-        B: Into<ExpandedProgramPoint>,
+        A: Into<ProgramPoint>,
+        B: Into<ProgramPoint>,
     {
         let a = a.into();
         let b = b.into();
         match a {
-            ExpandedProgramPoint::Block(block_a) => {
+            ProgramPoint::Block(block_a) => {
                 a == b || self.last_dominator(block_a, b, layout).is_some()
             }
-            ExpandedProgramPoint::Inst(inst_a) => {
+            ProgramPoint::Inst(inst_a) => {
                 let block_a = layout
                     .inst_block(inst_a)
                     .expect("Instruction not in layout.");
                 match self.last_dominator(block_a, b, layout) {
-                    Some(last) => layout.cmp(inst_a, last) != Ordering::Greater,
+                    Some(last) => layout.pp_cmp(inst_a, last) != Ordering::Greater,
                     None => false,
                 }
             }
@@ -145,11 +145,11 @@ impl DominatorTree {
     /// If no instructions in `a` dominate `b`, return `None`.
     pub fn last_dominator<B>(&self, a: Block, b: B, layout: &Layout) -> Option<Inst>
     where
-        B: Into<ExpandedProgramPoint>,
+        B: Into<ProgramPoint>,
     {
         let (mut block_b, mut inst_b) = match b.into() {
-            ExpandedProgramPoint::Block(block) => (block, None),
-            ExpandedProgramPoint::Inst(inst) => (
+            ProgramPoint::Block(block) => (block, None),
+            ProgramPoint::Inst(inst) => (
                 layout.inst_block(inst).expect("Instruction not in layout."),
                 Some(inst),
             ),
@@ -210,7 +210,7 @@ impl DominatorTree {
         );
 
         // We're in the same block. The common dominator is the earlier instruction.
-        if layout.cmp(a.inst, b.inst) == Ordering::Less {
+        if layout.pp_cmp(a.inst, b.inst) == Ordering::Less {
             a
         } else {
             b
@@ -475,7 +475,9 @@ impl DominatorTreePreorder {
         // sibling lists are ordered according to the CFG reverse post-order.
         for &block in domtree.cfg_postorder() {
             if let Some(idom_inst) = domtree.idom(block) {
-                let idom = layout.pp_block(idom_inst);
+                let idom = layout
+                    .inst_block(idom_inst)
+                    .expect("Instruction not in layout.");
                 let sib = mem::replace(&mut self.nodes[idom].child, block.into());
                 self.nodes[block].sibling = sib;
             } else {
@@ -505,7 +507,9 @@ impl DominatorTreePreorder {
         // its dominator tree children.
         for &block in domtree.cfg_postorder() {
             if let Some(idom_inst) = domtree.idom(block) {
-                let idom = layout.pp_block(idom_inst);
+                let idom = layout
+                    .inst_block(idom_inst)
+                    .expect("Instruction not in layout.");
                 let pre_max = cmp::max(self.nodes[block].pre_max, self.nodes[idom].pre_max);
                 self.nodes[idom].pre_max = pre_max;
             }
@@ -568,26 +572,13 @@ impl DominatorTreePreorder {
     /// program points dominated by pp follow immediately and contiguously after pp in the order.
     pub fn pre_cmp<A, B>(&self, a: A, b: B, layout: &Layout) -> Ordering
     where
-        A: Into<ExpandedProgramPoint>,
-        B: Into<ExpandedProgramPoint>,
+        A: Into<ProgramPoint>,
+        B: Into<ProgramPoint>,
     {
         let a = a.into();
         let b = b.into();
         self.pre_cmp_block(layout.pp_block(a), layout.pp_block(b))
-            .then(layout.cmp(a, b))
-    }
-
-    /// Compare two value defs according to the dominator tree pre-order.
-    ///
-    /// Two values defined at the same program point are compared according to their parameter or
-    /// result order.
-    ///
-    /// This is a total ordering of the values in the function.
-    pub fn pre_cmp_def(&self, a: Value, b: Value, func: &Function) -> Ordering {
-        let da = func.dfg.value_def(a);
-        let db = func.dfg.value_def(b);
-        self.pre_cmp(da, db, &func.layout)
-            .then_with(|| da.num().cmp(&db.num()))
+            .then(layout.pp_cmp(a, b))
     }
 }
 
diff --git a/cranelift/codegen/src/ir/dfg.rs b/cranelift/codegen/src/ir/dfg.rs
index 171892161..5784812cf 100644
--- a/cranelift/codegen/src/ir/dfg.rs
+++ b/cranelift/codegen/src/ir/dfg.rs
@@ -492,11 +492,6 @@ impl ValueDef {
         }
     }
 
-    /// Get the program point where the value was defined.
-    pub fn pp(self) -> ir::ExpandedProgramPoint {
-        self.into()
-    }
-
     /// Get the number component of this definition.
     ///
     /// When multiple values are defined at the same program point, this indicates the index of
diff --git a/cranelift/codegen/src/ir/layout.rs b/cranelift/codegen/src/ir/layout.rs
index 644665bab..f8bbc12fe 100644
--- a/cranelift/codegen/src/ir/layout.rs
+++ b/cranelift/codegen/src/ir/layout.rs
@@ -4,7 +4,7 @@
 //! determined by the `Layout` data structure defined in this module.
 
 use crate::entity::SecondaryMap;
-use crate::ir::progpoint::{ExpandedProgramPoint, ProgramOrder};
+use crate::ir::progpoint::ProgramPoint;
 use crate::ir::{Block, Inst};
 use crate::packed_option::PackedOption;
 use crate::{timing, trace};
@@ -114,33 +114,33 @@ fn test_midpoint() {
     assert_eq!(midpoint(3, 4), None);
 }
 
-impl ProgramOrder for Layout {
-    fn cmp<A, B>(&self, a: A, b: B) -> cmp::Ordering
+impl Layout {
+    /// Compare the program points `a` and `b` relative to this program order.
+    ///
+    /// Return `Less` if `a` appears in the program before `b`.
+    ///
+    /// This is declared as a generic such that it can be called with `Inst` and `Block` arguments
+    /// directly. Depending on the implementation, there is a good chance performance will be
+    /// improved for those cases where the type of either argument is known statically.
+    pub fn pp_cmp<A, B>(&self, a: A, b: B) -> cmp::Ordering
     where
-        A: Into<ExpandedProgramPoint>,
-        B: Into<ExpandedProgramPoint>,
+        A: Into<ProgramPoint>,
+        B: Into<ProgramPoint>,
     {
         let a_seq = self.seq(a);
         let b_seq = self.seq(b);
         a_seq.cmp(&b_seq)
     }
-
-    fn is_block_gap(&self, inst: Inst, block: Block) -> bool {
-        let i = &self.insts[inst];
-        let e = &self.blocks[block];
-
-        i.next.is_none() && i.block == e.prev
-    }
 }
 
 // Private methods for dealing with sequence numbers.
 impl Layout {
     /// Get the sequence number of a program point that must correspond to an entity in the layout.
-    fn seq<PP: Into<ExpandedProgramPoint>>(&self, pp: PP) -> SequenceNumber {
+    fn seq<PP: Into<ProgramPoint>>(&self, pp: PP) -> SequenceNumber {
         // When `PP = Inst` or `PP = Block`, we expect this dynamic type check to be optimized out.
         match pp.into() {
-            ExpandedProgramPoint::Block(block) => self.blocks[block].seq,
-            ExpandedProgramPoint::Inst(inst) => self.insts[inst].seq,
+            ProgramPoint::Block(block) => self.blocks[block].seq,
+            ProgramPoint::Inst(inst) => self.insts[inst].seq,
         }
     }
 
@@ -536,15 +536,10 @@ impl Layout {
     }
 
     /// Get the block containing the program point `pp`. Panic if `pp` is not in the layout.
-    pub fn pp_block<PP>(&self, pp: PP) -> Block
-    where
-        PP: Into<ExpandedProgramPoint>,
-    {
-        match pp.into() {
-            ExpandedProgramPoint::Block(block) => block,
-            ExpandedProgramPoint::Inst(inst) => {
-                self.inst_block(inst).expect("Program point not in layout")
-            }
+    pub fn pp_block(&self, pp: ProgramPoint) -> Block {
+        match pp {
+            ProgramPoint::Block(block) => block,
+            ProgramPoint::Inst(inst) => self.inst_block(inst).expect("Program point not in layout"),
         }
     }
 
@@ -867,7 +862,7 @@ mod tests {
     use super::Layout;
     use crate::cursor::{Cursor, CursorPosition};
     use crate::entity::EntityRef;
-    use crate::ir::{Block, Inst, ProgramOrder, SourceLoc};
+    use crate::ir::{Block, Inst, SourceLoc};
     use alloc::vec::Vec;
     use core::cmp::Ordering;
 
@@ -1289,13 +1284,8 @@ mod tests {
         }
 
         // Check `ProgramOrder`.
-        assert_eq!(layout.cmp(e2, e2), Ordering::Equal);
-        assert_eq!(layout.cmp(e2, i2), Ordering::Less);
-        assert_eq!(layout.cmp(i3, i2), Ordering::Greater);
-
-        assert_eq!(layout.is_block_gap(i1, e2), true);
-        assert_eq!(layout.is_block_gap(i3, e1), true);
-        assert_eq!(layout.is_block_gap(i1, e1), false);
-        assert_eq!(layout.is_block_gap(i2, e1), false);
+        assert_eq!(layout.pp_cmp(e2, e2), Ordering::Equal);
+        assert_eq!(layout.pp_cmp(e2, i2), Ordering::Less);
+        assert_eq!(layout.pp_cmp(i3, i2), Ordering::Greater)
     }
 }
diff --git a/cranelift/codegen/src/ir/mod.rs b/cranelift/codegen/src/ir/mod.rs
index 7b000c8e7..3a5936fcb 100644
--- a/cranelift/codegen/src/ir/mod.rs
+++ b/cranelift/codegen/src/ir/mod.rs
@@ -53,7 +53,7 @@ pub use crate::ir::known_symbol::KnownSymbol;
 pub use crate::ir::layout::Layout;
 pub use crate::ir::libcall::{get_probestack_funcref, LibCall};
 pub use crate::ir::memflags::{Endianness, MemFlags};
-pub use crate::ir::progpoint::{ExpandedProgramPoint, ProgramOrder, ProgramPoint};
+pub use crate::ir::progpoint::ProgramPoint;
 pub use crate::ir::sourceloc::RelSourceLoc;
 pub use crate::ir::sourceloc::SourceLoc;
 pub use crate::ir::stackslot::{
diff --git a/cranelift/codegen/src/ir/progpoint.rs b/cranelift/codegen/src/ir/progpoint.rs
index 39c4d98fb..780054776 100644
--- a/cranelift/codegen/src/ir/progpoint.rs
+++ b/cranelift/codegen/src/ir/progpoint.rs
@@ -1,10 +1,7 @@
 //! Program points.
 
-use crate::entity::EntityRef;
-use crate::ir::{Block, Inst, ValueDef};
-use core::cmp;
+use crate::ir::{Block, Inst};
 use core::fmt;
-use core::u32;
 
 /// A `ProgramPoint` represents a position in a function where the live range of an SSA value can
 /// begin or end. It can be either:
@@ -14,45 +11,14 @@ use core::u32;
 ///
 /// This corresponds more or less to the lines in the textual form of Cranelift IR.
 #[derive(PartialEq, Eq, Clone, Copy)]
-pub struct ProgramPoint(u32);
-
-impl From<Inst> for ProgramPoint {
-    fn from(inst: Inst) -> Self {
-        let idx = inst.index();
-        debug_assert!(idx < (u32::MAX / 2) as usize);
-        Self((idx * 2) as u32)
-    }
-}
-
-impl From<Block> for ProgramPoint {
-    fn from(block: Block) -> Self {
-        let idx = block.index();
-        debug_assert!(idx < (u32::MAX / 2) as usize);
-        Self((idx * 2 + 1) as u32)
-    }
-}
-
-impl From<ValueDef> for ProgramPoint {
-    fn from(def: ValueDef) -> Self {
-        match def {
-            ValueDef::Result(inst, _) => inst.into(),
-            ValueDef::Param(block, _) => block.into(),
-            ValueDef::Union(_, _) => panic!("Union does not have a single program point"),
-        }
-    }
-}
-
-/// An expanded program point directly exposes the variants, but takes twice the space to
-/// represent.
-#[derive(PartialEq, Eq, Clone, Copy)]
-pub enum ExpandedProgramPoint {
+pub enum ProgramPoint {
     /// An instruction in the function.
     Inst(Inst),
     /// A block header.
     Block(Block),
 }
 
-impl ExpandedProgramPoint {
+impl ProgramPoint {
     /// Get the instruction we know is inside.
     pub fn unwrap_inst(self) -> Inst {
         match self {
@@ -62,39 +28,19 @@ impl ExpandedProgramPoint {
     }
 }
 
-impl From<Inst> for ExpandedProgramPoint {
+impl From<Inst> for ProgramPoint {
     fn from(inst: Inst) -> Self {
         Self::Inst(inst)
     }
 }
 
-impl From<Block> for ExpandedProgramPoint {
+impl From<Block> for ProgramPoint {
     fn from(block: Block) -> Self {
         Self::Block(block)
     }
 }
 
-impl From<ValueDef> for ExpandedProgramPoint {
-    fn from(def: ValueDef) -> Self {
-        match def {
-            ValueDef::Result(inst, _) => inst.into(),
-            ValueDef::Param(block, _) => block.into(),
-            ValueDef::Union(_, _) => panic!("Union does not have a single program point"),
-        }
-    }
-}
-
-impl From<ProgramPoint> for ExpandedProgramPoint {
-    fn from(pp: ProgramPoint) -> Self {
-        if pp.0 & 1 == 0 {
-            Self::Inst(Inst::from_u32(pp.0 / 2))
-        } else {
-            Self::Block(Block::from_u32(pp.0 / 2))
-        }
-    }
-}
-
-impl fmt::Display for ExpandedProgramPoint {
+impl fmt::Display for ProgramPoint {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match *self {
             Self::Inst(x) => write!(f, "{}", x),
@@ -103,48 +49,12 @@ impl fmt::Display for ExpandedProgramPoint {
     }
 }
 
-impl fmt::Display for ProgramPoint {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        let epp: ExpandedProgramPoint = (*self).into();
-        epp.fmt(f)
-    }
-}
-
-impl fmt::Debug for ExpandedProgramPoint {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        write!(f, "ExpandedProgramPoint({})", self)
-    }
-}
-
 impl fmt::Debug for ProgramPoint {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         write!(f, "ProgramPoint({})", self)
     }
 }
 
-/// Context for ordering program points.
-///
-/// `ProgramPoint` objects don't carry enough information to be ordered independently, they need a
-/// context providing the program order.
-pub trait ProgramOrder {
-    /// Compare the program points `a` and `b` relative to this program order.
-    ///
-    /// Return `Less` if `a` appears in the program before `b`.
-    ///
-    /// This is declared as a generic such that it can be called with `Inst` and `Block` arguments
-    /// directly. Depending on the implementation, there is a good chance performance will be
-    /// improved for those cases where the type of either argument is known statically.
-    fn cmp<A, B>(&self, a: A, b: B) -> cmp::Ordering
-    where
-        A: Into<ExpandedProgramPoint>,
-        B: Into<ExpandedProgramPoint>;
-
-    /// Is the range from `inst` to `block` just the gap between consecutive blocks?
-    ///
-    /// This returns true if `inst` is the terminator in the block immediately before `block`.
-    fn is_block_gap(&self, inst: Inst, block: Block) -> bool;
-}
-
 #[cfg(test)]
 mod tests {
     use super::*;
diff --git a/cranelift/codegen/src/isle_prelude.rs b/cranelift/codegen/src/isle_prelude.rs
index cf0caac32..d557d53f9 100644
--- a/cranelift/codegen/src/isle_prelude.rs
+++ b/cranelift/codegen/src/isle_prelude.rs
@@ -217,6 +217,36 @@ macro_rules! isle_common_prelude_methods {
             u64::MAX >> shift
         }
 
+        #[inline]
+        fn ty_umin(&mut self, _ty: Type) -> u64 {
+            0
+        }
+
+        #[inline]
+        fn ty_umax(&mut self, ty: Type) -> u64 {
+            self.ty_mask(ty)
+        }
+
+        #[inline]
+        fn ty_smin(&mut self, ty: Type) -> u64 {
+            let ty_bits = ty.bits();
+            debug_assert_ne!(ty_bits, 0);
+            let shift = 64_u64
+                .checked_sub(ty_bits.into())
+                .expect("unimplemented for > 64 bits");
+            (i64::MIN as u64) >> shift
+        }
+
+        #[inline]
+        fn ty_smax(&mut self, ty: Type) -> u64 {
+            let ty_bits = ty.bits();
+            debug_assert_ne!(ty_bits, 0);
+            let shift = 64_u64
+                .checked_sub(ty_bits.into())
+                .expect("unimplemented for > 64 bits");
+            (i64::MAX as u64) >> shift
+        }
+
         fn fits_in_16(&mut self, ty: Type) -> Option<Type> {
             if ty.bits() <= 16 && !ty.is_dynamic_vector() {
                 Some(ty)
diff --git a/cranelift/codegen/src/legalizer/mod.rs b/cranelift/codegen/src/legalizer/mod.rs
index c226f0cb5..3b09ed1fc 100644
--- a/cranelift/codegen/src/legalizer/mod.rs
+++ b/cranelift/codegen/src/legalizer/mod.rs
@@ -299,7 +299,10 @@ fn expand_cond_trap(
     //
     //   new_block_resume:
     //     ..
-    let old_block = func.layout.pp_block(inst);
+    let old_block = func
+        .layout
+        .inst_block(inst)
+        .expect("Instruction not in layout.");
     let new_block_trap = func.dfg.make_block();
     let new_block_resume = func.dfg.make_block();
 
diff --git a/cranelift/codegen/src/opts/algebraic.isle b/cranelift/codegen/src/opts/algebraic.isle
index 3efa05dfe..03ed0be23 100644
--- a/cranelift/codegen/src/opts/algebraic.isle
+++ b/cranelift/codegen/src/opts/algebraic.isle
@@ -35,6 +35,10 @@
 ;; ineg(ineg(x)) == x.
 (rule (simplify (ineg ty (ineg ty x))) (subsume x))
 
+;; ineg(x) * ineg(y) == x*y.
+(rule (simplify (imul ty (ineg ty x) (ineg ty y)))
+      (subsume (imul ty x y)))
+
 ;; x-x == 0.
 (rule (simplify (isub (fits_in_64 (ty_int ty)) x x)) (subsume (iconst ty (imm64 0))))
 
@@ -377,20 +381,97 @@
              (iconst _ (u64_from_imm64 1))))
       extend)
 
-;; `x < 0` is always false for unsigned integers, and `x >= 0` is always true
-;; for unsigned integers, along with their reversals.
+;; ult(x, 0) == false.
 (rule (simplify
-       (icmp (fits_in_64 (ty_int ty))
-             (IntCC.UnsignedLessThan)
-             _
-             (iconst _ (u64_from_imm64 0))))
-      (iconst ty (imm64 0)))
+       (icmp (fits_in_64 (ty_int bty)) (IntCC.UnsignedLessThan) x zero @ (iconst _ (u64_from_imm64 0))))
+      (subsume (iconst bty (imm64 0))))
+
+;; ule(x, 0) == eq(x, 0)
 (rule (simplify
-       (icmp (fits_in_64 (ty_int ty))
-             (IntCC.UnsignedGreaterThanOrEqual)
-             _
-             (iconst _ (u64_from_imm64 0))))
-      (iconst ty (imm64 1)))
+       (icmp (fits_in_64 (ty_int bty)) (IntCC.UnsignedLessThanOrEqual) x zero @ (iconst _ (u64_from_imm64 0))))
+      (icmp bty (IntCC.Equal) x zero))
+
+;; ugt(x, 0) == ne(x, 0).
+(rule (simplify
+       (icmp (fits_in_64 (ty_int bty)) (IntCC.UnsignedGreaterThan) x zero @ (iconst _ (u64_from_imm64 0))))
+      (icmp bty (IntCC.NotEqual) x zero))
+
+;; uge(x, 0) == true.
+(rule (simplify
+       (icmp (fits_in_64 (ty_int bty)) (IntCC.UnsignedGreaterThanOrEqual) x zero @ (iconst _ (u64_from_imm64 0))))
+      (subsume (iconst bty (imm64 1))))
+
+;; ult(x, UMAX) == ne(x, UMAX).
+(rule (simplify
+       (icmp (fits_in_64 (ty_int bty)) (IntCC.UnsignedLessThan) x umax @ (iconst cty (u64_from_imm64 y))))
+       (if-let $true (u64_eq y (ty_umax cty)))
+       (icmp bty (IntCC.NotEqual) x umax))
+
+;; ule(x, UMAX) == true.
+(rule (simplify
+       (icmp (fits_in_64 (ty_int bty)) (IntCC.UnsignedLessThanOrEqual) x umax @ (iconst cty (u64_from_imm64 y))))
+       (if-let $true (u64_eq y (ty_umax cty)))
+       (subsume (iconst bty (imm64 1))))
+
+;; ugt(x, UMAX) == false.
+(rule (simplify
+       (icmp (fits_in_64 (ty_int bty)) (IntCC.UnsignedGreaterThan) x umax @ (iconst cty (u64_from_imm64 y))))
+       (if-let $true (u64_eq y (ty_umax cty)))
+       (subsume (iconst bty (imm64 0))))
+
+;; uge(x, UMAX) == eq(x, UMAX).
+(rule (simplify
+       (icmp (fits_in_64 (ty_int bty)) (IntCC.UnsignedGreaterThanOrEqual) x umax @ (iconst cty (u64_from_imm64 y))))
+       (if-let $true (u64_eq y (ty_umax cty)))
+       (icmp bty (IntCC.Equal) x umax))
+
+;; slt(x, SMIN) == false.
+(rule (simplify
+       (icmp (fits_in_64 (ty_int bty)) (IntCC.SignedLessThan) x smin @ (iconst cty (u64_from_imm64 y))))
+       (if-let $true (u64_eq y (ty_smin cty)))
+       (subsume (iconst bty (imm64 0))))
+
+;; sle(x, SMIN) == eq(x, SMIN).
+(rule (simplify
+       (icmp (fits_in_64 (ty_int bty)) (IntCC.SignedLessThanOrEqual) x smin @ (iconst cty (u64_from_imm64 y))))
+       (if-let $true (u64_eq y (ty_smin cty)))
+       (icmp bty (IntCC.Equal) x smin))
+
+;; sgt(x, SMIN) == ne(x, SMIN).
+(rule (simplify
+       (icmp (fits_in_64 (ty_int bty)) (IntCC.SignedGreaterThan) x smin @ (iconst cty (u64_from_imm64 y))))
+       (if-let $true (u64_eq y (ty_smin cty)))
+       (icmp bty (IntCC.NotEqual) x smin))
+
+;; sge(x, SMIN) == true.
+(rule (simplify
+       (icmp (fits_in_64 (ty_int bty)) (IntCC.SignedGreaterThanOrEqual) x smin @ (iconst cty (u64_from_imm64 y))))
+       (if-let $true (u64_eq y (ty_smin cty)))
+       (subsume (iconst bty (imm64 1))))
+
+;; slt(x, SMAX) == ne(x, SMAX).
+(rule (simplify
+       (icmp (fits_in_64 (ty_int bty)) (IntCC.SignedLessThan) x smax @ (iconst cty (u64_from_imm64 y))))
+       (if-let $true (u64_eq y (ty_smax cty)))
+       (icmp bty (IntCC.NotEqual) x smax))
+
+;; sle(x, SMAX) == true.
+(rule (simplify
+       (icmp (fits_in_64 (ty_int bty)) (IntCC.SignedLessThanOrEqual) x smax @ (iconst cty (u64_from_imm64 y))))
+       (if-let $true (u64_eq y (ty_smax cty)))
+       (subsume (iconst bty (imm64 1))))
+
+;; sgt(x, SMAX) == false.
+(rule (simplify
+       (icmp (fits_in_64 (ty_int bty)) (IntCC.SignedGreaterThan) x smax @ (iconst cty (u64_from_imm64 y))))
+       (if-let $true (u64_eq y (ty_smax cty)))
+       (subsume (iconst bty (imm64 0))))
+
+;; sge(x, SMAX) == eq(x, SMAX).
+(rule (simplify
+       (icmp (fits_in_64 (ty_int bty)) (IntCC.SignedGreaterThanOrEqual) x smax @ (iconst cty (u64_from_imm64 y))))
+       (if-let $true (u64_eq y (ty_smax cty)))
+       (icmp bty (IntCC.Equal) x smax))
 
 ;; 32-bit integers zero-extended to 64-bit integers are never negative
 (rule (simplify
diff --git a/cranelift/codegen/src/prelude.isle b/cranelift/codegen/src/prelude.isle
index ef2741570..5461109fd 100644
--- a/cranelift/codegen/src/prelude.isle
+++ b/cranelift/codegen/src/prelude.isle
@@ -208,6 +208,23 @@
 
 (extern const $I32X4XN Type)
 
+;; Get the unsigned minimum value for a given type.
+;; This always zero, but is included for completeness.
+(decl pure ty_umin (Type) u64)
+(extern constructor ty_umin ty_umin)
+
+;; Get the unsigned maximum value for a given type.
+(decl pure ty_umax (Type) u64)
+(extern constructor ty_umax ty_umax)
+
+;; Get the signed minimum value for a given type.
+(decl pure ty_smin (Type) u64)
+(extern constructor ty_smin ty_smin)
+
+;; Get the signed maximum value for a given type.
+(decl pure ty_smax (Type) u64)
+(extern constructor ty_smax ty_smax)
+
 ;; Get the bit width of a given type.
 (decl pure ty_bits (Type) u8)
 (extern constructor ty_bits ty_bits)
diff --git a/cranelift/codegen/src/verifier/mod.rs b/cranelift/codegen/src/verifier/mod.rs
index 016abdbf7..4f1e8a3df 100644
--- a/cranelift/codegen/src/verifier/mod.rs
+++ b/cranelift/codegen/src/verifier/mod.rs
@@ -884,7 +884,11 @@ impl<'a> Verifier<'a> {
         self.verify_value(loc_inst, v, errors)?;
 
         let dfg = &self.func.dfg;
-        let loc_block = self.func.layout.pp_block(loc_inst);
+        let loc_block = self
+            .func
+            .layout
+            .inst_block(loc_inst)
+            .expect("Instruction not in layout.");
         let is_reachable = self.expected_domtree.is_reachable(loc_block);
 
         // SSA form
@@ -1101,17 +1105,13 @@ impl<'a> Verifier<'a> {
                 ));
             }
         }
-        // We verify rpo_cmp on pairs of adjacent blocks in the postorder
+        // We verify rpo_cmp_block on pairs of adjacent blocks in the postorder
         for (&prev_block, &next_block) in domtree.cfg_postorder().iter().adjacent_pairs() {
-            if self
-                .expected_domtree
-                .rpo_cmp(prev_block, next_block, &self.func.layout)
-                != Ordering::Greater
-            {
+            if self.expected_domtree.rpo_cmp_block(prev_block, next_block) != Ordering::Greater {
                 return errors.fatal((
                     next_block,
                     format!(
-                        "invalid domtree, rpo_cmp does not says {} is greater than {}",
+                        "invalid domtree, rpo_cmp_block does not says {} is greater than {}",
                         prev_block, next_block
                     ),
                 ));
diff --git a/cranelift/wasm/src/code_translator/bounds_checks.rs b/cranelift/wasm/src/code_translator/bounds_checks.rs
index edb02b949..95ba787f4 100644
--- a/cranelift/wasm/src/code_translator/bounds_checks.rs
+++ b/cranelift/wasm/src/code_translator/bounds_checks.rs
@@ -7,6 +7,17 @@
 //! * a static access size,
 //!
 //! bounds check the memory access and translate it into a native memory access.
+//!
+//! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+//! !!!                                                                      !!!
+//! !!!    THIS CODE IS VERY SUBTLE, HAS MANY SPECIAL CASES, AND IS ALSO     !!!
+//! !!!   ABSOLUTELY CRITICAL FOR MAINTAINING THE SAFETY OF THE WASM HEAP    !!!
+//! !!!                             SANDBOX.                                 !!!
+//! !!!                                                                      !!!
+//! !!!    A good rule of thumb is to get two reviews on any substantive     !!!
+//! !!!                         changes in here.                             !!!
+//! !!!                                                                      !!!
+//! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
 use super::Reachability;
 use crate::{FuncEnvironment, HeapData, HeapStyle};
@@ -108,7 +119,67 @@ where
             ))
         }
 
-        // 2. Second special case for when `offset + access_size <= min_size`.
+        // 2. Second special case for when we know that there are enough guard
+        //    pages to cover the offset and access size.
+        //
+        //    The precise should-we-trap condition is
+        //
+        //        index + offset + access_size > bound
+        //
+        //    However, if we instead check only the partial condition
+        //
+        //        index > bound
+        //
+        //    then the most out of bounds that the access can be, while that
+        //    partial check still succeeds, is `offset + access_size`.
+        //
+        //    However, when we have a guard region that is at least as large as
+        //    `offset + access_size`, we can rely on the virtual memory
+        //    subsystem handling these out-of-bounds errors at
+        //    runtime. Therefore, the partial `index > bound` check is
+        //    sufficient for this heap configuration.
+        //
+        //    Additionally, this has the advantage that a series of Wasm loads
+        //    that use the same dynamic index operand but different static
+        //    offset immediates -- which is a common code pattern when accessing
+        //    multiple fields in the same struct that is in linear memory --
+        //    will all emit the same `index > bound` check, which we can GVN.
+        //
+        //    2.a Dedupe bounds checks with Spectre mitigations.
+        HeapStyle::Dynamic { bound_gv }
+            if offset_and_size <= heap.offset_guard_size && spectre_mitigations_enabled =>
+        {
+            let bound = builder.ins().global_value(env.pointer_type(), bound_gv);
+            Reachable(compute_addr(
+                &mut builder.cursor(),
+                heap,
+                env.pointer_type(),
+                index,
+                offset,
+                Some(SpectreOobComparison {
+                    cc: IntCC::UnsignedGreaterThan,
+                    lhs: index,
+                    rhs: bound,
+                }),
+            ))
+        }
+
+        //   2.b. Emit explicit `index > bound` check.
+        HeapStyle::Dynamic { bound_gv } if offset_and_size <= heap.offset_guard_size => {
+            let bound = builder.ins().global_value(env.pointer_type(), bound_gv);
+            let oob = builder.ins().icmp(IntCC::UnsignedGreaterThan, index, bound);
+            builder.ins().trapnz(oob, ir::TrapCode::HeapOutOfBounds);
+            Reachable(compute_addr(
+                &mut builder.cursor(),
+                heap,
+                env.pointer_type(),
+                index,
+                offset,
+                None,
+            ))
+        }
+
+        // 3. Second special case for when `offset + access_size <= min_size`.
         //
         //    We know that `bound >= min_size`, so we can do the following
         //    comparison, without fear of the right-hand side wrapping around:
@@ -116,7 +187,7 @@ where
         //            index + offset + access_size > bound
         //        ==> index > bound - (offset + access_size)
         //
-        //    2.a. Dedupe bounds checks with Spectre mitigations.
+        //    3.a. Dedupe bounds checks with Spectre mitigations.
         HeapStyle::Dynamic { bound_gv }
             if offset_and_size <= heap.min_size.into() && spectre_mitigations_enabled =>
         {
@@ -135,7 +206,7 @@ where
                 }),
             ))
         }
-        //    2.b. Emit explicit `index > bound - (offset + access_size)` bounds
+        //    3.b. Emit explicit `index > bound - (offset + access_size)` bounds
         //         checks.
         HeapStyle::Dynamic { bound_gv } if offset_and_size <= heap.min_size.into() => {
             let bound = builder.ins().global_value(env.pointer_type(), bound_gv);
@@ -154,13 +225,13 @@ where
             ))
         }
 
-        // 3. General case for dynamic memories:
+        // 4. General case for dynamic memories:
         //
         //        index + offset + access_size > bound
         //
         //    And we have to handle the overflow case in the left-hand side.
         //
-        //    3.a. Dedupe bounds checks with Spectre mitigations.
+        //    4.a. Dedupe bounds checks with Spectre mitigations.
         HeapStyle::Dynamic { bound_gv } if spectre_mitigations_enabled => {
             let access_size_val = builder
                 .ins()
@@ -184,7 +255,7 @@ where
                 }),
             ))
         }
-        //    3.b. Emit an explicit `index + offset + access_size > bound`
+        //    4.b. Emit an explicit `index + offset + access_size > bound`
         //         check.
         HeapStyle::Dynamic { bound_gv } => {
             let access_size_val = builder
@@ -377,7 +448,7 @@ fn compute_addr(
     index: ir::Value,
     offset: u32,
     // If we are performing Spectre mitigation with conditional selects, the
-    // values to compare and the condition code that indicates an out-of bounds
+    // values to compare and the condition code that indicates an out-of-bounds
     // condition; on this condition, the conditional move will choose a
     // speculatively safe address (a zero / null pointer) instead.
     spectre_oob_comparison: Option<SpectreOobComparison>,
@@ -387,6 +458,23 @@ fn compute_addr(
     // Add the heap base address base
     let base = pos.ins().global_value(addr_ty, heap.base);
 
+    // NB: We don't need to worry about overflow here when computing `base +
+    // index + offset` because the callee handled this concern for us and
+    // either:
+    //
+    // * We already did an explicit bounds check and know that `index + offset`
+    //   is within the heap's bounds, and therefore `base + index + offset` will
+    //   not overflow.
+    //
+    // * Or we will do that bounds check in the `select_spectre_guard` below,
+    //   and won't use the resulting value until after that bounds check
+    //   succeeds (and therefore we know that `index + offset` is within the
+    //   heap's bouns and `base + index + offset` didn't overflow). In this
+    //   scenario, if the addition did overflow, it doesn't matter since we will
+    //   just trap and won't use the result.
+    //
+    // * Or we statically know that it can never overflow due to the given heap
+    //   configuration (e.g. 32-bit static memories on a 64-bit host).
     let final_base = pos.ins().iadd(base, index);
     let final_addr = if offset == 0 {
         final_base
diff --git a/crates/runtime/src/cow.rs b/crates/runtime/src/cow.rs
index 12f809327..e043c31d1 100644
--- a/crates/runtime/src/cow.rs
+++ b/crates/runtime/src/cow.rs
@@ -9,7 +9,9 @@ use libc::c_void;
 use std::fs::File;
 use std::sync::Arc;
 use std::{convert::TryFrom, ops::Range};
-use wasmtime_environ::{DefinedMemoryIndex, MemoryInitialization, MemoryStyle, Module, PrimaryMap};
+use wasmtime_environ::{
+    DefinedMemoryIndex, MemoryInitialization, MemoryPlan, MemoryStyle, Module, PrimaryMap,
+};
 
 /// Backing images for memories in a module.
 ///
@@ -484,7 +486,7 @@ impl MemoryImageSlot {
         &mut self,
         initial_size_bytes: usize,
         maybe_image: Option<&Arc<MemoryImage>>,
-        style: &MemoryStyle,
+        plan: &MemoryPlan,
     ) -> Result<()> {
         assert!(!self.dirty);
         assert!(initial_size_bytes <= self.static_size);
@@ -509,22 +511,16 @@ impl MemoryImageSlot {
             self.accessible = initial_size_bytes;
         }
 
-        // Next, if the "static" style of memory is being used then that means
-        // that the addressable heap must be shrunk to match
-        // `initial_size_bytes`. This is because the "static" flavor of memory
-        // relies on page faults to indicate out-of-bounds accesses to memory.
-        //
-        // Note that "dynamic" memories do not shrink the heap here. A dynamic
-        // memory performs dynamic bounds checks so if the remaining heap is
-        // still addressable then that's ok since it still won't get accessed.
-        if initial_size_bytes < self.accessible {
-            match style {
-                MemoryStyle::Static { .. } => {
-                    self.set_protection(initial_size_bytes..self.accessible, false)?;
-                    self.accessible = initial_size_bytes;
-                }
-                MemoryStyle::Dynamic { .. } => {}
-            }
+        // If (1) the accessible region is not in its initial state, and (2) the
+        // memory relies on virtual memory at all (i.e. has offset guard pages
+        // and/or is static), then we need to reset memory protections. Put
+        // another way, the only time it is safe to not reset protections is
+        // when we are using dynamic memory without any guard pages.
+        if initial_size_bytes < self.accessible
+            && (plan.offset_guard_size > 0 || matches!(plan.style, MemoryStyle::Static { .. }))
+        {
+            self.set_protection(initial_size_bytes..self.accessible, false)?;
+            self.accessible = initial_size_bytes;
         }
 
         // Now that memory is sized appropriately the final operation is to
@@ -834,10 +830,11 @@ impl Drop for MemoryImageSlot {
 mod test {
     use std::sync::Arc;
 
-    use super::{create_memfd, FdSource, MemoryImage, MemoryImageSlot, MemoryStyle};
+    use super::{create_memfd, FdSource, MemoryImage, MemoryImageSlot, MemoryPlan, MemoryStyle};
     use crate::mmap::Mmap;
     use anyhow::Result;
     use std::io::Write;
+    use wasmtime_environ::Memory;
 
     fn create_memfd_with_data(offset: usize, data: &[u8]) -> Result<MemoryImage> {
         // Offset must be page-aligned.
@@ -858,9 +855,23 @@ mod test {
         })
     }
 
+    fn dummy_memory_plan(style: MemoryStyle) -> MemoryPlan {
+        MemoryPlan {
+            style,
+            memory: Memory {
+                minimum: 0,
+                maximum: None,
+                shared: false,
+                memory64: false,
+            },
+            pre_guard_size: 0,
+            offset_guard_size: 0,
+        }
+    }
+
     #[test]
     fn instantiate_no_image() {
-        let style = MemoryStyle::Static { bound: 4 << 30 };
+        let plan = dummy_memory_plan(MemoryStyle::Static { bound: 4 << 30 });
         // 4 MiB mmap'd area, not accessible
         let mut mmap = Mmap::accessible_reserved(0, 4 << 20).unwrap();
         // Create a MemoryImageSlot on top of it
@@ -868,7 +879,7 @@ mod test {
         memfd.no_clear_on_drop();
         assert!(!memfd.is_dirty());
         // instantiate with 64 KiB initial size
-        memfd.instantiate(64 << 10, None, &style).unwrap();
+        memfd.instantiate(64 << 10, None, &plan).unwrap();
         assert!(memfd.is_dirty());
         // We should be able to access this 64 KiB (try both ends) and
         // it should consist of zeroes.
@@ -886,14 +897,14 @@ mod test {
         // reuse-anon-mmap-opt kicks in
         memfd.clear_and_remain_ready(0).unwrap();
         assert!(!memfd.is_dirty());
-        memfd.instantiate(64 << 10, None, &style).unwrap();
+        memfd.instantiate(64 << 10, None, &plan).unwrap();
         let slice = mmap.as_slice();
         assert_eq!(0, slice[1024]);
     }
 
     #[test]
     fn instantiate_image() {
-        let style = MemoryStyle::Static { bound: 4 << 30 };
+        let plan = dummy_memory_plan(MemoryStyle::Static { bound: 4 << 30 });
         // 4 MiB mmap'd area, not accessible
         let mut mmap = Mmap::accessible_reserved(0, 4 << 20).unwrap();
         // Create a MemoryImageSlot on top of it
@@ -902,38 +913,38 @@ mod test {
         // Create an image with some data.
         let image = Arc::new(create_memfd_with_data(4096, &[1, 2, 3, 4]).unwrap());
         // Instantiate with this image
-        memfd.instantiate(64 << 10, Some(&image), &style).unwrap();
+        memfd.instantiate(64 << 10, Some(&image), &plan).unwrap();
         assert!(memfd.has_image());
         let slice = mmap.as_mut_slice();
         assert_eq!(&[1, 2, 3, 4], &slice[4096..4100]);
         slice[4096] = 5;
         // Clear and re-instantiate same image
         memfd.clear_and_remain_ready(0).unwrap();
-        memfd.instantiate(64 << 10, Some(&image), &style).unwrap();
+        memfd.instantiate(64 << 10, Some(&image), &plan).unwrap();
         let slice = mmap.as_slice();
         // Should not see mutation from above
         assert_eq!(&[1, 2, 3, 4], &slice[4096..4100]);
         // Clear and re-instantiate no image
         memfd.clear_and_remain_ready(0).unwrap();
-        memfd.instantiate(64 << 10, None, &style).unwrap();
+        memfd.instantiate(64 << 10, None, &plan).unwrap();
         assert!(!memfd.has_image());
         let slice = mmap.as_slice();
         assert_eq!(&[0, 0, 0, 0], &slice[4096..4100]);
         // Clear and re-instantiate image again
         memfd.clear_and_remain_ready(0).unwrap();
-        memfd.instantiate(64 << 10, Some(&image), &style).unwrap();
+        memfd.instantiate(64 << 10, Some(&image), &plan).unwrap();
         let slice = mmap.as_slice();
         assert_eq!(&[1, 2, 3, 4], &slice[4096..4100]);
         // Create another image with different data.
         let image2 = Arc::new(create_memfd_with_data(4096, &[10, 11, 12, 13]).unwrap());
         memfd.clear_and_remain_ready(0).unwrap();
-        memfd.instantiate(128 << 10, Some(&image2), &style).unwrap();
+        memfd.instantiate(128 << 10, Some(&image2), &plan).unwrap();
         let slice = mmap.as_slice();
         assert_eq!(&[10, 11, 12, 13], &slice[4096..4100]);
         // Instantiate the original image again; we should notice it's
         // a different image and not reuse the mappings.
         memfd.clear_and_remain_ready(0).unwrap();
-        memfd.instantiate(64 << 10, Some(&image), &style).unwrap();
+        memfd.instantiate(64 << 10, Some(&image), &plan).unwrap();
         let slice = mmap.as_slice();
         assert_eq!(&[1, 2, 3, 4], &slice[4096..4100]);
     }
@@ -941,7 +952,7 @@ mod test {
     #[test]
     #[cfg(target_os = "linux")]
     fn memset_instead_of_madvise() {
-        let style = MemoryStyle::Static { bound: 100 };
+        let plan = dummy_memory_plan(MemoryStyle::Static { bound: 100 });
         let mut mmap = Mmap::accessible_reserved(0, 4 << 20).unwrap();
         let mut memfd = MemoryImageSlot::create(mmap.as_mut_ptr() as *mut _, 0, 4 << 20);
         memfd.no_clear_on_drop();
@@ -950,7 +961,7 @@ mod test {
         for image_off in [0, 4096, 8 << 10] {
             let image = Arc::new(create_memfd_with_data(image_off, &[1, 2, 3, 4]).unwrap());
             for amt_to_memset in [0, 4096, 10 << 12, 1 << 20, 10 << 20] {
-                memfd.instantiate(64 << 10, Some(&image), &style).unwrap();
+                memfd.instantiate(64 << 10, Some(&image), &plan).unwrap();
                 assert!(memfd.has_image());
                 let slice = mmap.as_mut_slice();
                 if image_off > 0 {
@@ -966,7 +977,7 @@ mod test {
 
         // Test without an image
         for amt_to_memset in [0, 4096, 10 << 12, 1 << 20, 10 << 20] {
-            memfd.instantiate(64 << 10, None, &style).unwrap();
+            memfd.instantiate(64 << 10, None, &plan).unwrap();
             for chunk in mmap.as_mut_slice()[..64 << 10].chunks_mut(1024) {
                 assert_eq!(chunk[0], 0);
                 chunk[0] = 5;
@@ -978,7 +989,7 @@ mod test {
     #[test]
     #[cfg(target_os = "linux")]
     fn dynamic() {
-        let style = MemoryStyle::Dynamic { reserve: 200 };
+        let plan = dummy_memory_plan(MemoryStyle::Dynamic { reserve: 200 });
 
         let mut mmap = Mmap::accessible_reserved(0, 4 << 20).unwrap();
         let mut memfd = MemoryImageSlot::create(mmap.as_mut_ptr() as *mut _, 0, 4 << 20);
@@ -988,7 +999,7 @@ mod test {
 
         // Instantiate the image and test that memory remains accessible after
         // it's cleared.
-        memfd.instantiate(initial, Some(&image), &style).unwrap();
+        memfd.instantiate(initial, Some(&image), &plan).unwrap();
         assert!(memfd.has_image());
         let slice = mmap.as_mut_slice();
         assert_eq!(&[1, 2, 3, 4], &slice[4096..4100]);
@@ -999,7 +1010,7 @@ mod test {
 
         // Re-instantiate make sure it preserves memory. Grow a bit and set data
         // beyond the initial size.
-        memfd.instantiate(initial, Some(&image), &style).unwrap();
+        memfd.instantiate(initial, Some(&image), &plan).unwrap();
         assert_eq!(&[1, 2, 3, 4], &slice[4096..4100]);
         memfd.set_heap_limit(initial * 2).unwrap();
         assert_eq!(&[0, 0], &slice[initial..initial + 2]);
@@ -1012,7 +1023,7 @@ mod test {
 
         // Instantiate again, and again memory beyond the initial size should
         // still be accessible. Grow into it again and make sure it works.
-        memfd.instantiate(initial, Some(&image), &style).unwrap();
+        memfd.instantiate(initial, Some(&image), &plan).unwrap();
         assert_eq!(&[0, 0], &slice[initial..initial + 2]);
         memfd.set_heap_limit(initial * 2).unwrap();
         assert_eq!(&[0, 0], &slice[initial..initial + 2]);
@@ -1021,7 +1032,7 @@ mod test {
         memfd.clear_and_remain_ready(0).unwrap();
 
         // Reset the image to none and double-check everything is back to zero
-        memfd.instantiate(64 << 10, None, &style).unwrap();
+        memfd.instantiate(64 << 10, None, &plan).unwrap();
         assert!(!memfd.has_image());
         assert_eq!(&[0, 0, 0, 0], &slice[4096..4100]);
         assert_eq!(&[0, 0], &slice[initial..initial + 2]);
diff --git a/crates/runtime/src/instance/allocator/pooling.rs b/crates/runtime/src/instance/allocator/pooling.rs
index c89d74906..73af4b04c 100644
--- a/crates/runtime/src/instance/allocator/pooling.rs
+++ b/crates/runtime/src/instance/allocator/pooling.rs
@@ -815,7 +815,7 @@ unsafe impl InstanceAllocator for PoolingInstanceAllocator {
             // the process to continue, because we never perform a
             // mmap that would leave an open space for someone
             // else to come in and map something.
-            slot.instantiate(initial_size as usize, image, &plan.style)?;
+            slot.instantiate(initial_size as usize, image, &plan)?;
 
             memories.push(Memory::new_static(
                 plan,
diff --git a/crates/runtime/src/memory.rs b/crates/runtime/src/memory.rs
index e3f3d2c56..609a760fc 100644
--- a/crates/runtime/src/memory.rs
+++ b/crates/runtime/src/memory.rs
@@ -248,7 +248,7 @@ impl MmapMemory {
                     minimum,
                     alloc_bytes + extra_to_reserve_on_growth,
                 );
-                slot.instantiate(minimum, Some(image), &plan.style)?;
+                slot.instantiate(minimum, Some(image), &plan)?;
                 // On drop, we will unmap our mmap'd range that this slot was
                 // mapped on top of, so there is no need for the slot to wipe
                 // it with an anonymous mapping first.


Test patch:
diff --git a/cranelift/filetests/filetests/egraph/algebraic.clif b/cranelift/filetests/filetests/egraph/algebraic.clif
index faae822fe..068733030 100644
--- a/cranelift/filetests/filetests/egraph/algebraic.clif
+++ b/cranelift/filetests/filetests/egraph/algebraic.clif
@@ -232,6 +232,16 @@ block0(v0: i32):
     ; check: return v0
 }
 
+function %imul_ineg_cancel(i32, i32) -> i32 {
+block0(v0: i32, v1: i32):
+    v2 = ineg v0
+    v3 = ineg v1
+    v4 = imul v2, v3
+    return v4
+    ; check: v5 = imul v0, v1
+    ; check: return v5
+}
+
 function %isub_self(i32) -> i32 {
 block0(v0: i32):
     v1 = isub v0, v0
@@ -418,45 +428,149 @@ block0(v1: i64, v2: i64):
 ; check: v4 = uextend.i64 v3
 ; check: return v4
 
-function %ult_zero_always_false(i64) -> i8 {
-block0(v1: i64):
-    v2 = iconst.i64 0
-    v3 = icmp ult v1, v2
-    return v3
+function %icmp_ult_0(i32) -> i8 {
+block0(v0: i32):
+    v1 = iconst.i32 0
+    v2 = icmp ult v0, v1
+    return v2
+    ; check: v3 = iconst.i8 0
+    ; check: return v3
 }
 
-; check: v4 = iconst.i8 0
-; check: return v4
+function %icmp_ule_0(i32) -> i8 {
+block0(v0: i32):
+    v1 = iconst.i32 0
+    v2 = icmp ule v0, v1
+    return v2
+    ; check: v3 = icmp eq v0, v1
+    ; check: return v3
+}
 
-function %ugt_zero_always_false(i64) -> i8 {
-block0(v1: i64):
-    v2 = iconst.i64 0
-    v3 = icmp ugt v2, v1
-    return v3
+function %icmp_ugt_0(i32) -> i8 {
+block0(v0: i32):
+    v1 = iconst.i32 0
+    v2 = icmp ugt v0, v1
+    return v2
+    ; check: v3 = icmp ne v0, v1
+    ; check: return v3
 }
 
-; check: v5 = iconst.i8 0
-; check: return v5
+function %icmp_uge_0(i32) -> i8 {
+block0(v0: i32):
+    v1 = iconst.i32 0
+    v2 = icmp uge v0, v1
+    return v2
+    ; check: v3 = iconst.i8 1
+    ; check: return v3
+}
 
-function %uge_zero_always_false(i64) -> i8 {
-block0(v1: i64):
-    v2 = iconst.i64 0
-    v3 = icmp uge v1, v2
-    return v3
+function %icmp_ult_umax(i32) -> i8 {
+block0(v0: i32):
+    v1 = iconst.i32 0xffff_ffff
+    v2 = icmp ult v0, v1
+    return v2
+    ; check: v3 = icmp ne v0, v1
+    ; check: return v3
 }
 
-; check: v4 = iconst.i8 1
-; check: return v4
+function %icmp_ule_umax(i32) -> i8 {
+block0(v0: i32):
+    v1 = iconst.i32 0xffff_ffff
+    v2 = icmp ule v0, v1
+    return v2
+    ; check: v3 = iconst.i8 1
+    ; check: return v3
+}
 
-function %ule_zero_always_false(i64) -> i8 {
-block0(v1: i64):
-    v2 = iconst.i64 0
-    v3 = icmp ule v2, v1
-    return v3
+function %icmp_ugt_umax(i32) -> i8 {
+block0(v0: i32):
+    v1 = iconst.i32 0xffff_ffff
+    v2 = icmp ugt v0, v1
+    return v2
+    ; check: v3 = iconst.i8 0
+    ; check: return v3
 }
 
-; check: v5 = iconst.i8 1
-; check: return v5
+function %icmp_uge_umax(i32) -> i8 {
+block0(v0: i32):
+    v1 = iconst.i32 0xffff_ffff
+    v2 = icmp uge v0, v1
+    return v2
+    ; check: v3 = icmp eq v0, v1
+    ; check: return v3
+}
+
+function %icmp_slt_smin(i32) -> i8 {
+block0(v0: i32):
+    v1 = iconst.i32 0x8000_0000
+    v2 = icmp slt v0, v1
+    return v2
+    ; check: v3 = iconst.i8 0
+    ; check: return v3
+}
+
+function %icmp_sle_smin(i32) -> i8 {
+block0(v0: i32):
+    v1 = iconst.i32 0x8000_0000
+    v2 = icmp sle v0, v1
+    return v2
+    ; check: v3 = icmp eq v0, v1
+    ; check: return v3
+}
+
+function %icmp_sgt_smin(i32) -> i8 {
+block0(v0: i32):
+    v1 = iconst.i32 0x8000_0000
+    v2 = icmp sgt v0, v1
+    return v2
+    ; check: v3 = icmp ne v0, v1
+    ; check: return v3
+}
+
+function %icmp_sge_smin(i32) -> i8 {
+block0(v0: i32):
+    v1 = iconst.i32 0x8000_0000
+    v2 = icmp sge v0, v1
+    return v2
+    ; check: v3 = iconst.i8 1
+    ; check: return v3
+}
+
+function %icmp_slt_smax(i32) -> i8 {
+block0(v0: i32):
+    v1 = iconst.i32 0x7FFF_FFFF
+    v2 = icmp slt v0, v1
+    return v2
+    ; check: v3 = icmp ne v0, v1
+    ; check: return v3
+}
+
+function %icmp_sle_smax(i32) -> i8 {
+block0(v0: i32):
+    v1 = iconst.i32 0x7FFF_FFFF
+    v2 = icmp sle v0, v1
+    return v2
+    ; check: v3 = iconst.i8 1
+    ; check: return v3
+}
+
+function %icmp_sgt_smax(i32) -> i8 {
+block0(v0: i32):
+    v1 = iconst.i32 0x7FFF_FFFF
+    v2 = icmp sgt v0, v1
+    return v2
+    ; check: v3 = iconst.i8 0
+    ; check: return v3
+}
+
+function %icmp_sge_smax(i32) -> i8 {
+block0(v0: i32):
+    v1 = iconst.i32 0x7FFF_FFFF
+    v2 = icmp sge v0, v1
+    return v2
+    ; check: v3 = icmp eq v0, v1
+    ; check: return v3
+}
 
 function %extend_always_above_zero(i32) -> i8 {
 block0(v1: i32):
diff --git a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat
index bc7276d3b..c00574e05 100644
--- a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat
+++ b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat
@@ -41,14 +41,13 @@
 
 ;; function u0:0:
 ;; block0:
-;;   mov w7, w0
-;;   ldr x8, [x2, #8]
-;;   sub x8, x8, #4
-;;   subs xzr, x7, x8
+;;   mov w6, w0
+;;   ldr x7, [x2, #8]
+;;   subs xzr, x6, x7
 ;;   b.hi label3 ; b label1
 ;; block1:
-;;   ldr x9, [x2]
-;;   str w1, [x9, w0, UXTW]
+;;   ldr x8, [x2]
+;;   str w1, [x8, w0, UXTW]
 ;;   b label2
 ;; block2:
 ;;   ret
@@ -57,14 +56,13 @@
 ;;
 ;; function u0:1:
 ;; block0:
-;;   mov w7, w0
-;;   ldr x8, [x1, #8]
-;;   sub x8, x8, #4
-;;   subs xzr, x7, x8
+;;   mov w6, w0
+;;   ldr x7, [x1, #8]
+;;   subs xzr, x6, x7
 ;;   b.hi label3 ; b label1
 ;; block1:
-;;   ldr x9, [x1]
-;;   ldr w0, [x9, w0, UXTW]
+;;   ldr x8, [x1]
+;;   ldr w0, [x8, w0, UXTW]
 ;;   b label2
 ;; block2:
 ;;   ret
diff --git a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat
index aa6cf755f..23715cf3c 100644
--- a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat
@@ -41,16 +41,14 @@
 
 ;; function u0:0:
 ;; block0:
-;;   mov w9, w0
-;;   ldr x10, [x2, #8]
-;;   movn x8, #4099
-;;   add x10, x10, x8
-;;   subs xzr, x9, x10
+;;   mov w7, w0
+;;   ldr x8, [x2, #8]
+;;   subs xzr, x7, x8
 ;;   b.hi label3 ; b label1
 ;; block1:
-;;   ldr x11, [x2]
-;;   add x11, x11, #4096
-;;   str w1, [x11, w0, UXTW]
+;;   ldr x9, [x2]
+;;   add x9, x9, #4096
+;;   str w1, [x9, w0, UXTW]
 ;;   b label2
 ;; block2:
 ;;   ret
@@ -59,16 +57,14 @@
 ;;
 ;; function u0:1:
 ;; block0:
-;;   mov w9, w0
-;;   ldr x10, [x1, #8]
-;;   movn x8, #4099
-;;   add x10, x10, x8
-;;   subs xzr, x9, x10
+;;   mov w7, w0
+;;   ldr x8, [x1, #8]
+;;   subs xzr, x7, x8
 ;;   b.hi label3 ; b label1
 ;; block1:
-;;   ldr x11, [x1]
-;;   add x10, x11, #4096
-;;   ldr w0, [x10, w0, UXTW]
+;;   ldr x9, [x1]
+;;   add x8, x9, #4096
+;;   ldr w0, [x8, w0, UXTW]
 ;;   b label2
 ;; block2:
 ;;   ret
diff --git a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat
index e1c02472d..57f0052f6 100644
--- a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat
@@ -41,18 +41,15 @@
 
 ;; function u0:0:
 ;; block0:
-;;   mov w10, w0
-;;   movn w9, #65531
-;;   adds x11, x10, x9
-;;   b.lo 8 ; udf
-;;   ldr x12, [x2, #8]
-;;   subs xzr, x11, x12
+;;   mov w8, w0
+;;   ldr x9, [x2, #8]
+;;   subs xzr, x8, x9
 ;;   b.hi label3 ; b label1
 ;; block1:
-;;   ldr x13, [x2]
-;;   movz x14, #65535, LSL #16
-;;   add x13, x14, x13
-;;   str w1, [x13, w0, UXTW]
+;;   ldr x10, [x2]
+;;   movz x11, #65535, LSL #16
+;;   add x10, x11, x10
+;;   str w1, [x10, w0, UXTW]
 ;;   b label2
 ;; block2:
 ;;   ret
@@ -61,18 +58,15 @@
 ;;
 ;; function u0:1:
 ;; block0:
-;;   mov w10, w0
-;;   movn w9, #65531
-;;   adds x11, x10, x9
-;;   b.lo 8 ; udf
-;;   ldr x12, [x1, #8]
-;;   subs xzr, x11, x12
+;;   mov w8, w0
+;;   ldr x9, [x1, #8]
+;;   subs xzr, x8, x9
 ;;   b.hi label3 ; b label1
 ;; block1:
-;;   ldr x13, [x1]
-;;   movz x12, #65535, LSL #16
-;;   add x12, x12, x13
-;;   ldr w0, [x12, w0, UXTW]
+;;   ldr x10, [x1]
+;;   movz x9, #65535, LSL #16
+;;   add x9, x9, x10
+;;   ldr w0, [x9, w0, UXTW]
 ;;   b label2
 ;; block2:
 ;;   ret
diff --git a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat
index 86e692888..7310b1078 100644
--- a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat
@@ -41,16 +41,14 @@
 
 ;; function u0:0:
 ;; block0:
-;;   mov w9, w0
-;;   ldr x10, [x2, #8]
-;;   movn x8, #4096
-;;   add x10, x10, x8
-;;   subs xzr, x9, x10
+;;   mov w7, w0
+;;   ldr x8, [x2, #8]
+;;   subs xzr, x7, x8
 ;;   b.hi label3 ; b label1
 ;; block1:
-;;   ldr x11, [x2]
-;;   add x11, x11, #4096
-;;   strb w1, [x11, w0, UXTW]
+;;   ldr x9, [x2]
+;;   add x9, x9, #4096
+;;   strb w1, [x9, w0, UXTW]
 ;;   b label2
 ;; block2:
 ;;   ret
@@ -59,16 +57,14 @@
 ;;
 ;; function u0:1:
 ;; block0:
-;;   mov w9, w0
-;;   ldr x10, [x1, #8]
-;;   movn x8, #4096
-;;   add x10, x10, x8
-;;   subs xzr, x9, x10
+;;   mov w7, w0
+;;   ldr x8, [x1, #8]
+;;   subs xzr, x7, x8
 ;;   b.hi label3 ; b label1
 ;; block1:
-;;   ldr x11, [x1]
-;;   add x10, x11, #4096
-;;   ldrb w0, [x10, w0, UXTW]
+;;   ldr x9, [x1]
+;;   add x8, x9, #4096
+;;   ldrb w0, [x8, w0, UXTW]
 ;;   b label2
 ;; block2:
 ;;   ret
diff --git a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat
index 48dd89410..ea43a47c1 100644
--- a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat
@@ -41,18 +41,15 @@
 
 ;; function u0:0:
 ;; block0:
-;;   mov w10, w0
-;;   movn w9, #65534
-;;   adds x11, x10, x9
-;;   b.lo 8 ; udf
-;;   ldr x12, [x2, #8]
-;;   subs xzr, x11, x12
+;;   mov w8, w0
+;;   ldr x9, [x2, #8]
+;;   subs xzr, x8, x9
 ;;   b.hi label3 ; b label1
 ;; block1:
-;;   ldr x13, [x2]
-;;   movz x14, #65535, LSL #16
-;;   add x13, x14, x13
-;;   strb w1, [x13, w0, UXTW]
+;;   ldr x10, [x2]
+;;   movz x11, #65535, LSL #16
+;;   add x10, x11, x10
+;;   strb w1, [x10, w0, UXTW]
 ;;   b label2
 ;; block2:
 ;;   ret
@@ -61,18 +58,15 @@
 ;;
 ;; function u0:1:
 ;; block0:
-;;   mov w10, w0
-;;   movn w9, #65534
-;;   adds x11, x10, x9
-;;   b.lo 8 ; udf
-;;   ldr x12, [x1, #8]
-;;   subs xzr, x11, x12
+;;   mov w8, w0
+;;   ldr x9, [x1, #8]
+;;   subs xzr, x8, x9
 ;;   b.hi label3 ; b label1
 ;; block1:
-;;   ldr x13, [x1]
-;;   movz x12, #65535, LSL #16
-;;   add x12, x12, x13
-;;   ldrb w0, [x12, w0, UXTW]
+;;   ldr x10, [x1]
+;;   movz x9, #65535, LSL #16
+;;   add x9, x9, x10
+;;   ldrb w0, [x9, w0, UXTW]
 ;;   b label2
 ;; block2:
 ;;   ret
diff --git a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat
index f2792b70e..9add0d45d 100644
--- a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat
+++ b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat
@@ -41,32 +41,30 @@
 
 ;; function u0:0:
 ;; block0:
-;;   mov w10, w0
-;;   ldr x11, [x2, #8]
-;;   sub x11, x11, #4
-;;   ldr x12, [x2]
-;;   add x12, x12, x0, UXTW
-;;   movz x9, #0
-;;   subs xzr, x10, x11
-;;   csel x12, x9, x12, hi
+;;   mov w9, w0
+;;   ldr x10, [x2, #8]
+;;   ldr x11, [x2]
+;;   add x11, x11, x0, UXTW
+;;   movz x8, #0
+;;   subs xzr, x9, x10
+;;   csel x11, x8, x11, hi
 ;;   csdb
-;;   str w1, [x12]
+;;   str w1, [x11]
 ;;   b label1
 ;; block1:
 ;;   ret
 ;;
 ;; function u0:1:
 ;; block0:
-;;   mov w10, w0
-;;   ldr x11, [x1, #8]
-;;   sub x11, x11, #4
-;;   ldr x12, [x1]
-;;   add x12, x12, x0, UXTW
-;;   movz x9, #0
-;;   subs xzr, x10, x11
-;;   csel x12, x9, x12, hi
+;;   mov w9, w0
+;;   ldr x10, [x1, #8]
+;;   ldr x11, [x1]
+;;   add x11, x11, x0, UXTW
+;;   movz x8, #0
+;;   subs xzr, x9, x10
+;;   csel x11, x8, x11, hi
 ;;   csdb
-;;   ldr w0, [x12]
+;;   ldr w0, [x11]
 ;;   b label1
 ;; block1:
-;;   ret
\ No newline at end of file
+;;   ret
diff --git a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat
index de731eb7e..22bf50fcf 100644
--- a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat
@@ -41,36 +41,32 @@
 
 ;; function u0:0:
 ;; block0:
-;;   mov w12, w0
-;;   ldr x13, [x2, #8]
-;;   movn x11, #4099
-;;   add x13, x13, x11
-;;   ldr x14, [x2]
-;;   add x14, x14, x0, UXTW
-;;   add x14, x14, #4096
-;;   movz x11, #0
-;;   subs xzr, x12, x13
-;;   csel x14, x11, x14, hi
+;;   mov w10, w0
+;;   ldr x11, [x2, #8]
+;;   ldr x12, [x2]
+;;   add x12, x12, x0, UXTW
+;;   add x12, x12, #4096
+;;   movz x9, #0
+;;   subs xzr, x10, x11
+;;   csel x12, x9, x12, hi
 ;;   csdb
-;;   str w1, [x14]
+;;   str w1, [x12]
 ;;   b label1
 ;; block1:
 ;;   ret
 ;;
 ;; function u0:1:
 ;; block0:
-;;   mov w12, w0
-;;   ldr x13, [x1, #8]
-;;   movn x11, #4099
-;;   add x13, x13, x11
-;;   ldr x14, [x1]
-;;   add x14, x14, x0, UXTW
-;;   add x14, x14, #4096
-;;   movz x11, #0
-;;   subs xzr, x12, x13
-;;   csel x14, x11, x14, hi
+;;   mov w10, w0
+;;   ldr x11, [x1, #8]
+;;   ldr x12, [x1]
+;;   add x12, x12, x0, UXTW
+;;   add x12, x12, #4096
+;;   movz x9, #0
+;;   subs xzr, x10, x11
+;;   csel x12, x9, x12, hi
 ;;   csdb
-;;   ldr w0, [x14]
+;;   ldr w0, [x12]
 ;;   b label1
 ;; block1:
-;;   ret
\ No newline at end of file
+;;   ret
diff --git a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat
index ecb66f9d8..14a401df7 100644
--- a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat
@@ -41,40 +41,34 @@
 
 ;; function u0:0:
 ;; block0:
-;;   mov w13, w0
-;;   movn w12, #65531
-;;   adds x14, x13, x12
-;;   b.lo 8 ; udf
-;;   ldr x15, [x2, #8]
-;;   ldr x2, [x2]
-;;   add x0, x2, x0, UXTW
-;;   movz x13, #65535, LSL #16
-;;   add x0, x0, x13
-;;   movz x13, #0
-;;   subs xzr, x14, x15
-;;   csel x0, x13, x0, hi
+;;   mov w11, w0
+;;   ldr x12, [x2, #8]
+;;   ldr x13, [x2]
+;;   add x13, x13, x0, UXTW
+;;   movz x10, #65535, LSL #16
+;;   add x13, x13, x10
+;;   movz x10, #0
+;;   subs xzr, x11, x12
+;;   csel x13, x10, x13, hi
 ;;   csdb
-;;   str w1, [x0]
+;;   str w1, [x13]
 ;;   b label1
 ;; block1:
 ;;   ret
 ;;
 ;; function u0:1:
 ;; block0:
-;;   mov w13, w0
-;;   movn w12, #65531
-;;   adds x14, x13, x12
-;;   b.lo 8 ; udf
-;;   ldr x15, [x1, #8]
-;;   ldr x1, [x1]
-;;   add x0, x1, x0, UXTW
-;;   movz x13, #65535, LSL #16
-;;   add x0, x0, x13
-;;   movz x13, #0
-;;   subs xzr, x14, x15
-;;   csel x0, x13, x0, hi
+;;   mov w11, w0
+;;   ldr x12, [x1, #8]
+;;   ldr x13, [x1]
+;;   add x13, x13, x0, UXTW
+;;   movz x10, #65535, LSL #16
+;;   add x13, x13, x10
+;;   movz x10, #0
+;;   subs xzr, x11, x12
+;;   csel x13, x10, x13, hi
 ;;   csdb
-;;   ldr w0, [x0]
+;;   ldr w0, [x13]
 ;;   b label1
 ;; block1:
-;;   ret
\ No newline at end of file
+;;   ret
diff --git a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat
index 903c28106..d9ea12739 100644
--- a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat
@@ -41,36 +41,32 @@
 
 ;; function u0:0:
 ;; block0:
-;;   mov w12, w0
-;;   ldr x13, [x2, #8]
-;;   movn x11, #4096
-;;   add x13, x13, x11
-;;   ldr x14, [x2]
-;;   add x14, x14, x0, UXTW
-;;   add x14, x14, #4096
-;;   movz x11, #0
-;;   subs xzr, x12, x13
-;;   csel x14, x11, x14, hi
+;;   mov w10, w0
+;;   ldr x11, [x2, #8]
+;;   ldr x12, [x2]
+;;   add x12, x12, x0, UXTW
+;;   add x12, x12, #4096
+;;   movz x9, #0
+;;   subs xzr, x10, x11
+;;   csel x12, x9, x12, hi
 ;;   csdb
-;;   strb w1, [x14]
+;;   strb w1, [x12]
 ;;   b label1
 ;; block1:
 ;;   ret
 ;;
 ;; function u0:1:
 ;; block0:
-;;   mov w12, w0
-;;   ldr x13, [x1, #8]
-;;   movn x11, #4096
-;;   add x13, x13, x11
-;;   ldr x14, [x1]
-;;   add x14, x14, x0, UXTW
-;;   add x14, x14, #4096
-;;   movz x11, #0
-;;   subs xzr, x12, x13
-;;   csel x14, x11, x14, hi
+;;   mov w10, w0
+;;   ldr x11, [x1, #8]
+;;   ldr x12, [x1]
+;;   add x12, x12, x0, UXTW
+;;   add x12, x12, #4096
+;;   movz x9, #0
+;;   subs xzr, x10, x11
+;;   csel x12, x9, x12, hi
 ;;   csdb
-;;   ldrb w0, [x14]
+;;   ldrb w0, [x12]
 ;;   b label1
 ;; block1:
-;;   ret
\ No newline at end of file
+;;   ret
diff --git a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat
index 172db1ef5..e8a0c7635 100644
--- a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat
@@ -41,40 +41,34 @@
 
 ;; function u0:0:
 ;; block0:
-;;   mov w13, w0
-;;   movn w12, #65534
-;;   adds x14, x13, x12
-;;   b.lo 8 ; udf
-;;   ldr x15, [x2, #8]
-;;   ldr x2, [x2]
-;;   add x0, x2, x0, UXTW
-;;   movz x13, #65535, LSL #16
-;;   add x0, x0, x13
-;;   movz x13, #0
-;;   subs xzr, x14, x15
-;;   csel x0, x13, x0, hi
+;;   mov w11, w0
+;;   ldr x12, [x2, #8]
+;;   ldr x13, [x2]
+;;   add x13, x13, x0, UXTW
+;;   movz x10, #65535, LSL #16
+;;   add x13, x13, x10
+;;   movz x10, #0
+;;   subs xzr, x11, x12
+;;   csel x13, x10, x13, hi
 ;;   csdb
-;;   strb w1, [x0]
+;;   strb w1, [x13]
 ;;   b label1
 ;; block1:
 ;;   ret
 ;;
 ;; function u0:1:
 ;; block0:
-;;   mov w13, w0
-;;   movn w12, #65534
-;;   adds x14, x13, x12
-;;   b.lo 8 ; udf
-;;   ldr x15, [x1, #8]
-;;   ldr x1, [x1]
-;;   add x0, x1, x0, UXTW
-;;   movz x13, #65535, LSL #16
-;;   add x0, x0, x13
-;;   movz x13, #0
-;;   subs xzr, x14, x15
-;;   csel x0, x13, x0, hi
+;;   mov w11, w0
+;;   ldr x12, [x1, #8]
+;;   ldr x13, [x1]
+;;   add x13, x13, x0, UXTW
+;;   movz x10, #65535, LSL #16
+;;   add x13, x13, x10
+;;   movz x10, #0
+;;   subs xzr, x11, x12
+;;   csel x13, x10, x13, hi
 ;;   csdb
-;;   ldrb w0, [x0]
+;;   ldrb w0, [x13]
 ;;   b label1
 ;; block1:
-;;   ret
\ No newline at end of file
+;;   ret
diff --git a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat
index e636749fc..bc5472cdd 100644
--- a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat
+++ b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat
@@ -41,13 +41,12 @@
 
 ;; function u0:0:
 ;; block0:
-;;   ldr x6, [x2, #8]
-;;   sub x6, x6, #4
-;;   subs xzr, x0, x6
+;;   ldr x5, [x2, #8]
+;;   subs xzr, x0, x5
 ;;   b.hi label3 ; b label1
 ;; block1:
-;;   ldr x8, [x2]
-;;   str w1, [x8, x0]
+;;   ldr x7, [x2]
+;;   str w1, [x7, x0]
 ;;   b label2
 ;; block2:
 ;;   ret
@@ -56,13 +55,12 @@
 ;;
 ;; function u0:1:
 ;; block0:
-;;   ldr x6, [x1, #8]
-;;   sub x6, x6, #4
-;;   subs xzr, x0, x6
+;;   ldr x5, [x1, #8]
+;;   subs xzr, x0, x5
 ;;   b.hi label3 ; b label1
 ;; block1:
-;;   ldr x8, [x1]
-;;   ldr w0, [x8, x0]
+;;   ldr x7, [x1]
+;;   ldr w0, [x7, x0]
 ;;   b label2
 ;; block2:
 ;;   ret
diff --git a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat
index d3eb77ac1..4a7110ba3 100644
--- a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat
@@ -41,15 +41,13 @@
 
 ;; function u0:0:
 ;; block0:
-;;   ldr x8, [x2, #8]
-;;   movn x7, #4099
-;;   add x9, x8, x7
-;;   subs xzr, x0, x9
+;;   ldr x6, [x2, #8]
+;;   subs xzr, x0, x6
 ;;   b.hi label3 ; b label1
 ;; block1:
-;;   ldr x10, [x2]
-;;   add x11, x0, #4096
-;;   str w1, [x11, x10]
+;;   ldr x8, [x2]
+;;   add x9, x0, #4096
+;;   str w1, [x9, x8]
 ;;   b label2
 ;; block2:
 ;;   ret
@@ -58,15 +56,13 @@
 ;;
 ;; function u0:1:
 ;; block0:
-;;   ldr x8, [x1, #8]
-;;   movn x7, #4099
-;;   add x9, x8, x7
-;;   subs xzr, x0, x9
+;;   ldr x6, [x1, #8]
+;;   subs xzr, x0, x6
 ;;   b.hi label3 ; b label1
 ;; block1:
-;;   ldr x10, [x1]
-;;   add x9, x0, #4096
-;;   ldr w0, [x9, x10]
+;;   ldr x8, [x1]
+;;   add x7, x0, #4096
+;;   ldr w0, [x7, x8]
 ;;   b label2
 ;; block2:
 ;;   ret
diff --git a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat
index 5a733067a..fa61559c5 100644
--- a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat
@@ -41,17 +41,14 @@
 
 ;; function u0:0:
 ;; block0:
-;;   movn w8, #65531
-;;   adds x10, x0, x8
-;;   b.lo 8 ; udf
-;;   ldr x11, [x2, #8]
-;;   subs xzr, x10, x11
+;;   ldr x7, [x2, #8]
+;;   subs xzr, x0, x7
 ;;   b.hi label3 ; b label1
 ;; block1:
-;;   ldr x12, [x2]
-;;   movz x13, #65535, LSL #16
-;;   add x13, x13, x0
-;;   str w1, [x13, x12]
+;;   ldr x9, [x2]
+;;   movz x10, #65535, LSL #16
+;;   add x10, x10, x0
+;;   str w1, [x10, x9]
 ;;   b label2
 ;; block2:
 ;;   ret
@@ -60,17 +57,14 @@
 ;;
 ;; function u0:1:
 ;; block0:
-;;   movn w8, #65531
-;;   adds x10, x0, x8
-;;   b.lo 8 ; udf
-;;   ldr x11, [x1, #8]
-;;   subs xzr, x10, x11
+;;   ldr x7, [x1, #8]
+;;   subs xzr, x0, x7
 ;;   b.hi label3 ; b label1
 ;; block1:
-;;   ldr x12, [x1]
-;;   movz x11, #65535, LSL #16
-;;   add x11, x11, x0
-;;   ldr w0, [x11, x12]
+;;   ldr x9, [x1]
+;;   movz x8, #65535, LSL #16
+;;   add x8, x8, x0
+;;   ldr w0, [x8, x9]
 ;;   b label2
 ;; block2:
 ;;   ret
diff --git a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat
index a7aa1fed1..a36c08177 100644
--- a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat
@@ -41,15 +41,13 @@
 
 ;; function u0:0:
 ;; block0:
-;;   ldr x8, [x2, #8]
-;;   movn x7, #4096
-;;   add x9, x8, x7
-;;   subs xzr, x0, x9
+;;   ldr x6, [x2, #8]
+;;   subs xzr, x0, x6
 ;;   b.hi label3 ; b label1
 ;; block1:
-;;   ldr x10, [x2]
-;;   add x11, x0, #4096
-;;   strb w1, [x11, x10]
+;;   ldr x8, [x2]
+;;   add x9, x0, #4096
+;;   strb w1, [x9, x8]
 ;;   b label2
 ;; block2:
 ;;   ret
@@ -58,15 +56,13 @@
 ;;
 ;; function u0:1:
 ;; block0:
-;;   ldr x8, [x1, #8]
-;;   movn x7, #4096
-;;   add x9, x8, x7
-;;   subs xzr, x0, x9
+;;   ldr x6, [x1, #8]
+;;   subs xzr, x0, x6
 ;;   b.hi label3 ; b label1
 ;; block1:
-;;   ldr x10, [x1]
-;;   add x9, x0, #4096
-;;   ldrb w0, [x9, x10]
+;;   ldr x8, [x1]
+;;   add x7, x0, #4096
+;;   ldrb w0, [x7, x8]
 ;;   b label2
 ;; block2:
 ;;   ret
diff --git a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat
index 313917c05..ff9cb1f5c 100644
--- a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat
@@ -41,17 +41,14 @@
 
 ;; function u0:0:
 ;; block0:
-;;   movn w8, #65534
-;;   adds x10, x0, x8
-;;   b.lo 8 ; udf
-;;   ldr x11, [x2, #8]
-;;   subs xzr, x10, x11
+;;   ldr x7, [x2, #8]
+;;   subs xzr, x0, x7
 ;;   b.hi label3 ; b label1
 ;; block1:
-;;   ldr x12, [x2]
-;;   movz x13, #65535, LSL #16
-;;   add x13, x13, x0
-;;   strb w1, [x13, x12]
+;;   ldr x9, [x2]
+;;   movz x10, #65535, LSL #16
+;;   add x10, x10, x0
+;;   strb w1, [x10, x9]
 ;;   b label2
 ;; block2:
 ;;   ret
@@ -60,17 +57,14 @@
 ;;
 ;; function u0:1:
 ;; block0:
-;;   movn w8, #65534
-;;   adds x10, x0, x8
-;;   b.lo 8 ; udf
-;;   ldr x11, [x1, #8]
-;;   subs xzr, x10, x11
+;;   ldr x7, [x1, #8]
+;;   subs xzr, x0, x7
 ;;   b.hi label3 ; b label1
 ;; block1:
-;;   ldr x12, [x1]
-;;   movz x11, #65535, LSL #16
-;;   add x11, x11, x0
-;;   ldrb w0, [x11, x12]
+;;   ldr x9, [x1]
+;;   movz x8, #65535, LSL #16
+;;   add x8, x8, x0
+;;   ldrb w0, [x8, x9]
 ;;   b label2
 ;; block2:
 ;;   ret
diff --git a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat
index c07748333..b5de11150 100644
--- a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat
+++ b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat
@@ -41,30 +41,28 @@
 
 ;; function u0:0:
 ;; block0:
-;;   ldr x9, [x2, #8]
-;;   sub x9, x9, #4
-;;   ldr x10, [x2]
-;;   add x10, x10, x0
-;;   movz x8, #0
-;;   subs xzr, x0, x9
-;;   csel x11, x8, x10, hi
+;;   ldr x8, [x2, #8]
+;;   ldr x9, [x2]
+;;   add x9, x9, x0
+;;   movz x7, #0
+;;   subs xzr, x0, x8
+;;   csel x10, x7, x9, hi
 ;;   csdb
-;;   str w1, [x11]
+;;   str w1, [x10]
 ;;   b label1
 ;; block1:
 ;;   ret
 ;;
 ;; function u0:1:
 ;; block0:
-;;   ldr x9, [x1, #8]
-;;   sub x9, x9, #4
-;;   ldr x10, [x1]
-;;   add x10, x10, x0
-;;   movz x8, #0
-;;   subs xzr, x0, x9
-;;   csel x11, x8, x10, hi
+;;   ldr x8, [x1, #8]
+;;   ldr x9, [x1]
+;;   add x9, x9, x0
+;;   movz x7, #0
+;;   subs xzr, x0, x8
+;;   csel x10, x7, x9, hi
 ;;   csdb
-;;   ldr w0, [x11]
+;;   ldr w0, [x10]
 ;;   b label1
 ;; block1:
-;;   ret
\ No newline at end of file
+;;   ret
diff --git a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat
index 06af27033..269c3c11e 100644
--- a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat
@@ -41,34 +41,30 @@
 
 ;; function u0:0:
 ;; block0:
-;;   ldr x11, [x2, #8]
-;;   movn x10, #4099
-;;   add x12, x11, x10
-;;   ldr x11, [x2]
-;;   add x11, x11, x0
-;;   add x11, x11, #4096
-;;   movz x10, #0
-;;   subs xzr, x0, x12
-;;   csel x13, x10, x11, hi
+;;   ldr x9, [x2, #8]
+;;   ldr x10, [x2]
+;;   add x10, x10, x0
+;;   add x10, x10, #4096
+;;   movz x8, #0
+;;   subs xzr, x0, x9
+;;   csel x11, x8, x10, hi
 ;;   csdb
-;;   str w1, [x13]
+;;   str w1, [x11]
 ;;   b label1
 ;; block1:
 ;;   ret
 ;;
 ;; function u0:1:
 ;; block0:
-;;   ldr x11, [x1, #8]
-;;   movn x10, #4099
-;;   add x12, x11, x10
-;;   ldr x11, [x1]
-;;   add x11, x11, x0
-;;   add x11, x11, #4096
-;;   movz x10, #0
-;;   subs xzr, x0, x12
-;;   csel x13, x10, x11, hi
+;;   ldr x9, [x1, #8]
+;;   ldr x10, [x1]
+;;   add x10, x10, x0
+;;   add x10, x10, #4096
+;;   movz x8, #0
+;;   subs xzr, x0, x9
+;;   csel x11, x8, x10, hi
 ;;   csdb
-;;   ldr w0, [x13]
+;;   ldr w0, [x11]
 ;;   b label1
 ;; block1:
-;;   ret
\ No newline at end of file
+;;   ret
diff --git a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat
index 535faa0c1..6d594d804 100644
--- a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat
@@ -41,38 +41,32 @@
 
 ;; function u0:0:
 ;; block0:
-;;   movn w11, #65531
-;;   adds x13, x0, x11
-;;   b.lo 8 ; udf
-;;   ldr x14, [x2, #8]
-;;   ldr x15, [x2]
-;;   add x15, x15, x0
-;;   movz x12, #65535, LSL #16
-;;   add x15, x15, x12
-;;   movz x12, #0
-;;   subs xzr, x13, x14
-;;   csel x15, x12, x15, hi
+;;   ldr x10, [x2, #8]
+;;   ldr x11, [x2]
+;;   add x11, x11, x0
+;;   movz x9, #65535, LSL #16
+;;   add x11, x11, x9
+;;   movz x9, #0
+;;   subs xzr, x0, x10
+;;   csel x12, x9, x11, hi
 ;;   csdb
-;;   str w1, [x15]
+;;   str w1, [x12]
 ;;   b label1
 ;; block1:
 ;;   ret
 ;;
 ;; function u0:1:
 ;; block0:
-;;   movn w11, #65531
-;;   adds x13, x0, x11
-;;   b.lo 8 ; udf
-;;   ldr x14, [x1, #8]
-;;   ldr x15, [x1]
-;;   add x15, x15, x0
-;;   movz x12, #65535, LSL #16
-;;   add x15, x15, x12
-;;   movz x12, #0
-;;   subs xzr, x13, x14
-;;   csel x15, x12, x15, hi
+;;   ldr x10, [x1, #8]
+;;   ldr x11, [x1]
+;;   add x11, x11, x0
+;;   movz x9, #65535, LSL #16
+;;   add x11, x11, x9
+;;   movz x9, #0
+;;   subs xzr, x0, x10
+;;   csel x12, x9, x11, hi
 ;;   csdb
-;;   ldr w0, [x15]
+;;   ldr w0, [x12]
 ;;   b label1
 ;; block1:
-;;   ret
\ No newline at end of file
+;;   ret
diff --git a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat
index a324ddc25..7b02fe28a 100644
--- a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat
@@ -41,34 +41,30 @@
 
 ;; function u0:0:
 ;; block0:
-;;   ldr x11, [x2, #8]
-;;   movn x10, #4096
-;;   add x12, x11, x10
-;;   ldr x11, [x2]
-;;   add x11, x11, x0
-;;   add x11, x11, #4096
-;;   movz x10, #0
-;;   subs xzr, x0, x12
-;;   csel x13, x10, x11, hi
+;;   ldr x9, [x2, #8]
+;;   ldr x10, [x2]
+;;   add x10, x10, x0
+;;   add x10, x10, #4096
+;;   movz x8, #0
+;;   subs xzr, x0, x9
+;;   csel x11, x8, x10, hi
 ;;   csdb
-;;   strb w1, [x13]
+;;   strb w1, [x11]
 ;;   b label1
 ;; block1:
 ;;   ret
 ;;
 ;; function u0:1:
 ;; block0:
-;;   ldr x11, [x1, #8]
-;;   movn x10, #4096
-;;   add x12, x11, x10
-;;   ldr x11, [x1]
-;;   add x11, x11, x0
-;;   add x11, x11, #4096
-;;   movz x10, #0
-;;   subs xzr, x0, x12
-;;   csel x13, x10, x11, hi
+;;   ldr x9, [x1, #8]
+;;   ldr x10, [x1]
+;;   add x10, x10, x0
+;;   add x10, x10, #4096
+;;   movz x8, #0
+;;   subs xzr, x0, x9
+;;   csel x11, x8, x10, hi
 ;;   csdb
-;;   ldrb w0, [x13]
+;;   ldrb w0, [x11]
 ;;   b label1
 ;; block1:
-;;   ret
\ No newline at end of file
+;;   ret
diff --git a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat
index e5d4ccf58..1ad2a90d2 100644
--- a/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/isa/aarch64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat
@@ -41,38 +41,32 @@
 
 ;; function u0:0:
 ;; block0:
-;;   movn w11, #65534
-;;   adds x13, x0, x11
-;;   b.lo 8 ; udf
-;;   ldr x14, [x2, #8]
-;;   ldr x15, [x2]
-;;   add x15, x15, x0
-;;   movz x12, #65535, LSL #16
-;;   add x15, x15, x12
-;;   movz x12, #0
-;;   subs xzr, x13, x14
-;;   csel x15, x12, x15, hi
+;;   ldr x10, [x2, #8]
+;;   ldr x11, [x2]
+;;   add x11, x11, x0
+;;   movz x9, #65535, LSL #16
+;;   add x11, x11, x9
+;;   movz x9, #0
+;;   subs xzr, x0, x10
+;;   csel x12, x9, x11, hi
 ;;   csdb
-;;   strb w1, [x15]
+;;   strb w1, [x12]
 ;;   b label1
 ;; block1:
 ;;   ret
 ;;
 ;; function u0:1:
 ;; block0:
-;;   movn w11, #65534
-;;   adds x13, x0, x11
-;;   b.lo 8 ; udf
-;;   ldr x14, [x1, #8]
-;;   ldr x15, [x1]
-;;   add x15, x15, x0
-;;   movz x12, #65535, LSL #16
-;;   add x15, x15, x12
-;;   movz x12, #0
-;;   subs xzr, x13, x14
-;;   csel x15, x12, x15, hi
+;;   ldr x10, [x1, #8]
+;;   ldr x11, [x1]
+;;   add x11, x11, x0
+;;   movz x9, #65535, LSL #16
+;;   add x11, x11, x9
+;;   movz x9, #0
+;;   subs xzr, x0, x10
+;;   csel x12, x9, x11, hi
 ;;   csdb
-;;   ldrb w0, [x15]
+;;   ldrb w0, [x12]
 ;;   b label1
 ;; block1:
-;;   ret
\ No newline at end of file
+;;   ret
diff --git a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat
index bc4f4c544..40dd0f89b 100644
--- a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat
+++ b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat
@@ -41,16 +41,15 @@
 
 ;; function u0:0:
 ;; block0:
-;;   slli a6,a0,32
-;;   srli t3,a6,32
-;;   ld a7,8(a2)
-;;   addi a7,a7,-4
-;;   ugt a7,t3,a7##ty=i64
-;;   bne a7,zero,taken(label3),not_taken(label1)
+;;   slli a5,a0,32
+;;   srli a7,a5,32
+;;   ld a6,8(a2)
+;;   ugt a6,a7,a6##ty=i64
+;;   bne a6,zero,taken(label3),not_taken(label1)
 ;; block1:
-;;   ld t4,0(a2)
-;;   add t3,t4,t3
-;;   sw a1,0(t3)
+;;   ld t3,0(a2)
+;;   add a7,t3,a7
+;;   sw a1,0(a7)
 ;;   j label2
 ;; block2:
 ;;   ret
@@ -59,16 +58,15 @@
 ;;
 ;; function u0:1:
 ;; block0:
-;;   slli a6,a0,32
-;;   srli t3,a6,32
-;;   ld a7,8(a1)
-;;   addi a7,a7,-4
-;;   ugt a7,t3,a7##ty=i64
-;;   bne a7,zero,taken(label3),not_taken(label1)
+;;   slli a5,a0,32
+;;   srli a7,a5,32
+;;   ld a6,8(a1)
+;;   ugt a6,a7,a6##ty=i64
+;;   bne a6,zero,taken(label3),not_taken(label1)
 ;; block1:
-;;   ld t4,0(a1)
-;;   add t3,t4,t3
-;;   lw a0,0(t3)
+;;   ld t3,0(a1)
+;;   add a7,t3,a7
+;;   lw a0,0(a7)
 ;;   j label2
 ;; block2:
 ;;   ret
diff --git a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat
index 90c3d04a3..5b6792543 100644
--- a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat
@@ -41,20 +41,17 @@
 
 ;; function u0:0:
 ;; block0:
-;;   slli t0,a0,32
-;;   srli t2,t0,32
-;;   ld t1,8(a2)
-;;   lui t0,1048575
-;;   addi t0,t0,4092
-;;   add a0,t1,t0
-;;   ugt t1,t2,a0##ty=i64
-;;   bne t1,zero,taken(label3),not_taken(label1)
+;;   slli a7,a0,32
+;;   srli t4,a7,32
+;;   ld t3,8(a2)
+;;   ugt t3,t4,t3##ty=i64
+;;   bne t3,zero,taken(label3),not_taken(label1)
 ;; block1:
-;;   ld a0,0(a2)
-;;   add t2,a0,t2
-;;   lui t1,1
-;;   add a0,t2,t1
-;;   sw a1,0(a0)
+;;   ld t0,0(a2)
+;;   add t4,t0,t4
+;;   lui t3,1
+;;   add t0,t4,t3
+;;   sw a1,0(t0)
 ;;   j label2
 ;; block2:
 ;;   ret
@@ -63,20 +60,17 @@
 ;;
 ;; function u0:1:
 ;; block0:
-;;   slli t0,a0,32
-;;   srli t2,t0,32
-;;   ld t1,8(a1)
-;;   lui t0,1048575
-;;   addi t0,t0,4092
-;;   add a0,t1,t0
-;;   ugt t1,t2,a0##ty=i64
-;;   bne t1,zero,taken(label3),not_taken(label1)
+;;   slli a7,a0,32
+;;   srli t4,a7,32
+;;   ld t3,8(a1)
+;;   ugt t3,t4,t3##ty=i64
+;;   bne t3,zero,taken(label3),not_taken(label1)
 ;; block1:
-;;   ld a0,0(a1)
-;;   add t2,a0,t2
-;;   lui t1,1
-;;   add a0,t2,t1
-;;   lw a0,0(a0)
+;;   ld t0,0(a1)
+;;   add t4,t0,t4
+;;   lui t3,1
+;;   add t0,t4,t3
+;;   lw a0,0(t0)
 ;;   j label2
 ;; block2:
 ;;   ret
diff --git a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat
index e388d02d7..945c90f8c 100644
--- a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat
@@ -41,21 +41,17 @@
 
 ;; function u0:0:
 ;; block0:
-;;   slli t0,a0,32
-;;   srli t2,t0,32
-;;   auipc t4,0; ld t4,12(t4); j 12; .8byte 0xffff0004
-;;   add t1,t2,t4
-;;   ult a0,t1,t2##ty=i64
-;;   trap_if a0,heap_oob
-;;   ld a0,8(a2)
-;;   ugt a0,t1,a0##ty=i64
-;;   bne a0,zero,taken(label3),not_taken(label1)
+;;   slli a7,a0,32
+;;   srli t4,a7,32
+;;   ld t3,8(a2)
+;;   ugt t3,t4,t3##ty=i64
+;;   bne t3,zero,taken(label3),not_taken(label1)
 ;; block1:
-;;   ld a0,0(a2)
-;;   add a0,a0,t2
-;;   auipc t2,0; ld t2,12(t2); j 12; .8byte 0xffff0000
-;;   add a2,a0,t2
-;;   sw a1,0(a2)
+;;   ld t0,0(a2)
+;;   add t4,t0,t4
+;;   auipc t3,0; ld t3,12(t3); j 12; .8byte 0xffff0000
+;;   add t0,t4,t3
+;;   sw a1,0(t0)
 ;;   j label2
 ;; block2:
 ;;   ret
@@ -64,21 +60,17 @@
 ;;
 ;; function u0:1:
 ;; block0:
-;;   slli t0,a0,32
-;;   srli t2,t0,32
-;;   auipc t4,0; ld t4,12(t4); j 12; .8byte 0xffff0004
-;;   add t1,t2,t4
-;;   ult a0,t1,t2##ty=i64
-;;   trap_if a0,heap_oob
-;;   ld a0,8(a1)
-;;   ugt a0,t1,a0##ty=i64
-;;   bne a0,zero,taken(label3),not_taken(label1)
+;;   slli a7,a0,32
+;;   srli t4,a7,32
+;;   ld t3,8(a1)
+;;   ugt t3,t4,t3##ty=i64
+;;   bne t3,zero,taken(label3),not_taken(label1)
 ;; block1:
-;;   ld a0,0(a1)
-;;   add a0,a0,t2
-;;   auipc t2,0; ld t2,12(t2); j 12; .8byte 0xffff0000
-;;   add a1,a0,t2
-;;   lw a0,0(a1)
+;;   ld t0,0(a1)
+;;   add t4,t0,t4
+;;   auipc t3,0; ld t3,12(t3); j 12; .8byte 0xffff0000
+;;   add t0,t4,t3
+;;   lw a0,0(t0)
 ;;   j label2
 ;; block2:
 ;;   ret
diff --git a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat
index 307e3a828..96ff7fa66 100644
--- a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat
@@ -41,20 +41,17 @@
 
 ;; function u0:0:
 ;; block0:
-;;   slli t0,a0,32
-;;   srli t2,t0,32
-;;   ld t1,8(a2)
-;;   lui t0,1048575
-;;   addi t0,t0,4095
-;;   add a0,t1,t0
-;;   ugt t1,t2,a0##ty=i64
-;;   bne t1,zero,taken(label3),not_taken(label1)
+;;   slli a7,a0,32
+;;   srli t4,a7,32
+;;   ld t3,8(a2)
+;;   ugt t3,t4,t3##ty=i64
+;;   bne t3,zero,taken(label3),not_taken(label1)
 ;; block1:
-;;   ld a0,0(a2)
-;;   add t2,a0,t2
-;;   lui t1,1
-;;   add a0,t2,t1
-;;   sb a1,0(a0)
+;;   ld t0,0(a2)
+;;   add t4,t0,t4
+;;   lui t3,1
+;;   add t0,t4,t3
+;;   sb a1,0(t0)
 ;;   j label2
 ;; block2:
 ;;   ret
@@ -63,20 +60,17 @@
 ;;
 ;; function u0:1:
 ;; block0:
-;;   slli t0,a0,32
-;;   srli t2,t0,32
-;;   ld t1,8(a1)
-;;   lui t0,1048575
-;;   addi t0,t0,4095
-;;   add a0,t1,t0
-;;   ugt t1,t2,a0##ty=i64
-;;   bne t1,zero,taken(label3),not_taken(label1)
+;;   slli a7,a0,32
+;;   srli t4,a7,32
+;;   ld t3,8(a1)
+;;   ugt t3,t4,t3##ty=i64
+;;   bne t3,zero,taken(label3),not_taken(label1)
 ;; block1:
-;;   ld a0,0(a1)
-;;   add t2,a0,t2
-;;   lui t1,1
-;;   add a0,t2,t1
-;;   lbu a0,0(a0)
+;;   ld t0,0(a1)
+;;   add t4,t0,t4
+;;   lui t3,1
+;;   add t0,t4,t3
+;;   lbu a0,0(t0)
 ;;   j label2
 ;; block2:
 ;;   ret
diff --git a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat
index 01e960a92..7ebe36844 100644
--- a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat
@@ -41,21 +41,17 @@
 
 ;; function u0:0:
 ;; block0:
-;;   slli t0,a0,32
-;;   srli t2,t0,32
-;;   auipc t4,0; ld t4,12(t4); j 12; .8byte 0xffff0001
-;;   add t1,t2,t4
-;;   ult a0,t1,t2##ty=i64
-;;   trap_if a0,heap_oob
-;;   ld a0,8(a2)
-;;   ugt a0,t1,a0##ty=i64
-;;   bne a0,zero,taken(label3),not_taken(label1)
+;;   slli a7,a0,32
+;;   srli t4,a7,32
+;;   ld t3,8(a2)
+;;   ugt t3,t4,t3##ty=i64
+;;   bne t3,zero,taken(label3),not_taken(label1)
 ;; block1:
-;;   ld a0,0(a2)
-;;   add a0,a0,t2
-;;   auipc t2,0; ld t2,12(t2); j 12; .8byte 0xffff0000
-;;   add a2,a0,t2
-;;   sb a1,0(a2)
+;;   ld t0,0(a2)
+;;   add t4,t0,t4
+;;   auipc t3,0; ld t3,12(t3); j 12; .8byte 0xffff0000
+;;   add t0,t4,t3
+;;   sb a1,0(t0)
 ;;   j label2
 ;; block2:
 ;;   ret
@@ -64,21 +60,17 @@
 ;;
 ;; function u0:1:
 ;; block0:
-;;   slli t0,a0,32
-;;   srli t2,t0,32
-;;   auipc t4,0; ld t4,12(t4); j 12; .8byte 0xffff0001
-;;   add t1,t2,t4
-;;   ult a0,t1,t2##ty=i64
-;;   trap_if a0,heap_oob
-;;   ld a0,8(a1)
-;;   ugt a0,t1,a0##ty=i64
-;;   bne a0,zero,taken(label3),not_taken(label1)
+;;   slli a7,a0,32
+;;   srli t4,a7,32
+;;   ld t3,8(a1)
+;;   ugt t3,t4,t3##ty=i64
+;;   bne t3,zero,taken(label3),not_taken(label1)
 ;; block1:
-;;   ld a0,0(a1)
-;;   add a0,a0,t2
-;;   auipc t2,0; ld t2,12(t2); j 12; .8byte 0xffff0000
-;;   add a1,a0,t2
-;;   lbu a0,0(a1)
+;;   ld t0,0(a1)
+;;   add t4,t0,t4
+;;   auipc t3,0; ld t3,12(t3); j 12; .8byte 0xffff0000
+;;   add t0,t4,t3
+;;   lbu a0,0(t0)
 ;;   j label2
 ;; block2:
 ;;   ret
diff --git a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat
index 83238484a..aad2ea214 100644
--- a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat
+++ b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat
@@ -41,32 +41,30 @@
 
 ;; function u0:0:
 ;; block0:
-;;   slli t3,a0,32
-;;   srli t0,t3,32
-;;   ld t4,8(a2)
-;;   addi t4,t4,-4
-;;   ld t1,0(a2)
-;;   add t1,t1,t0
-;;   ugt t3,t0,t4##ty=i64
-;;   li t0,0
-;;   selectif_spectre_guard t4,t0,t1##test=t3
-;;   sw a1,0(t4)
+;;   slli a7,a0,32
+;;   srli t4,a7,32
+;;   ld t3,8(a2)
+;;   ld t0,0(a2)
+;;   add t0,t0,t4
+;;   ugt a7,t4,t3##ty=i64
+;;   li t4,0
+;;   selectif_spectre_guard t3,t4,t0##test=a7
+;;   sw a1,0(t3)
 ;;   j label1
 ;; block1:
 ;;   ret
 ;;
 ;; function u0:1:
 ;; block0:
-;;   slli t3,a0,32
-;;   srli t0,t3,32
-;;   ld t4,8(a1)
-;;   addi t4,t4,-4
-;;   ld t1,0(a1)
-;;   add t1,t1,t0
-;;   ugt t3,t0,t4##ty=i64
-;;   li t0,0
-;;   selectif_spectre_guard t4,t0,t1##test=t3
-;;   lw a0,0(t4)
+;;   slli a7,a0,32
+;;   srli t4,a7,32
+;;   ld t3,8(a1)
+;;   ld t0,0(a1)
+;;   add t0,t0,t4
+;;   ugt a7,t4,t3##ty=i64
+;;   li t4,0
+;;   selectif_spectre_guard t3,t4,t0##test=a7
+;;   lw a0,0(t3)
 ;;   j label1
 ;; block1:
 ;;   ret
diff --git a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat
index 0f146db70..9839c99a9 100644
--- a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat
@@ -41,40 +41,34 @@
 
 ;; function u0:0:
 ;; block0:
-;;   slli t2,a0,32
-;;   srli a3,t2,32
-;;   ld a0,8(a2)
-;;   lui t2,1048575
-;;   addi t2,t2,4092
-;;   add a4,a0,t2
-;;   ld a0,0(a2)
-;;   add a0,a0,a3
-;;   lui t2,1
-;;   add a2,a0,t2
-;;   ugt t2,a3,a4##ty=i64
-;;   li a3,0
-;;   selectif_spectre_guard a0,a3,a2##test=t2
-;;   sw a1,0(a0)
+;;   slli t4,a0,32
+;;   srli t1,t4,32
+;;   ld t0,8(a2)
+;;   ld t2,0(a2)
+;;   add t2,t2,t1
+;;   lui t4,1
+;;   add t2,t2,t4
+;;   ugt t4,t1,t0##ty=i64
+;;   li t1,0
+;;   selectif_spectre_guard t0,t1,t2##test=t4
+;;   sw a1,0(t0)
 ;;   j label1
 ;; block1:
 ;;   ret
 ;;
 ;; function u0:1:
 ;; block0:
-;;   slli t2,a0,32
-;;   srli a2,t2,32
-;;   ld a0,8(a1)
-;;   lui t2,1048575
-;;   addi t2,t2,4092
-;;   add a3,a0,t2
-;;   ld a0,0(a1)
-;;   add a0,a0,a2
-;;   lui t2,1
-;;   add a1,a0,t2
-;;   ugt t2,a2,a3##ty=i64
-;;   li a2,0
-;;   selectif_spectre_guard a0,a2,a1##test=t2
-;;   lw a0,0(a0)
+;;   slli t4,a0,32
+;;   srli t1,t4,32
+;;   ld t0,8(a1)
+;;   ld t2,0(a1)
+;;   add t2,t2,t1
+;;   lui t4,1
+;;   add t2,t2,t4
+;;   ugt t4,t1,t0##ty=i64
+;;   li t1,0
+;;   selectif_spectre_guard t0,t1,t2##test=t4
+;;   lw a0,0(t0)
 ;;   j label1
 ;; block1:
 ;;   ret
diff --git a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat
index 965966076..d1cee5b07 100644
--- a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat
@@ -41,42 +41,34 @@
 
 ;; function u0:0:
 ;; block0:
-;;   slli t2,a0,32
-;;   srli a3,t2,32
-;;   auipc t1,0; ld t1,12(t1); j 12; .8byte 0xffff0004
-;;   add a0,a3,t1
-;;   ult a4,a0,a3##ty=i64
-;;   trap_if a4,heap_oob
-;;   ld a4,8(a2)
-;;   ld a2,0(a2)
-;;   add a2,a2,a3
-;;   auipc a3,0; ld a3,12(a3); j 12; .8byte 0xffff0000
-;;   add a2,a2,a3
-;;   ugt a0,a0,a4##ty=i64
-;;   li a3,0
-;;   selectif_spectre_guard a4,a3,a2##test=a0
-;;   sw a1,0(a4)
+;;   slli t4,a0,32
+;;   srli t1,t4,32
+;;   ld t0,8(a2)
+;;   ld t2,0(a2)
+;;   add t2,t2,t1
+;;   auipc t4,0; ld t4,12(t4); j 12; .8byte 0xffff0000
+;;   add t2,t2,t4
+;;   ugt t4,t1,t0##ty=i64
+;;   li t1,0
+;;   selectif_spectre_guard t0,t1,t2##test=t4
+;;   sw a1,0(t0)
 ;;   j label1
 ;; block1:
 ;;   ret
 ;;
 ;; function u0:1:
 ;; block0:
-;;   slli t2,a0,32
-;;   srli a2,t2,32
-;;   auipc t1,0; ld t1,12(t1); j 12; .8byte 0xffff0004
-;;   add a0,a2,t1
-;;   ult a3,a0,a2##ty=i64
-;;   trap_if a3,heap_oob
-;;   ld a3,8(a1)
-;;   ld a1,0(a1)
-;;   add a1,a1,a2
-;;   auipc a2,0; ld a2,12(a2); j 12; .8byte 0xffff0000
-;;   add a2,a1,a2
-;;   ugt a0,a0,a3##ty=i64
-;;   li a3,0
-;;   selectif_spectre_guard a1,a3,a2##test=a0
-;;   lw a0,0(a1)
+;;   slli t4,a0,32
+;;   srli t1,t4,32
+;;   ld t0,8(a1)
+;;   ld t2,0(a1)
+;;   add t2,t2,t1
+;;   auipc t4,0; ld t4,12(t4); j 12; .8byte 0xffff0000
+;;   add t2,t2,t4
+;;   ugt t4,t1,t0##ty=i64
+;;   li t1,0
+;;   selectif_spectre_guard t0,t1,t2##test=t4
+;;   lw a0,0(t0)
 ;;   j label1
 ;; block1:
 ;;   ret
diff --git a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat
index c3930901e..238f25870 100644
--- a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat
@@ -41,40 +41,34 @@
 
 ;; function u0:0:
 ;; block0:
-;;   slli t2,a0,32
-;;   srli a3,t2,32
-;;   ld a0,8(a2)
-;;   lui t2,1048575
-;;   addi t2,t2,4095
-;;   add a4,a0,t2
-;;   ld a0,0(a2)
-;;   add a0,a0,a3
-;;   lui t2,1
-;;   add a2,a0,t2
-;;   ugt t2,a3,a4##ty=i64
-;;   li a3,0
-;;   selectif_spectre_guard a0,a3,a2##test=t2
-;;   sb a1,0(a0)
+;;   slli t4,a0,32
+;;   srli t1,t4,32
+;;   ld t0,8(a2)
+;;   ld t2,0(a2)
+;;   add t2,t2,t1
+;;   lui t4,1
+;;   add t2,t2,t4
+;;   ugt t4,t1,t0##ty=i64
+;;   li t1,0
+;;   selectif_spectre_guard t0,t1,t2##test=t4
+;;   sb a1,0(t0)
 ;;   j label1
 ;; block1:
 ;;   ret
 ;;
 ;; function u0:1:
 ;; block0:
-;;   slli t2,a0,32
-;;   srli a2,t2,32
-;;   ld a0,8(a1)
-;;   lui t2,1048575
-;;   addi t2,t2,4095
-;;   add a3,a0,t2
-;;   ld a0,0(a1)
-;;   add a0,a0,a2
-;;   lui t2,1
-;;   add a1,a0,t2
-;;   ugt t2,a2,a3##ty=i64
-;;   li a2,0
-;;   selectif_spectre_guard a0,a2,a1##test=t2
-;;   lbu a0,0(a0)
+;;   slli t4,a0,32
+;;   srli t1,t4,32
+;;   ld t0,8(a1)
+;;   ld t2,0(a1)
+;;   add t2,t2,t1
+;;   lui t4,1
+;;   add t2,t2,t4
+;;   ugt t4,t1,t0##ty=i64
+;;   li t1,0
+;;   selectif_spectre_guard t0,t1,t2##test=t4
+;;   lbu a0,0(t0)
 ;;   j label1
 ;; block1:
 ;;   ret
diff --git a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat
index efec9936f..334bd2166 100644
--- a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat
@@ -41,42 +41,34 @@
 
 ;; function u0:0:
 ;; block0:
-;;   slli t2,a0,32
-;;   srli a3,t2,32
-;;   auipc t1,0; ld t1,12(t1); j 12; .8byte 0xffff0001
-;;   add a0,a3,t1
-;;   ult a4,a0,a3##ty=i64
-;;   trap_if a4,heap_oob
-;;   ld a4,8(a2)
-;;   ld a2,0(a2)
-;;   add a2,a2,a3
-;;   auipc a3,0; ld a3,12(a3); j 12; .8byte 0xffff0000
-;;   add a2,a2,a3
-;;   ugt a0,a0,a4##ty=i64
-;;   li a3,0
-;;   selectif_spectre_guard a4,a3,a2##test=a0
-;;   sb a1,0(a4)
+;;   slli t4,a0,32
+;;   srli t1,t4,32
+;;   ld t0,8(a2)
+;;   ld t2,0(a2)
+;;   add t2,t2,t1
+;;   auipc t4,0; ld t4,12(t4); j 12; .8byte 0xffff0000
+;;   add t2,t2,t4
+;;   ugt t4,t1,t0##ty=i64
+;;   li t1,0
+;;   selectif_spectre_guard t0,t1,t2##test=t4
+;;   sb a1,0(t0)
 ;;   j label1
 ;; block1:
 ;;   ret
 ;;
 ;; function u0:1:
 ;; block0:
-;;   slli t2,a0,32
-;;   srli a2,t2,32
-;;   auipc t1,0; ld t1,12(t1); j 12; .8byte 0xffff0001
-;;   add a0,a2,t1
-;;   ult a3,a0,a2##ty=i64
-;;   trap_if a3,heap_oob
-;;   ld a3,8(a1)
-;;   ld a1,0(a1)
-;;   add a1,a1,a2
-;;   auipc a2,0; ld a2,12(a2); j 12; .8byte 0xffff0000
-;;   add a2,a1,a2
-;;   ugt a0,a0,a3##ty=i64
-;;   li a3,0
-;;   selectif_spectre_guard a1,a3,a2##test=a0
-;;   lbu a0,0(a1)
+;;   slli t4,a0,32
+;;   srli t1,t4,32
+;;   ld t0,8(a1)
+;;   ld t2,0(a1)
+;;   add t2,t2,t1
+;;   auipc t4,0; ld t4,12(t4); j 12; .8byte 0xffff0000
+;;   add t2,t2,t4
+;;   ugt t4,t1,t0##ty=i64
+;;   li t1,0
+;;   selectif_spectre_guard t0,t1,t2##test=t4
+;;   lbu a0,0(t0)
 ;;   j label1
 ;; block1:
 ;;   ret
diff --git a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat
index c5bac8adc..a248ccc6f 100644
--- a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat
+++ b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat
@@ -41,14 +41,13 @@
 
 ;; function u0:0:
 ;; block0:
-;;   ld a5,8(a2)
-;;   addi a5,a5,-4
-;;   ugt a5,a0,a5##ty=i64
-;;   bne a5,zero,taken(label3),not_taken(label1)
+;;   ld a4,8(a2)
+;;   ugt a4,a0,a4##ty=i64
+;;   bne a4,zero,taken(label3),not_taken(label1)
 ;; block1:
-;;   ld a6,0(a2)
-;;   add a6,a6,a0
-;;   sw a1,0(a6)
+;;   ld a5,0(a2)
+;;   add a5,a5,a0
+;;   sw a1,0(a5)
 ;;   j label2
 ;; block2:
 ;;   ret
@@ -57,14 +56,13 @@
 ;;
 ;; function u0:1:
 ;; block0:
-;;   ld a5,8(a1)
-;;   addi a5,a5,-4
-;;   ugt a5,a0,a5##ty=i64
-;;   bne a5,zero,taken(label3),not_taken(label1)
+;;   ld a4,8(a1)
+;;   ugt a4,a0,a4##ty=i64
+;;   bne a4,zero,taken(label3),not_taken(label1)
 ;; block1:
-;;   ld a6,0(a1)
-;;   add a6,a6,a0
-;;   lw a0,0(a6)
+;;   ld a5,0(a1)
+;;   add a5,a5,a0
+;;   lw a0,0(a5)
 ;;   j label2
 ;; block2:
 ;;   ret
diff --git a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat
index 57b5d1237..9cb33c5e1 100644
--- a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat
@@ -41,18 +41,15 @@
 
 ;; function u0:0:
 ;; block0:
-;;   ld t4,8(a2)
-;;   lui t3,1048575
-;;   addi t3,t3,4092
-;;   add t1,t4,t3
-;;   ugt t4,a0,t1##ty=i64
-;;   bne t4,zero,taken(label3),not_taken(label1)
+;;   ld a6,8(a2)
+;;   ugt a6,a0,a6##ty=i64
+;;   bne a6,zero,taken(label3),not_taken(label1)
 ;; block1:
-;;   ld t0,0(a2)
-;;   add t0,t0,a0
-;;   lui t4,1
-;;   add t1,t0,t4
-;;   sw a1,0(t1)
+;;   ld a7,0(a2)
+;;   add a7,a7,a0
+;;   lui a6,1
+;;   add t3,a7,a6
+;;   sw a1,0(t3)
 ;;   j label2
 ;; block2:
 ;;   ret
@@ -61,18 +58,15 @@
 ;;
 ;; function u0:1:
 ;; block0:
-;;   ld t4,8(a1)
-;;   lui t3,1048575
-;;   addi t3,t3,4092
-;;   add t1,t4,t3
-;;   ugt t4,a0,t1##ty=i64
-;;   bne t4,zero,taken(label3),not_taken(label1)
+;;   ld a6,8(a1)
+;;   ugt a6,a0,a6##ty=i64
+;;   bne a6,zero,taken(label3),not_taken(label1)
 ;; block1:
-;;   ld t0,0(a1)
-;;   add t0,t0,a0
-;;   lui t4,1
-;;   add t1,t0,t4
-;;   lw a0,0(t1)
+;;   ld a7,0(a1)
+;;   add a7,a7,a0
+;;   lui a6,1
+;;   add t3,a7,a6
+;;   lw a0,0(t3)
 ;;   j label2
 ;; block2:
 ;;   ret
diff --git a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat
index ea9cd1c9c..455abbfed 100644
--- a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat
@@ -41,19 +41,15 @@
 
 ;; function u0:0:
 ;; block0:
-;;   auipc a7,0; ld a7,12(a7); j 12; .8byte 0xffff0004
-;;   add t4,a0,a7
-;;   ult t1,t4,a0##ty=i64
-;;   trap_if t1,heap_oob
-;;   ld t0,8(a2)
-;;   ugt t0,t4,t0##ty=i64
-;;   bne t0,zero,taken(label3),not_taken(label1)
+;;   ld a6,8(a2)
+;;   ugt a6,a0,a6##ty=i64
+;;   bne a6,zero,taken(label3),not_taken(label1)
 ;; block1:
-;;   ld t1,0(a2)
-;;   add t1,t1,a0
-;;   auipc t0,0; ld t0,12(t0); j 12; .8byte 0xffff0000
-;;   add t2,t1,t0
-;;   sw a1,0(t2)
+;;   ld a7,0(a2)
+;;   add a7,a7,a0
+;;   auipc a6,0; ld a6,12(a6); j 12; .8byte 0xffff0000
+;;   add t3,a7,a6
+;;   sw a1,0(t3)
 ;;   j label2
 ;; block2:
 ;;   ret
@@ -62,19 +58,15 @@
 ;;
 ;; function u0:1:
 ;; block0:
-;;   auipc a7,0; ld a7,12(a7); j 12; .8byte 0xffff0004
-;;   add t4,a0,a7
-;;   ult t1,t4,a0##ty=i64
-;;   trap_if t1,heap_oob
-;;   ld t0,8(a1)
-;;   ugt t0,t4,t0##ty=i64
-;;   bne t0,zero,taken(label3),not_taken(label1)
+;;   ld a6,8(a1)
+;;   ugt a6,a0,a6##ty=i64
+;;   bne a6,zero,taken(label3),not_taken(label1)
 ;; block1:
-;;   ld t1,0(a1)
-;;   add t1,t1,a0
-;;   auipc t0,0; ld t0,12(t0); j 12; .8byte 0xffff0000
-;;   add t2,t1,t0
-;;   lw a0,0(t2)
+;;   ld a7,0(a1)
+;;   add a7,a7,a0
+;;   auipc a6,0; ld a6,12(a6); j 12; .8byte 0xffff0000
+;;   add t3,a7,a6
+;;   lw a0,0(t3)
 ;;   j label2
 ;; block2:
 ;;   ret
diff --git a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat
index 552af17da..b692ae637 100644
--- a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat
@@ -41,18 +41,15 @@
 
 ;; function u0:0:
 ;; block0:
-;;   ld t4,8(a2)
-;;   lui t3,1048575
-;;   addi t3,t3,4095
-;;   add t1,t4,t3
-;;   ugt t4,a0,t1##ty=i64
-;;   bne t4,zero,taken(label3),not_taken(label1)
+;;   ld a6,8(a2)
+;;   ugt a6,a0,a6##ty=i64
+;;   bne a6,zero,taken(label3),not_taken(label1)
 ;; block1:
-;;   ld t0,0(a2)
-;;   add t0,t0,a0
-;;   lui t4,1
-;;   add t1,t0,t4
-;;   sb a1,0(t1)
+;;   ld a7,0(a2)
+;;   add a7,a7,a0
+;;   lui a6,1
+;;   add t3,a7,a6
+;;   sb a1,0(t3)
 ;;   j label2
 ;; block2:
 ;;   ret
@@ -61,18 +58,15 @@
 ;;
 ;; function u0:1:
 ;; block0:
-;;   ld t4,8(a1)
-;;   lui t3,1048575
-;;   addi t3,t3,4095
-;;   add t1,t4,t3
-;;   ugt t4,a0,t1##ty=i64
-;;   bne t4,zero,taken(label3),not_taken(label1)
+;;   ld a6,8(a1)
+;;   ugt a6,a0,a6##ty=i64
+;;   bne a6,zero,taken(label3),not_taken(label1)
 ;; block1:
-;;   ld t0,0(a1)
-;;   add t0,t0,a0
-;;   lui t4,1
-;;   add t1,t0,t4
-;;   lbu a0,0(t1)
+;;   ld a7,0(a1)
+;;   add a7,a7,a0
+;;   lui a6,1
+;;   add t3,a7,a6
+;;   lbu a0,0(t3)
 ;;   j label2
 ;; block2:
 ;;   ret
diff --git a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat
index 9ae252108..ca05882ca 100644
--- a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat
@@ -41,19 +41,15 @@
 
 ;; function u0:0:
 ;; block0:
-;;   auipc a7,0; ld a7,12(a7); j 12; .8byte 0xffff0001
-;;   add t4,a0,a7
-;;   ult t1,t4,a0##ty=i64
-;;   trap_if t1,heap_oob
-;;   ld t0,8(a2)
-;;   ugt t0,t4,t0##ty=i64
-;;   bne t0,zero,taken(label3),not_taken(label1)
+;;   ld a6,8(a2)
+;;   ugt a6,a0,a6##ty=i64
+;;   bne a6,zero,taken(label3),not_taken(label1)
 ;; block1:
-;;   ld t1,0(a2)
-;;   add t1,t1,a0
-;;   auipc t0,0; ld t0,12(t0); j 12; .8byte 0xffff0000
-;;   add t2,t1,t0
-;;   sb a1,0(t2)
+;;   ld a7,0(a2)
+;;   add a7,a7,a0
+;;   auipc a6,0; ld a6,12(a6); j 12; .8byte 0xffff0000
+;;   add t3,a7,a6
+;;   sb a1,0(t3)
 ;;   j label2
 ;; block2:
 ;;   ret
@@ -62,19 +58,15 @@
 ;;
 ;; function u0:1:
 ;; block0:
-;;   auipc a7,0; ld a7,12(a7); j 12; .8byte 0xffff0001
-;;   add t4,a0,a7
-;;   ult t1,t4,a0##ty=i64
-;;   trap_if t1,heap_oob
-;;   ld t0,8(a1)
-;;   ugt t0,t4,t0##ty=i64
-;;   bne t0,zero,taken(label3),not_taken(label1)
+;;   ld a6,8(a1)
+;;   ugt a6,a0,a6##ty=i64
+;;   bne a6,zero,taken(label3),not_taken(label1)
 ;; block1:
-;;   ld t1,0(a1)
-;;   add t1,t1,a0
-;;   auipc t0,0; ld t0,12(t0); j 12; .8byte 0xffff0000
-;;   add t2,t1,t0
-;;   lbu a0,0(t2)
+;;   ld a7,0(a1)
+;;   add a7,a7,a0
+;;   auipc a6,0; ld a6,12(a6); j 12; .8byte 0xffff0000
+;;   add t3,a7,a6
+;;   lbu a0,0(t3)
 ;;   j label2
 ;; block2:
 ;;   ret
diff --git a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat
index 1394499d0..28c262ddc 100644
--- a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat
+++ b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat
@@ -41,28 +41,26 @@
 
 ;; function u0:0:
 ;; block0:
-;;   ld a7,8(a2)
-;;   addi a7,a7,-4
-;;   ld t3,0(a2)
-;;   add t3,t3,a0
-;;   ugt a6,a0,a7##ty=i64
-;;   li t4,0
-;;   selectif_spectre_guard a7,t4,t3##test=a6
-;;   sw a1,0(a7)
+;;   ld a6,8(a2)
+;;   ld a7,0(a2)
+;;   add a7,a7,a0
+;;   ugt a5,a0,a6##ty=i64
+;;   li t3,0
+;;   selectif_spectre_guard a6,t3,a7##test=a5
+;;   sw a1,0(a6)
 ;;   j label1
 ;; block1:
 ;;   ret
 ;;
 ;; function u0:1:
 ;; block0:
-;;   ld a7,8(a1)
-;;   addi a7,a7,-4
-;;   ld t3,0(a1)
-;;   add t3,t3,a0
-;;   ugt a6,a0,a7##ty=i64
-;;   li t4,0
-;;   selectif_spectre_guard a7,t4,t3##test=a6
-;;   lw a0,0(a7)
+;;   ld a6,8(a1)
+;;   ld a7,0(a1)
+;;   add a7,a7,a0
+;;   ugt a5,a0,a6##ty=i64
+;;   li t3,0
+;;   selectif_spectre_guard a6,t3,a7##test=a5
+;;   lw a0,0(a6)
 ;;   j label1
 ;; block1:
-;;   ret
\ No newline at end of file
+;;   ret
diff --git a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat
index dcea0981e..878086222 100644
--- a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat
@@ -41,36 +41,30 @@
 
 ;; function u0:0:
 ;; block0:
-;;   ld t1,8(a2)
-;;   lui t0,1048575
-;;   addi t0,t0,4092
-;;   add a3,t1,t0
-;;   ld t1,0(a2)
-;;   add t1,t1,a0
-;;   lui t0,1
-;;   add t2,t1,t0
-;;   ugt t0,a0,a3##ty=i64
-;;   li a0,0
-;;   selectif_spectre_guard t1,a0,t2##test=t0
-;;   sw a1,0(t1)
+;;   ld t3,8(a2)
+;;   ld t4,0(a2)
+;;   add t4,t4,a0
+;;   lui a7,1
+;;   add t4,t4,a7
+;;   ugt a7,a0,t3##ty=i64
+;;   li t0,0
+;;   selectif_spectre_guard t3,t0,t4##test=a7
+;;   sw a1,0(t3)
 ;;   j label1
 ;; block1:
 ;;   ret
 ;;
 ;; function u0:1:
 ;; block0:
-;;   ld t1,8(a1)
-;;   lui t0,1048575
-;;   addi t0,t0,4092
-;;   add a2,t1,t0
-;;   ld t1,0(a1)
-;;   add t1,t1,a0
-;;   lui t0,1
-;;   add t2,t1,t0
-;;   ugt t0,a0,a2##ty=i64
-;;   li a0,0
-;;   selectif_spectre_guard t1,a0,t2##test=t0
-;;   lw a0,0(t1)
+;;   ld t3,8(a1)
+;;   ld t4,0(a1)
+;;   add t4,t4,a0
+;;   lui a7,1
+;;   add t4,t4,a7
+;;   ugt a7,a0,t3##ty=i64
+;;   li t0,0
+;;   selectif_spectre_guard t3,t0,t4##test=a7
+;;   lw a0,0(t3)
 ;;   j label1
 ;; block1:
-;;   ret
\ No newline at end of file
+;;   ret
diff --git a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat
index e5762ae96..483ad66ca 100644
--- a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat
@@ -41,38 +41,30 @@
 
 ;; function u0:0:
 ;; block0:
-;;   auipc t4,0; ld t4,12(t4); j 12; .8byte 0xffff0004
-;;   add t1,a0,t4
-;;   ult a3,t1,a0##ty=i64
-;;   trap_if a3,heap_oob
-;;   ld t2,8(a2)
-;;   ld a2,0(a2)
-;;   add a0,a2,a0
-;;   auipc a2,0; ld a2,12(a2); j 12; .8byte 0xffff0000
-;;   add a0,a0,a2
-;;   ugt t1,t1,t2##ty=i64
-;;   li a2,0
-;;   selectif_spectre_guard t2,a2,a0##test=t1
-;;   sw a1,0(t2)
+;;   ld t3,8(a2)
+;;   ld t4,0(a2)
+;;   add t4,t4,a0
+;;   auipc a7,0; ld a7,12(a7); j 12; .8byte 0xffff0000
+;;   add t4,t4,a7
+;;   ugt a7,a0,t3##ty=i64
+;;   li t0,0
+;;   selectif_spectre_guard t3,t0,t4##test=a7
+;;   sw a1,0(t3)
 ;;   j label1
 ;; block1:
 ;;   ret
 ;;
 ;; function u0:1:
 ;; block0:
-;;   auipc t4,0; ld t4,12(t4); j 12; .8byte 0xffff0004
-;;   add t1,a0,t4
-;;   ult a2,t1,a0##ty=i64
-;;   trap_if a2,heap_oob
-;;   ld t2,8(a1)
-;;   ld a1,0(a1)
-;;   add a0,a1,a0
-;;   auipc a1,0; ld a1,12(a1); j 12; .8byte 0xffff0000
-;;   add a0,a0,a1
-;;   ugt t1,t1,t2##ty=i64
-;;   li a1,0
-;;   selectif_spectre_guard t2,a1,a0##test=t1
-;;   lw a0,0(t2)
+;;   ld t3,8(a1)
+;;   ld t4,0(a1)
+;;   add t4,t4,a0
+;;   auipc a7,0; ld a7,12(a7); j 12; .8byte 0xffff0000
+;;   add t4,t4,a7
+;;   ugt a7,a0,t3##ty=i64
+;;   li t0,0
+;;   selectif_spectre_guard t3,t0,t4##test=a7
+;;   lw a0,0(t3)
 ;;   j label1
 ;; block1:
-;;   ret
\ No newline at end of file
+;;   ret
diff --git a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat
index 6a3f5877c..b11fadba5 100644
--- a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat
@@ -41,36 +41,30 @@
 
 ;; function u0:0:
 ;; block0:
-;;   ld t1,8(a2)
-;;   lui t0,1048575
-;;   addi t0,t0,4095
-;;   add a3,t1,t0
-;;   ld t1,0(a2)
-;;   add t1,t1,a0
-;;   lui t0,1
-;;   add t2,t1,t0
-;;   ugt t0,a0,a3##ty=i64
-;;   li a0,0
-;;   selectif_spectre_guard t1,a0,t2##test=t0
-;;   sb a1,0(t1)
+;;   ld t3,8(a2)
+;;   ld t4,0(a2)
+;;   add t4,t4,a0
+;;   lui a7,1
+;;   add t4,t4,a7
+;;   ugt a7,a0,t3##ty=i64
+;;   li t0,0
+;;   selectif_spectre_guard t3,t0,t4##test=a7
+;;   sb a1,0(t3)
 ;;   j label1
 ;; block1:
 ;;   ret
 ;;
 ;; function u0:1:
 ;; block0:
-;;   ld t1,8(a1)
-;;   lui t0,1048575
-;;   addi t0,t0,4095
-;;   add a2,t1,t0
-;;   ld t1,0(a1)
-;;   add t1,t1,a0
-;;   lui t0,1
-;;   add t2,t1,t0
-;;   ugt t0,a0,a2##ty=i64
-;;   li a0,0
-;;   selectif_spectre_guard t1,a0,t2##test=t0
-;;   lbu a0,0(t1)
+;;   ld t3,8(a1)
+;;   ld t4,0(a1)
+;;   add t4,t4,a0
+;;   lui a7,1
+;;   add t4,t4,a7
+;;   ugt a7,a0,t3##ty=i64
+;;   li t0,0
+;;   selectif_spectre_guard t3,t0,t4##test=a7
+;;   lbu a0,0(t3)
 ;;   j label1
 ;; block1:
-;;   ret
\ No newline at end of file
+;;   ret
diff --git a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat
index a4b0f0c6a..2630ec2e6 100644
--- a/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/isa/riscv64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat
@@ -41,38 +41,30 @@
 
 ;; function u0:0:
 ;; block0:
-;;   auipc t4,0; ld t4,12(t4); j 12; .8byte 0xffff0001
-;;   add t1,a0,t4
-;;   ult a3,t1,a0##ty=i64
-;;   trap_if a3,heap_oob
-;;   ld t2,8(a2)
-;;   ld a2,0(a2)
-;;   add a0,a2,a0
-;;   auipc a2,0; ld a2,12(a2); j 12; .8byte 0xffff0000
-;;   add a0,a0,a2
-;;   ugt t1,t1,t2##ty=i64
-;;   li a2,0
-;;   selectif_spectre_guard t2,a2,a0##test=t1
-;;   sb a1,0(t2)
+;;   ld t3,8(a2)
+;;   ld t4,0(a2)
+;;   add t4,t4,a0
+;;   auipc a7,0; ld a7,12(a7); j 12; .8byte 0xffff0000
+;;   add t4,t4,a7
+;;   ugt a7,a0,t3##ty=i64
+;;   li t0,0
+;;   selectif_spectre_guard t3,t0,t4##test=a7
+;;   sb a1,0(t3)
 ;;   j label1
 ;; block1:
 ;;   ret
 ;;
 ;; function u0:1:
 ;; block0:
-;;   auipc t4,0; ld t4,12(t4); j 12; .8byte 0xffff0001
-;;   add t1,a0,t4
-;;   ult a2,t1,a0##ty=i64
-;;   trap_if a2,heap_oob
-;;   ld t2,8(a1)
-;;   ld a1,0(a1)
-;;   add a0,a1,a0
-;;   auipc a1,0; ld a1,12(a1); j 12; .8byte 0xffff0000
-;;   add a0,a0,a1
-;;   ugt t1,t1,t2##ty=i64
-;;   li a1,0
-;;   selectif_spectre_guard t2,a1,a0##test=t1
-;;   lbu a0,0(t2)
+;;   ld t3,8(a1)
+;;   ld t4,0(a1)
+;;   add t4,t4,a0
+;;   auipc a7,0; ld a7,12(a7); j 12; .8byte 0xffff0000
+;;   add t4,t4,a7
+;;   ugt a7,a0,t3##ty=i64
+;;   li t0,0
+;;   selectif_spectre_guard t3,t0,t4##test=a7
+;;   lbu a0,0(t3)
 ;;   j label1
 ;; block1:
-;;   ret
\ No newline at end of file
+;;   ret
diff --git a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat
index 173379cdd..708e4bfe8 100644
--- a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat
+++ b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat
@@ -43,14 +43,15 @@
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 160, offset_downward_to_clobbers: 0 }
 ;;   unwind StackAlloc { size: 0 }
 ;; block0:
-;;   llgfr %r5, %r2
-;;   lghi %r2, -4
-;;   ag %r2, 8(%r4)
-;;   clgr %r5, %r2
+;;   lgr %r5, %r4
+;;   llgfr %r4, %r2
+;;   lgr %r2, %r5
+;;   lg %r5, 8(%r2)
+;;   clgr %r4, %r5
 ;;   jgh label3 ; jg label1
 ;; block1:
-;;   lg %r4, 0(%r4)
-;;   strv %r3, 0(%r5,%r4)
+;;   lg %r2, 0(%r2)
+;;   strv %r3, 0(%r4,%r2)
 ;;   jg label2
 ;; block2:
 ;;   br %r14
@@ -61,14 +62,13 @@
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 160, offset_downward_to_clobbers: 0 }
 ;;   unwind StackAlloc { size: 0 }
 ;; block0:
-;;   llgfr %r5, %r2
-;;   lghi %r2, -4
-;;   ag %r2, 8(%r3)
-;;   clgr %r5, %r2
+;;   llgfr %r4, %r2
+;;   lg %r5, 8(%r3)
+;;   clgr %r4, %r5
 ;;   jgh label3 ; jg label1
 ;; block1:
-;;   lg %r3, 0(%r3)
-;;   lrv %r2, 0(%r5,%r3)
+;;   lg %r2, 0(%r3)
+;;   lrv %r2, 0(%r4,%r2)
 ;;   jg label2
 ;; block2:
 ;;   br %r14
diff --git a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat
index 9eaf0bd93..d7f0c5361 100644
--- a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat
@@ -45,8 +45,7 @@
 ;; block0:
 ;;   lgr %r5, %r4
 ;;   llgfr %r4, %r2
-;;   lghi %r2, -4100
-;;   ag %r2, 8(%r5)
+;;   lg %r2, 8(%r5)
 ;;   clgr %r4, %r2
 ;;   jgh label3 ; jg label1
 ;; block1:
@@ -65,15 +64,13 @@
 ;; block0:
 ;;   lgr %r4, %r3
 ;;   llgfr %r3, %r2
-;;   lghi %r2, -4100
-;;   lgr %r5, %r4
-;;   ag %r2, 8(%r5)
-;;   clgr %r3, %r2
+;;   lg %r5, 8(%r4)
+;;   clgr %r3, %r5
 ;;   jgh label3 ; jg label1
 ;; block1:
-;;   ag %r3, 0(%r5)
-;;   lghi %r4, 4096
-;;   lrv %r2, 0(%r4,%r3)
+;;   ag %r3, 0(%r4)
+;;   lghi %r2, 4096
+;;   lrv %r2, 0(%r2,%r3)
 ;;   jg label2
 ;; block2:
 ;;   br %r14
diff --git a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat
index c97dd6b61..efe0b2cd1 100644
--- a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat
@@ -41,35 +41,19 @@
 
 ;; function u0:0:
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 160, offset_downward_to_clobbers: 0 }
-;;   stmg %r7, %r15, 56(%r15)
-;;   unwind SaveReg { clobber_offset: 56, reg: p7i }
-;;   unwind SaveReg { clobber_offset: 64, reg: p8i }
-;;   unwind SaveReg { clobber_offset: 72, reg: p9i }
-;;   unwind SaveReg { clobber_offset: 80, reg: p10i }
-;;   unwind SaveReg { clobber_offset: 88, reg: p11i }
-;;   unwind SaveReg { clobber_offset: 96, reg: p12i }
-;;   unwind SaveReg { clobber_offset: 104, reg: p13i }
-;;   unwind SaveReg { clobber_offset: 112, reg: p14i }
-;;   unwind SaveReg { clobber_offset: 120, reg: p15i }
 ;;   unwind StackAlloc { size: 0 }
 ;; block0:
-;;   lgr %r7, %r4
+;;   lgr %r5, %r4
 ;;   llgfr %r4, %r2
-;;   lgr %r5, %r2
-;;   llilf %r2, 4294901764
-;;   algfr %r2, %r5
-;;   jle 6 ; trap
-;;   lgr %r5, %r7
-;;   lg %r7, 8(%r5)
-;;   clgr %r2, %r7
+;;   lg %r2, 8(%r5)
+;;   clgr %r4, %r2
 ;;   jgh label3 ; jg label1
 ;; block1:
 ;;   ag %r4, 0(%r5)
-;;   llilh %r2, 65535
-;;   strv %r3, 0(%r2,%r4)
+;;   llilh %r5, 65535
+;;   strv %r3, 0(%r5,%r4)
 ;;   jg label2
 ;; block2:
-;;   lmg %r7, %r15, 56(%r15)
 ;;   br %r14
 ;; block3:
 ;;   trap
@@ -80,16 +64,13 @@
 ;; block0:
 ;;   lgr %r4, %r3
 ;;   llgfr %r3, %r2
-;;   llilf %r5, 4294901764
-;;   algfr %r5, %r2
-;;   jle 6 ; trap
-;;   lg %r2, 8(%r4)
-;;   clgr %r5, %r2
+;;   lg %r5, 8(%r4)
+;;   clgr %r3, %r5
 ;;   jgh label3 ; jg label1
 ;; block1:
 ;;   ag %r3, 0(%r4)
-;;   llilh %r5, 65535
-;;   lrv %r2, 0(%r5,%r3)
+;;   llilh %r2, 65535
+;;   lrv %r2, 0(%r2,%r3)
 ;;   jg label2
 ;; block2:
 ;;   br %r14
diff --git a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat
index 3490d6153..4288c8491 100644
--- a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat
@@ -45,8 +45,7 @@
 ;; block0:
 ;;   lgr %r5, %r4
 ;;   llgfr %r4, %r2
-;;   lghi %r2, -4097
-;;   ag %r2, 8(%r5)
+;;   lg %r2, 8(%r5)
 ;;   clgr %r4, %r2
 ;;   jgh label3 ; jg label1
 ;; block1:
@@ -65,15 +64,13 @@
 ;; block0:
 ;;   lgr %r4, %r3
 ;;   llgfr %r3, %r2
-;;   lghi %r2, -4097
-;;   lgr %r5, %r4
-;;   ag %r2, 8(%r5)
-;;   clgr %r3, %r2
+;;   lg %r5, 8(%r4)
+;;   clgr %r3, %r5
 ;;   jgh label3 ; jg label1
 ;; block1:
-;;   ag %r3, 0(%r5)
-;;   lghi %r4, 4096
-;;   llc %r2, 0(%r4,%r3)
+;;   ag %r3, 0(%r4)
+;;   lghi %r2, 4096
+;;   llc %r2, 0(%r2,%r3)
 ;;   jg label2
 ;; block2:
 ;;   br %r14
diff --git a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat
index 65f03555c..2c0ddb02e 100644
--- a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat
@@ -41,35 +41,19 @@
 
 ;; function u0:0:
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 160, offset_downward_to_clobbers: 0 }
-;;   stmg %r7, %r15, 56(%r15)
-;;   unwind SaveReg { clobber_offset: 56, reg: p7i }
-;;   unwind SaveReg { clobber_offset: 64, reg: p8i }
-;;   unwind SaveReg { clobber_offset: 72, reg: p9i }
-;;   unwind SaveReg { clobber_offset: 80, reg: p10i }
-;;   unwind SaveReg { clobber_offset: 88, reg: p11i }
-;;   unwind SaveReg { clobber_offset: 96, reg: p12i }
-;;   unwind SaveReg { clobber_offset: 104, reg: p13i }
-;;   unwind SaveReg { clobber_offset: 112, reg: p14i }
-;;   unwind SaveReg { clobber_offset: 120, reg: p15i }
 ;;   unwind StackAlloc { size: 0 }
 ;; block0:
-;;   lgr %r7, %r4
+;;   lgr %r5, %r4
 ;;   llgfr %r4, %r2
-;;   lgr %r5, %r2
-;;   llilf %r2, 4294901761
-;;   algfr %r2, %r5
-;;   jle 6 ; trap
-;;   lgr %r5, %r7
-;;   lg %r7, 8(%r5)
-;;   clgr %r2, %r7
+;;   lg %r2, 8(%r5)
+;;   clgr %r4, %r2
 ;;   jgh label3 ; jg label1
 ;; block1:
 ;;   ag %r4, 0(%r5)
-;;   llilh %r2, 65535
-;;   stc %r3, 0(%r2,%r4)
+;;   llilh %r5, 65535
+;;   stc %r3, 0(%r5,%r4)
 ;;   jg label2
 ;; block2:
-;;   lmg %r7, %r15, 56(%r15)
 ;;   br %r14
 ;; block3:
 ;;   trap
@@ -80,16 +64,13 @@
 ;; block0:
 ;;   lgr %r4, %r3
 ;;   llgfr %r3, %r2
-;;   llilf %r5, 4294901761
-;;   algfr %r5, %r2
-;;   jle 6 ; trap
-;;   lg %r2, 8(%r4)
-;;   clgr %r5, %r2
+;;   lg %r5, 8(%r4)
+;;   clgr %r3, %r5
 ;;   jgh label3 ; jg label1
 ;; block1:
 ;;   ag %r3, 0(%r4)
-;;   llilh %r5, 65535
-;;   llc %r2, 0(%r5,%r3)
+;;   llilh %r2, 65535
+;;   llc %r2, 0(%r2,%r3)
 ;;   jg label2
 ;; block2:
 ;;   br %r14
diff --git a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat
index dae8f9ac5..a3076eed2 100644
--- a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat
+++ b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat
@@ -41,48 +41,36 @@
 
 ;; function u0:0:
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 160, offset_downward_to_clobbers: 0 }
-;;   stmg %r7, %r15, 56(%r15)
-;;   unwind SaveReg { clobber_offset: 56, reg: p7i }
-;;   unwind SaveReg { clobber_offset: 64, reg: p8i }
-;;   unwind SaveReg { clobber_offset: 72, reg: p9i }
-;;   unwind SaveReg { clobber_offset: 80, reg: p10i }
-;;   unwind SaveReg { clobber_offset: 88, reg: p11i }
-;;   unwind SaveReg { clobber_offset: 96, reg: p12i }
-;;   unwind SaveReg { clobber_offset: 104, reg: p13i }
+;;   stmg %r14, %r15, 112(%r15)
 ;;   unwind SaveReg { clobber_offset: 112, reg: p14i }
 ;;   unwind SaveReg { clobber_offset: 120, reg: p15i }
 ;;   unwind StackAlloc { size: 0 }
 ;; block0:
-;;   lgr %r7, %r4
-;;   llgfr %r4, %r2
-;;   lghi %r5, -4
-;;   lgr %r9, %r7
-;;   ag %r5, 8(%r9)
-;;   lgr %r2, %r4
-;;   ag %r2, 0(%r9)
-;;   lghi %r14, 0
-;;   clgr %r4, %r5
-;;   locgrh %r2, %r14
-;;   strv %r3, 0(%r2)
+;;   llgfr %r2, %r2
+;;   lg %r14, 8(%r4)
+;;   lgr %r5, %r2
+;;   ag %r5, 0(%r4)
+;;   lghi %r4, 0
+;;   clgr %r2, %r14
+;;   locgrh %r5, %r4
+;;   strv %r3, 0(%r5)
 ;;   jg label1
 ;; block1:
-;;   lmg %r7, %r15, 56(%r15)
+;;   lmg %r14, %r15, 112(%r15)
 ;;   br %r14
 ;;
 ;; function u0:1:
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 160, offset_downward_to_clobbers: 0 }
 ;;   unwind StackAlloc { size: 0 }
 ;; block0:
-;;   lgr %r5, %r3
-;;   llgfr %r3, %r2
-;;   lghi %r4, -4
-;;   ag %r4, 8(%r5)
-;;   lgr %r2, %r3
-;;   ag %r2, 0(%r5)
-;;   lghi %r5, 0
-;;   clgr %r3, %r4
-;;   locgrh %r2, %r5
-;;   lrv %r2, 0(%r2)
+;;   llgfr %r2, %r2
+;;   lg %r4, 8(%r3)
+;;   lgr %r5, %r2
+;;   ag %r5, 0(%r3)
+;;   lghi %r3, 0
+;;   clgr %r2, %r4
+;;   locgrh %r5, %r3
+;;   lrv %r2, 0(%r5)
 ;;   jg label1
 ;; block1:
-;;   br %r14
\ No newline at end of file
+;;   br %r14
diff --git a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat
index 927d19e06..e84586b28 100644
--- a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat
@@ -54,16 +54,15 @@
 ;;   unwind SaveReg { clobber_offset: 120, reg: p15i }
 ;;   unwind StackAlloc { size: 0 }
 ;; block0:
-;;   llgfr %r2, %r2
-;;   lghi %r5, -4100
-;;   ag %r5, 8(%r4)
-;;   lgr %r7, %r2
-;;   ag %r7, 0(%r4)
-;;   aghik %r4, %r7, 4096
-;;   lghi %r6, 0
-;;   clgr %r2, %r5
-;;   locgrh %r4, %r6
-;;   strv %r3, 0(%r4)
+;;   llgfr %r6, %r2
+;;   lg %r5, 8(%r4)
+;;   lgr %r2, %r6
+;;   ag %r2, 0(%r4)
+;;   aghi %r2, 4096
+;;   lghi %r4, 0
+;;   clgr %r6, %r5
+;;   locgrh %r2, %r4
+;;   strv %r3, 0(%r2)
 ;;   jg label1
 ;; block1:
 ;;   lmg %r6, %r15, 48(%r15)
@@ -73,16 +72,15 @@
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 160, offset_downward_to_clobbers: 0 }
 ;;   unwind StackAlloc { size: 0 }
 ;; block0:
-;;   llgfr %r4, %r2
-;;   lghi %r5, -4100
-;;   ag %r5, 8(%r3)
-;;   lgr %r2, %r4
+;;   llgfr %r5, %r2
+;;   lg %r4, 8(%r3)
+;;   lgr %r2, %r5
 ;;   ag %r2, 0(%r3)
-;;   aghik %r3, %r2, 4096
-;;   lghi %r2, 0
-;;   clgr %r4, %r5
-;;   locgrh %r3, %r2
-;;   lrv %r2, 0(%r3)
+;;   aghi %r2, 4096
+;;   lghi %r3, 0
+;;   clgr %r5, %r4
+;;   locgrh %r2, %r3
+;;   lrv %r2, 0(%r2)
 ;;   jg label1
 ;; block1:
-;;   br %r14
\ No newline at end of file
+;;   br %r14
diff --git a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat
index 6318857db..53ce88183 100644
--- a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat
@@ -41,7 +41,9 @@
 
 ;; function u0:0:
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 160, offset_downward_to_clobbers: 0 }
-;;   stmg %r9, %r15, 72(%r15)
+;;   stmg %r7, %r15, 56(%r15)
+;;   unwind SaveReg { clobber_offset: 56, reg: p7i }
+;;   unwind SaveReg { clobber_offset: 64, reg: p8i }
 ;;   unwind SaveReg { clobber_offset: 72, reg: p9i }
 ;;   unwind SaveReg { clobber_offset: 80, reg: p10i }
 ;;   unwind SaveReg { clobber_offset: 88, reg: p11i }
@@ -51,43 +53,35 @@
 ;;   unwind SaveReg { clobber_offset: 120, reg: p15i }
 ;;   unwind StackAlloc { size: 0 }
 ;; block0:
-;;   lgr %r5, %r4
-;;   llgfr %r4, %r2
-;;   llilf %r9, 4294901764
-;;   algfr %r9, %r2
-;;   jle 6 ; trap
-;;   lgr %r2, %r5
-;;   lg %r5, 8(%r2)
-;;   ag %r4, 0(%r2)
-;;   llilh %r2, 65535
-;;   agr %r4, %r2
-;;   lghi %r2, 0
-;;   clgr %r9, %r5
-;;   locgrh %r4, %r2
-;;   strv %r3, 0(%r4)
+;;   llgfr %r7, %r2
+;;   lg %r5, 8(%r4)
+;;   lgr %r2, %r7
+;;   ag %r2, 0(%r4)
+;;   llilh %r4, 65535
+;;   agr %r2, %r4
+;;   lghi %r4, 0
+;;   clgr %r7, %r5
+;;   locgrh %r2, %r4
+;;   strv %r3, 0(%r2)
 ;;   jg label1
 ;; block1:
-;;   lmg %r9, %r15, 72(%r15)
+;;   lmg %r7, %r15, 56(%r15)
 ;;   br %r14
 ;;
 ;; function u0:1:
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 160, offset_downward_to_clobbers: 0 }
 ;;   unwind StackAlloc { size: 0 }
 ;; block0:
-;;   lgr %r4, %r3
-;;   llgfr %r3, %r2
-;;   llilf %r5, 4294901764
-;;   algfr %r5, %r2
-;;   jle 6 ; trap
+;;   llgfr %r4, %r2
+;;   lg %r5, 8(%r3)
 ;;   lgr %r2, %r4
-;;   lg %r4, 8(%r2)
-;;   ag %r3, 0(%r2)
-;;   llilh %r2, 65535
-;;   agr %r3, %r2
+;;   ag %r2, 0(%r3)
+;;   llilh %r3, 65535
+;;   agrk %r3, %r2, %r3
 ;;   lghi %r2, 0
-;;   clgr %r5, %r4
+;;   clgr %r4, %r5
 ;;   locgrh %r3, %r2
 ;;   lrv %r2, 0(%r3)
 ;;   jg label1
 ;; block1:
-;;   br %r14
\ No newline at end of file
+;;   br %r14
diff --git a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat
index 2c196b2c7..82a28ca0d 100644
--- a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat
@@ -54,16 +54,15 @@
 ;;   unwind SaveReg { clobber_offset: 120, reg: p15i }
 ;;   unwind StackAlloc { size: 0 }
 ;; block0:
-;;   llgfr %r2, %r2
-;;   lghi %r5, -4097
-;;   ag %r5, 8(%r4)
-;;   lgr %r7, %r2
-;;   ag %r7, 0(%r4)
-;;   aghik %r4, %r7, 4096
-;;   lghi %r6, 0
-;;   clgr %r2, %r5
-;;   locgrh %r4, %r6
-;;   stc %r3, 0(%r4)
+;;   llgfr %r6, %r2
+;;   lg %r5, 8(%r4)
+;;   lgr %r2, %r6
+;;   ag %r2, 0(%r4)
+;;   aghi %r2, 4096
+;;   lghi %r4, 0
+;;   clgr %r6, %r5
+;;   locgrh %r2, %r4
+;;   stc %r3, 0(%r2)
 ;;   jg label1
 ;; block1:
 ;;   lmg %r6, %r15, 48(%r15)
@@ -73,16 +72,15 @@
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 160, offset_downward_to_clobbers: 0 }
 ;;   unwind StackAlloc { size: 0 }
 ;; block0:
-;;   llgfr %r4, %r2
-;;   lghi %r5, -4097
-;;   ag %r5, 8(%r3)
-;;   lgr %r2, %r4
+;;   llgfr %r5, %r2
+;;   lg %r4, 8(%r3)
+;;   lgr %r2, %r5
 ;;   ag %r2, 0(%r3)
-;;   aghik %r3, %r2, 4096
-;;   lghi %r2, 0
-;;   clgr %r4, %r5
-;;   locgrh %r3, %r2
-;;   llc %r2, 0(%r3)
+;;   aghi %r2, 4096
+;;   lghi %r3, 0
+;;   clgr %r5, %r4
+;;   locgrh %r2, %r3
+;;   llc %r2, 0(%r2)
 ;;   jg label1
 ;; block1:
-;;   br %r14
\ No newline at end of file
+;;   br %r14
diff --git a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat
index 5c3b7162a..1bda827d8 100644
--- a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat
@@ -41,7 +41,9 @@
 
 ;; function u0:0:
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 160, offset_downward_to_clobbers: 0 }
-;;   stmg %r9, %r15, 72(%r15)
+;;   stmg %r7, %r15, 56(%r15)
+;;   unwind SaveReg { clobber_offset: 56, reg: p7i }
+;;   unwind SaveReg { clobber_offset: 64, reg: p8i }
 ;;   unwind SaveReg { clobber_offset: 72, reg: p9i }
 ;;   unwind SaveReg { clobber_offset: 80, reg: p10i }
 ;;   unwind SaveReg { clobber_offset: 88, reg: p11i }
@@ -51,43 +53,35 @@
 ;;   unwind SaveReg { clobber_offset: 120, reg: p15i }
 ;;   unwind StackAlloc { size: 0 }
 ;; block0:
-;;   lgr %r5, %r4
-;;   llgfr %r4, %r2
-;;   llilf %r9, 4294901761
-;;   algfr %r9, %r2
-;;   jle 6 ; trap
-;;   lgr %r2, %r5
-;;   lg %r5, 8(%r2)
-;;   ag %r4, 0(%r2)
-;;   llilh %r2, 65535
-;;   agr %r4, %r2
-;;   lghi %r2, 0
-;;   clgr %r9, %r5
-;;   locgrh %r4, %r2
-;;   stc %r3, 0(%r4)
+;;   llgfr %r7, %r2
+;;   lg %r5, 8(%r4)
+;;   lgr %r2, %r7
+;;   ag %r2, 0(%r4)
+;;   llilh %r4, 65535
+;;   agr %r2, %r4
+;;   lghi %r4, 0
+;;   clgr %r7, %r5
+;;   locgrh %r2, %r4
+;;   stc %r3, 0(%r2)
 ;;   jg label1
 ;; block1:
-;;   lmg %r9, %r15, 72(%r15)
+;;   lmg %r7, %r15, 56(%r15)
 ;;   br %r14
 ;;
 ;; function u0:1:
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 160, offset_downward_to_clobbers: 0 }
 ;;   unwind StackAlloc { size: 0 }
 ;; block0:
-;;   lgr %r4, %r3
-;;   llgfr %r3, %r2
-;;   llilf %r5, 4294901761
-;;   algfr %r5, %r2
-;;   jle 6 ; trap
+;;   llgfr %r4, %r2
+;;   lg %r5, 8(%r3)
 ;;   lgr %r2, %r4
-;;   lg %r4, 8(%r2)
-;;   ag %r3, 0(%r2)
-;;   llilh %r2, 65535
-;;   agr %r3, %r2
+;;   ag %r2, 0(%r3)
+;;   llilh %r3, 65535
+;;   agrk %r3, %r2, %r3
 ;;   lghi %r2, 0
-;;   clgr %r5, %r4
+;;   clgr %r4, %r5
 ;;   locgrh %r3, %r2
 ;;   llc %r2, 0(%r3)
 ;;   jg label1
 ;; block1:
-;;   br %r14
\ No newline at end of file
+;;   br %r14
diff --git a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat
index 2af148328..cf7df8397 100644
--- a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat
+++ b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat
@@ -43,13 +43,12 @@
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 160, offset_downward_to_clobbers: 0 }
 ;;   unwind StackAlloc { size: 0 }
 ;; block0:
-;;   lghi %r5, -4
-;;   ag %r5, 8(%r4)
+;;   lg %r5, 8(%r4)
 ;;   clgr %r2, %r5
 ;;   jgh label3 ; jg label1
 ;; block1:
-;;   lg %r4, 0(%r4)
-;;   strv %r3, 0(%r2,%r4)
+;;   lg %r5, 0(%r4)
+;;   strv %r3, 0(%r2,%r5)
 ;;   jg label2
 ;; block2:
 ;;   br %r14
@@ -60,13 +59,12 @@
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 160, offset_downward_to_clobbers: 0 }
 ;;   unwind StackAlloc { size: 0 }
 ;; block0:
-;;   lghi %r4, -4
-;;   ag %r4, 8(%r3)
+;;   lg %r4, 8(%r3)
 ;;   clgr %r2, %r4
 ;;   jgh label3 ; jg label1
 ;; block1:
-;;   lg %r3, 0(%r3)
-;;   lrv %r2, 0(%r2,%r3)
+;;   lg %r5, 0(%r3)
+;;   lrv %r2, 0(%r2,%r5)
 ;;   jg label2
 ;; block2:
 ;;   br %r14
diff --git a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat
index d50b81a28..47d32bb98 100644
--- a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat
@@ -43,15 +43,13 @@
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 160, offset_downward_to_clobbers: 0 }
 ;;   unwind StackAlloc { size: 0 }
 ;; block0:
-;;   lghi %r5, -4100
-;;   ag %r5, 8(%r4)
+;;   lg %r5, 8(%r4)
 ;;   clgr %r2, %r5
 ;;   jgh label3 ; jg label1
 ;; block1:
-;;   lgr %r5, %r2
-;;   ag %r5, 0(%r4)
+;;   ag %r2, 0(%r4)
 ;;   lghi %r4, 4096
-;;   strv %r3, 0(%r4,%r5)
+;;   strv %r3, 0(%r4,%r2)
 ;;   jg label2
 ;; block2:
 ;;   br %r14
@@ -62,15 +60,13 @@
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 160, offset_downward_to_clobbers: 0 }
 ;;   unwind StackAlloc { size: 0 }
 ;; block0:
-;;   lghi %r5, -4100
-;;   ag %r5, 8(%r3)
-;;   clgr %r2, %r5
+;;   lg %r4, 8(%r3)
+;;   clgr %r2, %r4
 ;;   jgh label3 ; jg label1
 ;; block1:
-;;   lgr %r4, %r2
-;;   ag %r4, 0(%r3)
-;;   lghi %r2, 4096
-;;   lrv %r2, 0(%r2,%r4)
+;;   ag %r2, 0(%r3)
+;;   lghi %r5, 4096
+;;   lrv %r2, 0(%r5,%r2)
 ;;   jg label2
 ;; block2:
 ;;   br %r14
diff --git a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat
index 99ca65c00..434de2925 100644
--- a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat
@@ -41,25 +41,17 @@
 
 ;; function u0:0:
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 160, offset_downward_to_clobbers: 0 }
-;;   stmg %r14, %r15, 112(%r15)
-;;   unwind SaveReg { clobber_offset: 112, reg: p14i }
-;;   unwind SaveReg { clobber_offset: 120, reg: p15i }
 ;;   unwind StackAlloc { size: 0 }
 ;; block0:
-;;   lgr %r5, %r2
-;;   algfi %r5, 4294901764
-;;   jle 6 ; trap
-;;   lg %r14, 8(%r4)
-;;   clgr %r5, %r14
+;;   lg %r5, 8(%r4)
+;;   clgr %r2, %r5
 ;;   jgh label3 ; jg label1
 ;; block1:
-;;   lgr %r5, %r2
-;;   ag %r5, 0(%r4)
+;;   ag %r2, 0(%r4)
 ;;   llilh %r4, 65535
-;;   strv %r3, 0(%r4,%r5)
+;;   strv %r3, 0(%r4,%r2)
 ;;   jg label2
 ;; block2:
-;;   lmg %r14, %r15, 112(%r15)
 ;;   br %r14
 ;; block3:
 ;;   trap
@@ -68,17 +60,13 @@
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 160, offset_downward_to_clobbers: 0 }
 ;;   unwind StackAlloc { size: 0 }
 ;; block0:
-;;   lgr %r5, %r2
-;;   algfi %r5, 4294901764
-;;   jle 6 ; trap
 ;;   lg %r4, 8(%r3)
-;;   clgr %r5, %r4
+;;   clgr %r2, %r4
 ;;   jgh label3 ; jg label1
 ;; block1:
-;;   lgr %r4, %r2
-;;   ag %r4, 0(%r3)
-;;   llilh %r3, 65535
-;;   lrv %r2, 0(%r3,%r4)
+;;   ag %r2, 0(%r3)
+;;   llilh %r5, 65535
+;;   lrv %r2, 0(%r5,%r2)
 ;;   jg label2
 ;; block2:
 ;;   br %r14
diff --git a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat
index 7d5c81e0a..9782d3a0d 100644
--- a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat
@@ -43,15 +43,13 @@
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 160, offset_downward_to_clobbers: 0 }
 ;;   unwind StackAlloc { size: 0 }
 ;; block0:
-;;   lghi %r5, -4097
-;;   ag %r5, 8(%r4)
+;;   lg %r5, 8(%r4)
 ;;   clgr %r2, %r5
 ;;   jgh label3 ; jg label1
 ;; block1:
-;;   lgr %r5, %r2
-;;   ag %r5, 0(%r4)
+;;   ag %r2, 0(%r4)
 ;;   lghi %r4, 4096
-;;   stc %r3, 0(%r4,%r5)
+;;   stc %r3, 0(%r4,%r2)
 ;;   jg label2
 ;; block2:
 ;;   br %r14
@@ -62,15 +60,13 @@
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 160, offset_downward_to_clobbers: 0 }
 ;;   unwind StackAlloc { size: 0 }
 ;; block0:
-;;   lghi %r5, -4097
-;;   ag %r5, 8(%r3)
-;;   clgr %r2, %r5
+;;   lg %r4, 8(%r3)
+;;   clgr %r2, %r4
 ;;   jgh label3 ; jg label1
 ;; block1:
-;;   lgr %r4, %r2
-;;   ag %r4, 0(%r3)
-;;   lghi %r2, 4096
-;;   llc %r2, 0(%r2,%r4)
+;;   ag %r2, 0(%r3)
+;;   lghi %r5, 4096
+;;   llc %r2, 0(%r5,%r2)
 ;;   jg label2
 ;; block2:
 ;;   br %r14
diff --git a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat
index 1eaa3219b..2e68c2e53 100644
--- a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat
@@ -41,25 +41,17 @@
 
 ;; function u0:0:
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 160, offset_downward_to_clobbers: 0 }
-;;   stmg %r14, %r15, 112(%r15)
-;;   unwind SaveReg { clobber_offset: 112, reg: p14i }
-;;   unwind SaveReg { clobber_offset: 120, reg: p15i }
 ;;   unwind StackAlloc { size: 0 }
 ;; block0:
-;;   lgr %r5, %r2
-;;   algfi %r5, 4294901761
-;;   jle 6 ; trap
-;;   lg %r14, 8(%r4)
-;;   clgr %r5, %r14
+;;   lg %r5, 8(%r4)
+;;   clgr %r2, %r5
 ;;   jgh label3 ; jg label1
 ;; block1:
-;;   lgr %r5, %r2
-;;   ag %r5, 0(%r4)
+;;   ag %r2, 0(%r4)
 ;;   llilh %r4, 65535
-;;   stc %r3, 0(%r4,%r5)
+;;   stc %r3, 0(%r4,%r2)
 ;;   jg label2
 ;; block2:
-;;   lmg %r14, %r15, 112(%r15)
 ;;   br %r14
 ;; block3:
 ;;   trap
@@ -68,17 +60,13 @@
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 160, offset_downward_to_clobbers: 0 }
 ;;   unwind StackAlloc { size: 0 }
 ;; block0:
-;;   lgr %r5, %r2
-;;   algfi %r5, 4294901761
-;;   jle 6 ; trap
 ;;   lg %r4, 8(%r3)
-;;   clgr %r5, %r4
+;;   clgr %r2, %r4
 ;;   jgh label3 ; jg label1
 ;; block1:
-;;   lgr %r4, %r2
-;;   ag %r4, 0(%r3)
-;;   llilh %r3, 65535
-;;   llc %r2, 0(%r3,%r4)
+;;   ag %r2, 0(%r3)
+;;   llilh %r5, 65535
+;;   llc %r2, 0(%r5,%r2)
 ;;   jg label2
 ;; block2:
 ;;   br %r14
diff --git a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat
index f8d6f839e..22ff765aa 100644
--- a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat
+++ b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat
@@ -41,46 +41,36 @@
 
 ;; function u0:0:
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 160, offset_downward_to_clobbers: 0 }
-;;   stmg %r7, %r15, 56(%r15)
-;;   unwind SaveReg { clobber_offset: 56, reg: p7i }
-;;   unwind SaveReg { clobber_offset: 64, reg: p8i }
-;;   unwind SaveReg { clobber_offset: 72, reg: p9i }
-;;   unwind SaveReg { clobber_offset: 80, reg: p10i }
-;;   unwind SaveReg { clobber_offset: 88, reg: p11i }
+;;   stmg %r12, %r15, 96(%r15)
 ;;   unwind SaveReg { clobber_offset: 96, reg: p12i }
 ;;   unwind SaveReg { clobber_offset: 104, reg: p13i }
 ;;   unwind SaveReg { clobber_offset: 112, reg: p14i }
 ;;   unwind SaveReg { clobber_offset: 120, reg: p15i }
 ;;   unwind StackAlloc { size: 0 }
 ;; block0:
-;;   lgr %r5, %r4
-;;   lghi %r4, -4
-;;   lgr %r7, %r5
-;;   ag %r4, 8(%r7)
-;;   lgr %r5, %r2
-;;   ag %r5, 0(%r7)
-;;   lghi %r13, 0
-;;   clgr %r2, %r4
-;;   locgrh %r5, %r13
-;;   strv %r3, 0(%r5)
+;;   lg %r5, 8(%r4)
+;;   lgr %r13, %r2
+;;   ag %r13, 0(%r4)
+;;   lghi %r12, 0
+;;   clgr %r2, %r5
+;;   locgrh %r13, %r12
+;;   strv %r3, 0(%r13)
 ;;   jg label1
 ;; block1:
-;;   lmg %r7, %r15, 56(%r15)
+;;   lmg %r12, %r15, 96(%r15)
 ;;   br %r14
 ;;
 ;; function u0:1:
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 160, offset_downward_to_clobbers: 0 }
 ;;   unwind StackAlloc { size: 0 }
 ;; block0:
-;;   lgr %r4, %r3
-;;   lghi %r3, -4
-;;   ag %r3, 8(%r4)
-;;   lgr %r5, %r2
-;;   ag %r5, 0(%r4)
-;;   lghi %r4, 0
-;;   clgr %r2, %r3
-;;   locgrh %r5, %r4
-;;   lrv %r2, 0(%r5)
+;;   lg %r5, 8(%r3)
+;;   lgr %r4, %r2
+;;   ag %r4, 0(%r3)
+;;   lghi %r3, 0
+;;   clgr %r2, %r5
+;;   locgrh %r4, %r3
+;;   lrv %r2, 0(%r4)
 ;;   jg label1
 ;; block1:
-;;   br %r14
\ No newline at end of file
+;;   br %r14
diff --git a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat
index 2608bb055..c8f69cfca 100644
--- a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat
@@ -41,49 +41,41 @@
 
 ;; function u0:0:
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 160, offset_downward_to_clobbers: 0 }
-;;   stmg %r6, %r15, 48(%r15)
-;;   unwind SaveReg { clobber_offset: 48, reg: p6i }
-;;   unwind SaveReg { clobber_offset: 56, reg: p7i }
-;;   unwind SaveReg { clobber_offset: 64, reg: p8i }
-;;   unwind SaveReg { clobber_offset: 72, reg: p9i }
-;;   unwind SaveReg { clobber_offset: 80, reg: p10i }
-;;   unwind SaveReg { clobber_offset: 88, reg: p11i }
-;;   unwind SaveReg { clobber_offset: 96, reg: p12i }
+;;   stmg %r13, %r15, 104(%r15)
 ;;   unwind SaveReg { clobber_offset: 104, reg: p13i }
 ;;   unwind SaveReg { clobber_offset: 112, reg: p14i }
 ;;   unwind SaveReg { clobber_offset: 120, reg: p15i }
 ;;   unwind StackAlloc { size: 0 }
 ;; block0:
-;;   lgr %r5, %r4
-;;   lghi %r4, -4100
-;;   ag %r4, 8(%r5)
-;;   lgr %r6, %r2
-;;   ag %r6, 0(%r5)
-;;   aghik %r5, %r6, 4096
-;;   lghi %r14, 0
-;;   clgr %r2, %r4
-;;   locgrh %r5, %r14
+;;   lg %r14, 8(%r4)
+;;   lgr %r5, %r2
+;;   ag %r5, 0(%r4)
+;;   aghi %r5, 4096
+;;   lghi %r13, 0
+;;   clgr %r2, %r14
+;;   locgrh %r5, %r13
 ;;   strv %r3, 0(%r5)
 ;;   jg label1
 ;; block1:
-;;   lmg %r6, %r15, 48(%r15)
+;;   lmg %r13, %r15, 104(%r15)
 ;;   br %r14
 ;;
 ;; function u0:1:
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 160, offset_downward_to_clobbers: 0 }
+;;   stmg %r14, %r15, 112(%r15)
+;;   unwind SaveReg { clobber_offset: 112, reg: p14i }
+;;   unwind SaveReg { clobber_offset: 120, reg: p15i }
 ;;   unwind StackAlloc { size: 0 }
 ;; block0:
-;;   lgr %r4, %r3
-;;   lghi %r3, -4100
-;;   lgr %r5, %r4
-;;   ag %r3, 8(%r5)
+;;   lg %r14, 8(%r3)
 ;;   lgr %r4, %r2
-;;   ag %r4, 0(%r5)
-;;   aghi %r4, 4096
-;;   lghi %r5, 0
-;;   clgr %r2, %r3
-;;   locgrh %r4, %r5
-;;   lrv %r2, 0(%r4)
+;;   ag %r4, 0(%r3)
+;;   aghik %r5, %r4, 4096
+;;   lghi %r4, 0
+;;   clgr %r2, %r14
+;;   locgrh %r5, %r4
+;;   lrv %r2, 0(%r5)
 ;;   jg label1
 ;; block1:
-;;   br %r14
\ No newline at end of file
+;;   lmg %r14, %r15, 112(%r15)
+;;   br %r14
diff --git a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat
index 237c141ab..4fe8f62b5 100644
--- a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat
@@ -41,7 +41,8 @@
 
 ;; function u0:0:
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 160, offset_downward_to_clobbers: 0 }
-;;   stmg %r7, %r15, 56(%r15)
+;;   stmg %r6, %r15, 48(%r15)
+;;   unwind SaveReg { clobber_offset: 48, reg: p6i }
 ;;   unwind SaveReg { clobber_offset: 56, reg: p7i }
 ;;   unwind SaveReg { clobber_offset: 64, reg: p8i }
 ;;   unwind SaveReg { clobber_offset: 72, reg: p9i }
@@ -53,37 +54,45 @@
 ;;   unwind SaveReg { clobber_offset: 120, reg: p15i }
 ;;   unwind StackAlloc { size: 0 }
 ;; block0:
-;;   lgr %r7, %r2
-;;   algfi %r7, 4294901764
-;;   jle 6 ; trap
-;;   lg %r5, 8(%r4)
-;;   ag %r2, 0(%r4)
+;;   lg %r6, 8(%r4)
+;;   lgr %r5, %r2
+;;   ag %r5, 0(%r4)
 ;;   llilh %r4, 65535
-;;   agrk %r4, %r2, %r4
-;;   lghi %r2, 0
-;;   clgr %r7, %r5
-;;   locgrh %r4, %r2
-;;   strv %r3, 0(%r4)
+;;   agr %r5, %r4
+;;   lghi %r14, 0
+;;   clgr %r2, %r6
+;;   locgrh %r5, %r14
+;;   strv %r3, 0(%r5)
 ;;   jg label1
 ;; block1:
-;;   lmg %r7, %r15, 56(%r15)
+;;   lmg %r6, %r15, 48(%r15)
 ;;   br %r14
 ;;
 ;; function u0:1:
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 160, offset_downward_to_clobbers: 0 }
+;;   stmg %r6, %r15, 48(%r15)
+;;   unwind SaveReg { clobber_offset: 48, reg: p6i }
+;;   unwind SaveReg { clobber_offset: 56, reg: p7i }
+;;   unwind SaveReg { clobber_offset: 64, reg: p8i }
+;;   unwind SaveReg { clobber_offset: 72, reg: p9i }
+;;   unwind SaveReg { clobber_offset: 80, reg: p10i }
+;;   unwind SaveReg { clobber_offset: 88, reg: p11i }
+;;   unwind SaveReg { clobber_offset: 96, reg: p12i }
+;;   unwind SaveReg { clobber_offset: 104, reg: p13i }
+;;   unwind SaveReg { clobber_offset: 112, reg: p14i }
+;;   unwind SaveReg { clobber_offset: 120, reg: p15i }
 ;;   unwind StackAlloc { size: 0 }
 ;; block0:
+;;   lg %r6, 8(%r3)
 ;;   lgr %r4, %r2
-;;   algfi %r4, 4294901764
-;;   jle 6 ; trap
-;;   lg %r5, 8(%r3)
-;;   ag %r2, 0(%r3)
+;;   ag %r4, 0(%r3)
 ;;   llilh %r3, 65535
-;;   agr %r2, %r3
-;;   lghi %r3, 0
-;;   clgr %r4, %r5
-;;   locgrh %r2, %r3
-;;   lrv %r2, 0(%r2)
+;;   agr %r4, %r3
+;;   lghi %r5, 0
+;;   clgr %r2, %r6
+;;   locgrh %r4, %r5
+;;   lrv %r2, 0(%r4)
 ;;   jg label1
 ;; block1:
-;;   br %r14
\ No newline at end of file
+;;   lmg %r6, %r15, 48(%r15)
+;;   br %r14
diff --git a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat
index d5aac8b75..0e8196f8d 100644
--- a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat
@@ -41,49 +41,41 @@
 
 ;; function u0:0:
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 160, offset_downward_to_clobbers: 0 }
-;;   stmg %r6, %r15, 48(%r15)
-;;   unwind SaveReg { clobber_offset: 48, reg: p6i }
-;;   unwind SaveReg { clobber_offset: 56, reg: p7i }
-;;   unwind SaveReg { clobber_offset: 64, reg: p8i }
-;;   unwind SaveReg { clobber_offset: 72, reg: p9i }
-;;   unwind SaveReg { clobber_offset: 80, reg: p10i }
-;;   unwind SaveReg { clobber_offset: 88, reg: p11i }
-;;   unwind SaveReg { clobber_offset: 96, reg: p12i }
+;;   stmg %r13, %r15, 104(%r15)
 ;;   unwind SaveReg { clobber_offset: 104, reg: p13i }
 ;;   unwind SaveReg { clobber_offset: 112, reg: p14i }
 ;;   unwind SaveReg { clobber_offset: 120, reg: p15i }
 ;;   unwind StackAlloc { size: 0 }
 ;; block0:
-;;   lgr %r5, %r4
-;;   lghi %r4, -4097
-;;   ag %r4, 8(%r5)
-;;   lgr %r6, %r2
-;;   ag %r6, 0(%r5)
-;;   aghik %r5, %r6, 4096
-;;   lghi %r14, 0
-;;   clgr %r2, %r4
-;;   locgrh %r5, %r14
+;;   lg %r14, 8(%r4)
+;;   lgr %r5, %r2
+;;   ag %r5, 0(%r4)
+;;   aghi %r5, 4096
+;;   lghi %r13, 0
+;;   clgr %r2, %r14
+;;   locgrh %r5, %r13
 ;;   stc %r3, 0(%r5)
 ;;   jg label1
 ;; block1:
-;;   lmg %r6, %r15, 48(%r15)
+;;   lmg %r13, %r15, 104(%r15)
 ;;   br %r14
 ;;
 ;; function u0:1:
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 160, offset_downward_to_clobbers: 0 }
+;;   stmg %r14, %r15, 112(%r15)
+;;   unwind SaveReg { clobber_offset: 112, reg: p14i }
+;;   unwind SaveReg { clobber_offset: 120, reg: p15i }
 ;;   unwind StackAlloc { size: 0 }
 ;; block0:
-;;   lgr %r4, %r3
-;;   lghi %r3, -4097
-;;   lgr %r5, %r4
-;;   ag %r3, 8(%r5)
+;;   lg %r14, 8(%r3)
 ;;   lgr %r4, %r2
-;;   ag %r4, 0(%r5)
-;;   aghi %r4, 4096
-;;   lghi %r5, 0
-;;   clgr %r2, %r3
-;;   locgrh %r4, %r5
-;;   llc %r2, 0(%r4)
+;;   ag %r4, 0(%r3)
+;;   aghik %r5, %r4, 4096
+;;   lghi %r4, 0
+;;   clgr %r2, %r14
+;;   locgrh %r5, %r4
+;;   llc %r2, 0(%r5)
 ;;   jg label1
 ;; block1:
-;;   br %r14
\ No newline at end of file
+;;   lmg %r14, %r15, 112(%r15)
+;;   br %r14
diff --git a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat
index aa670baf3..75a9d70cc 100644
--- a/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/isa/s390x/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat
@@ -41,7 +41,8 @@
 
 ;; function u0:0:
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 160, offset_downward_to_clobbers: 0 }
-;;   stmg %r7, %r15, 56(%r15)
+;;   stmg %r6, %r15, 48(%r15)
+;;   unwind SaveReg { clobber_offset: 48, reg: p6i }
 ;;   unwind SaveReg { clobber_offset: 56, reg: p7i }
 ;;   unwind SaveReg { clobber_offset: 64, reg: p8i }
 ;;   unwind SaveReg { clobber_offset: 72, reg: p9i }
@@ -53,37 +54,45 @@
 ;;   unwind SaveReg { clobber_offset: 120, reg: p15i }
 ;;   unwind StackAlloc { size: 0 }
 ;; block0:
-;;   lgr %r7, %r2
-;;   algfi %r7, 4294901761
-;;   jle 6 ; trap
-;;   lg %r5, 8(%r4)
-;;   ag %r2, 0(%r4)
+;;   lg %r6, 8(%r4)
+;;   lgr %r5, %r2
+;;   ag %r5, 0(%r4)
 ;;   llilh %r4, 65535
-;;   agrk %r4, %r2, %r4
-;;   lghi %r2, 0
-;;   clgr %r7, %r5
-;;   locgrh %r4, %r2
-;;   stc %r3, 0(%r4)
+;;   agr %r5, %r4
+;;   lghi %r14, 0
+;;   clgr %r2, %r6
+;;   locgrh %r5, %r14
+;;   stc %r3, 0(%r5)
 ;;   jg label1
 ;; block1:
-;;   lmg %r7, %r15, 56(%r15)
+;;   lmg %r6, %r15, 48(%r15)
 ;;   br %r14
 ;;
 ;; function u0:1:
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 160, offset_downward_to_clobbers: 0 }
+;;   stmg %r6, %r15, 48(%r15)
+;;   unwind SaveReg { clobber_offset: 48, reg: p6i }
+;;   unwind SaveReg { clobber_offset: 56, reg: p7i }
+;;   unwind SaveReg { clobber_offset: 64, reg: p8i }
+;;   unwind SaveReg { clobber_offset: 72, reg: p9i }
+;;   unwind SaveReg { clobber_offset: 80, reg: p10i }
+;;   unwind SaveReg { clobber_offset: 88, reg: p11i }
+;;   unwind SaveReg { clobber_offset: 96, reg: p12i }
+;;   unwind SaveReg { clobber_offset: 104, reg: p13i }
+;;   unwind SaveReg { clobber_offset: 112, reg: p14i }
+;;   unwind SaveReg { clobber_offset: 120, reg: p15i }
 ;;   unwind StackAlloc { size: 0 }
 ;; block0:
+;;   lg %r6, 8(%r3)
 ;;   lgr %r4, %r2
-;;   algfi %r4, 4294901761
-;;   jle 6 ; trap
-;;   lg %r5, 8(%r3)
-;;   ag %r2, 0(%r3)
+;;   ag %r4, 0(%r3)
 ;;   llilh %r3, 65535
-;;   agr %r2, %r3
-;;   lghi %r3, 0
-;;   clgr %r4, %r5
-;;   locgrh %r2, %r3
-;;   llc %r2, 0(%r2)
+;;   agr %r4, %r3
+;;   lghi %r5, 0
+;;   clgr %r2, %r6
+;;   locgrh %r4, %r5
+;;   llc %r2, 0(%r4)
 ;;   jg label1
 ;; block1:
-;;   br %r14
\ No newline at end of file
+;;   lmg %r6, %r15, 48(%r15)
+;;   br %r14
diff --git a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat
index 553e76dbb..221ecbae6 100644
--- a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat
+++ b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat
@@ -45,14 +45,13 @@
 ;;   movq    %rsp, %rbp
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
-;;   movl    %edi, %r10d
-;;   movabsq $-4, %r11
-;;   addq    %r11, 8(%rdx), %r11
-;;   cmpq    %r11, %r10
+;;   movl    %edi, %r9d
+;;   movq    8(%rdx), %r10
+;;   cmpq    %r10, %r9
 ;;   jnbe    label3; j label1
 ;; block1:
-;;   movq    0(%rdx), %rdi
-;;   movl    %esi, 0(%rdi,%r10,1)
+;;   movq    0(%rdx), %r11
+;;   movl    %esi, 0(%r11,%r9,1)
 ;;   jmp     label2
 ;; block2:
 ;;   movq    %rbp, %rsp
@@ -67,14 +66,13 @@
 ;;   movq    %rsp, %rbp
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
-;;   movl    %edi, %r10d
-;;   movabsq $-4, %r11
-;;   addq    %r11, 8(%rsi), %r11
-;;   cmpq    %r11, %r10
+;;   movl    %edi, %r9d
+;;   movq    8(%rsi), %r10
+;;   cmpq    %r10, %r9
 ;;   jnbe    label3; j label1
 ;; block1:
-;;   movq    0(%rsi), %rsi
-;;   movl    0(%rsi,%r10,1), %eax
+;;   movq    0(%rsi), %r11
+;;   movl    0(%r11,%r9,1), %eax
 ;;   jmp     label2
 ;; block2:
 ;;   movq    %rbp, %rsp
diff --git a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat
index 20f4fd8fc..25bda2004 100644
--- a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat
@@ -45,14 +45,13 @@
 ;;   movq    %rsp, %rbp
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
-;;   movl    %edi, %r10d
-;;   movabsq $-4100, %r11
-;;   addq    %r11, 8(%rdx), %r11
-;;   cmpq    %r11, %r10
+;;   movl    %edi, %r9d
+;;   movq    8(%rdx), %r10
+;;   cmpq    %r10, %r9
 ;;   jnbe    label3; j label1
 ;; block1:
-;;   movq    0(%rdx), %rdi
-;;   movl    %esi, 4096(%rdi,%r10,1)
+;;   movq    0(%rdx), %r11
+;;   movl    %esi, 4096(%r11,%r9,1)
 ;;   jmp     label2
 ;; block2:
 ;;   movq    %rbp, %rsp
@@ -67,14 +66,13 @@
 ;;   movq    %rsp, %rbp
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
-;;   movl    %edi, %r10d
-;;   movabsq $-4100, %r11
-;;   addq    %r11, 8(%rsi), %r11
-;;   cmpq    %r11, %r10
+;;   movl    %edi, %r9d
+;;   movq    8(%rsi), %r10
+;;   cmpq    %r10, %r9
 ;;   jnbe    label3; j label1
 ;; block1:
-;;   movq    0(%rsi), %rsi
-;;   movl    4096(%rsi,%r10,1), %eax
+;;   movq    0(%rsi), %r11
+;;   movl    4096(%r11,%r9,1), %eax
 ;;   jmp     label2
 ;; block2:
 ;;   movq    %rbp, %rsp
diff --git a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat
index 2b8019e85..20f154347 100644
--- a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat
@@ -46,16 +46,13 @@
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
 ;;   movl    %edi, %r8d
-;;   movq    %r8, %r11
-;;   addq    %r11, const(0), %r11
-;;   jnb ; ud2 heap_oob ;
-;;   movq    8(%rdx), %rdi
-;;   cmpq    %rdi, %r11
+;;   movq    8(%rdx), %r10
+;;   cmpq    %r10, %r8
 ;;   jnbe    label3; j label1
 ;; block1:
 ;;   addq    %r8, 0(%rdx), %r8
-;;   movl    $-65536, %eax
-;;   movl    %esi, 0(%r8,%rax,1)
+;;   movl    $-65536, %edi
+;;   movl    %esi, 0(%r8,%rdi,1)
 ;;   jmp     label2
 ;; block2:
 ;;   movq    %rbp, %rsp
@@ -71,16 +68,13 @@
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
 ;;   movl    %edi, %r8d
-;;   movq    %r8, %r11
-;;   addq    %r11, const(0), %r11
-;;   jnb ; ud2 heap_oob ;
-;;   movq    8(%rsi), %rdi
-;;   cmpq    %rdi, %r11
+;;   movq    8(%rsi), %r10
+;;   cmpq    %r10, %r8
 ;;   jnbe    label3; j label1
 ;; block1:
 ;;   addq    %r8, 0(%rsi), %r8
-;;   movl    $-65536, %edi
-;;   movl    0(%r8,%rdi,1), %eax
+;;   movl    $-65536, %r11d
+;;   movl    0(%r8,%r11,1), %eax
 ;;   jmp     label2
 ;; block2:
 ;;   movq    %rbp, %rsp
diff --git a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat
index d3785344e..f9c64c890 100644
--- a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat
@@ -45,14 +45,13 @@
 ;;   movq    %rsp, %rbp
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
-;;   movl    %edi, %r10d
-;;   movabsq $-4097, %r11
-;;   addq    %r11, 8(%rdx), %r11
-;;   cmpq    %r11, %r10
+;;   movl    %edi, %r9d
+;;   movq    8(%rdx), %r10
+;;   cmpq    %r10, %r9
 ;;   jnbe    label3; j label1
 ;; block1:
-;;   movq    0(%rdx), %rdi
-;;   movb    %sil, 4096(%rdi,%r10,1)
+;;   movq    0(%rdx), %r11
+;;   movb    %sil, 4096(%r11,%r9,1)
 ;;   jmp     label2
 ;; block2:
 ;;   movq    %rbp, %rsp
@@ -67,14 +66,13 @@
 ;;   movq    %rsp, %rbp
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
-;;   movl    %edi, %r10d
-;;   movabsq $-4097, %r11
-;;   addq    %r11, 8(%rsi), %r11
-;;   cmpq    %r11, %r10
+;;   movl    %edi, %r9d
+;;   movq    8(%rsi), %r10
+;;   cmpq    %r10, %r9
 ;;   jnbe    label3; j label1
 ;; block1:
-;;   movq    0(%rsi), %rsi
-;;   movzbq  4096(%rsi,%r10,1), %rax
+;;   movq    0(%rsi), %r11
+;;   movzbq  4096(%r11,%r9,1), %rax
 ;;   jmp     label2
 ;; block2:
 ;;   movq    %rbp, %rsp
diff --git a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat
index 29ff03b82..e7fd0d0f0 100644
--- a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat
@@ -46,16 +46,13 @@
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
 ;;   movl    %edi, %r8d
-;;   movq    %r8, %r11
-;;   addq    %r11, const(0), %r11
-;;   jnb ; ud2 heap_oob ;
-;;   movq    8(%rdx), %rdi
-;;   cmpq    %rdi, %r11
+;;   movq    8(%rdx), %r10
+;;   cmpq    %r10, %r8
 ;;   jnbe    label3; j label1
 ;; block1:
 ;;   addq    %r8, 0(%rdx), %r8
-;;   movl    $-65536, %eax
-;;   movb    %sil, 0(%r8,%rax,1)
+;;   movl    $-65536, %edi
+;;   movb    %sil, 0(%r8,%rdi,1)
 ;;   jmp     label2
 ;; block2:
 ;;   movq    %rbp, %rsp
@@ -71,16 +68,13 @@
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
 ;;   movl    %edi, %r8d
-;;   movq    %r8, %r11
-;;   addq    %r11, const(0), %r11
-;;   jnb ; ud2 heap_oob ;
-;;   movq    8(%rsi), %rdi
-;;   cmpq    %rdi, %r11
+;;   movq    8(%rsi), %r10
+;;   cmpq    %r10, %r8
 ;;   jnbe    label3; j label1
 ;; block1:
 ;;   addq    %r8, 0(%rsi), %r8
-;;   movl    $-65536, %edi
-;;   movzbq  0(%r8,%rdi,1), %rax
+;;   movl    $-65536, %r11d
+;;   movzbq  0(%r8,%r11,1), %rax
 ;;   jmp     label2
 ;; block2:
 ;;   movq    %rbp, %rsp
diff --git a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat
index d8c802c7f..916816034 100644
--- a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat
+++ b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat
@@ -45,15 +45,14 @@
 ;;   movq    %rsp, %rbp
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
-;;   movl    %edi, %edi
-;;   movabsq $-4, %rax
-;;   addq    %rax, 8(%rdx), %rax
-;;   movq    %rdi, %r11
-;;   addq    %r11, 0(%rdx), %r11
-;;   xorq    %rcx, %rcx, %rcx
-;;   cmpq    %rax, %rdi
-;;   cmovnbeq %rcx, %r11, %r11
-;;   movl    %esi, 0(%r11)
+;;   movl    %edi, %r11d
+;;   movq    8(%rdx), %rdi
+;;   movq    %r11, %r10
+;;   addq    %r10, 0(%rdx), %r10
+;;   xorq    %rax, %rax, %rax
+;;   cmpq    %rdi, %r11
+;;   cmovnbeq %rax, %r10, %r10
+;;   movl    %esi, 0(%r10)
 ;;   jmp     label1
 ;; block1:
 ;;   movq    %rbp, %rsp
@@ -66,19 +65,16 @@
 ;;   movq    %rsp, %rbp
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
-;;   movq    %rsi, %rax
-;;   movl    %edi, %esi
-;;   movabsq $-4, %rdi
-;;   movq    %rax, %rcx
-;;   addq    %rdi, 8(%rcx), %rdi
-;;   movq    %rsi, %r11
-;;   addq    %r11, 0(%rcx), %r11
-;;   xorq    %rax, %rax, %rax
-;;   cmpq    %rdi, %rsi
-;;   cmovnbeq %rax, %r11, %r11
-;;   movl    0(%r11), %eax
+;;   movl    %edi, %r11d
+;;   movq    8(%rsi), %rdi
+;;   movq    %r11, %r10
+;;   addq    %r10, 0(%rsi), %r10
+;;   xorq    %rsi, %rsi, %rsi
+;;   cmpq    %rdi, %r11
+;;   cmovnbeq %rsi, %r10, %r10
+;;   movl    0(%r10), %eax
 ;;   jmp     label1
 ;; block1:
 ;;   movq    %rbp, %rsp
 ;;   popq    %rbp
-;;   ret
\ No newline at end of file
+;;   ret
diff --git a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat
index 9b8f9e4b3..d083b959b 100644
--- a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat
@@ -46,14 +46,13 @@
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
 ;;   movl    %edi, %edi
-;;   movabsq $-4100, %rax
-;;   addq    %rax, 8(%rdx), %rax
+;;   movq    8(%rdx), %rax
 ;;   movq    0(%rdx), %rcx
-;;   lea     4096(%rcx,%rdi,1), %rcx
-;;   xorq    %rdx, %rdx, %rdx
+;;   lea     4096(%rcx,%rdi,1), %r11
+;;   xorq    %rcx, %rcx, %rcx
 ;;   cmpq    %rax, %rdi
-;;   cmovnbeq %rdx, %rcx, %rcx
-;;   movl    %esi, 0(%rcx)
+;;   cmovnbeq %rcx, %r11, %r11
+;;   movl    %esi, 0(%r11)
 ;;   jmp     label1
 ;; block1:
 ;;   movq    %rbp, %rsp
@@ -66,15 +65,14 @@
 ;;   movq    %rsp, %rbp
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
-;;   movl    %edi, %edi
-;;   movabsq $-4100, %rax
-;;   addq    %rax, 8(%rsi), %rax
-;;   movq    0(%rsi), %rcx
-;;   lea     4096(%rcx,%rdi,1), %rsi
-;;   xorq    %rcx, %rcx, %rcx
-;;   cmpq    %rax, %rdi
-;;   cmovnbeq %rcx, %rsi, %rsi
-;;   movl    0(%rsi), %eax
+;;   movl    %edi, %ecx
+;;   movq    8(%rsi), %rdi
+;;   movq    0(%rsi), %rsi
+;;   lea     4096(%rsi,%rcx,1), %r11
+;;   xorq    %rax, %rax, %rax
+;;   cmpq    %rdi, %rcx
+;;   cmovnbeq %rax, %r11, %r11
+;;   movl    0(%r11), %eax
 ;;   jmp     label1
 ;; block1:
 ;;   movq    %rbp, %rsp
diff --git a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat
index 37401d352..809121cb0 100644
--- a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat
@@ -45,18 +45,16 @@
 ;;   movq    %rsp, %rbp
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
-;;   movl    %edi, %r11d
-;;   movq    %r11, %rax
-;;   addq    %rax, const(0), %rax
-;;   jnb ; ud2 heap_oob ;
-;;   movq    8(%rdx), %rcx
-;;   addq    %r11, 0(%rdx), %r11
+;;   movl    %edi, %edi
+;;   movq    8(%rdx), %rax
+;;   movq    %rdi, %rcx
+;;   addq    %rcx, 0(%rdx), %rcx
 ;;   movl    $-65536, %edx
-;;   lea     0(%r11,%rdx,1), %rdx
-;;   xorq    %r8, %r8, %r8
-;;   cmpq    %rcx, %rax
-;;   cmovnbeq %r8, %rdx, %rdx
-;;   movl    %esi, 0(%rdx)
+;;   lea     0(%rcx,%rdx,1), %rcx
+;;   xorq    %rdx, %rdx, %rdx
+;;   cmpq    %rax, %rdi
+;;   cmovnbeq %rdx, %rcx, %rcx
+;;   movl    %esi, 0(%rcx)
 ;;   jmp     label1
 ;; block1:
 ;;   movq    %rbp, %rsp
@@ -69,18 +67,16 @@
 ;;   movq    %rsp, %rbp
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
-;;   movl    %edi, %r11d
-;;   movq    %r11, %rax
-;;   addq    %rax, const(0), %rax
-;;   jnb ; ud2 heap_oob ;
-;;   movq    8(%rsi), %rcx
-;;   addq    %r11, 0(%rsi), %r11
-;;   movl    $-65536, %edx
-;;   lea     0(%r11,%rdx,1), %rdx
-;;   xorq    %r8, %r8, %r8
-;;   cmpq    %rcx, %rax
-;;   cmovnbeq %r8, %rdx, %rdx
-;;   movl    0(%rdx), %eax
+;;   movl    %edi, %edi
+;;   movq    8(%rsi), %rax
+;;   movq    %rdi, %rcx
+;;   addq    %rcx, 0(%rsi), %rcx
+;;   movl    $-65536, %esi
+;;   lea     0(%rcx,%rsi,1), %rsi
+;;   xorq    %rcx, %rcx, %rcx
+;;   cmpq    %rax, %rdi
+;;   cmovnbeq %rcx, %rsi, %rsi
+;;   movl    0(%rsi), %eax
 ;;   jmp     label1
 ;; block1:
 ;;   movq    %rbp, %rsp
diff --git a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat
index 99113750d..917aee92f 100644
--- a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat
@@ -46,14 +46,13 @@
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
 ;;   movl    %edi, %edi
-;;   movabsq $-4097, %rax
-;;   addq    %rax, 8(%rdx), %rax
+;;   movq    8(%rdx), %rax
 ;;   movq    0(%rdx), %rcx
-;;   lea     4096(%rcx,%rdi,1), %rcx
-;;   xorq    %rdx, %rdx, %rdx
+;;   lea     4096(%rcx,%rdi,1), %r11
+;;   xorq    %rcx, %rcx, %rcx
 ;;   cmpq    %rax, %rdi
-;;   cmovnbeq %rdx, %rcx, %rcx
-;;   movb    %sil, 0(%rcx)
+;;   cmovnbeq %rcx, %r11, %r11
+;;   movb    %sil, 0(%r11)
 ;;   jmp     label1
 ;; block1:
 ;;   movq    %rbp, %rsp
@@ -66,15 +65,14 @@
 ;;   movq    %rsp, %rbp
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
-;;   movl    %edi, %edi
-;;   movabsq $-4097, %rax
-;;   addq    %rax, 8(%rsi), %rax
-;;   movq    0(%rsi), %rcx
-;;   lea     4096(%rcx,%rdi,1), %rsi
-;;   xorq    %rcx, %rcx, %rcx
-;;   cmpq    %rax, %rdi
-;;   cmovnbeq %rcx, %rsi, %rsi
-;;   movzbq  0(%rsi), %rax
+;;   movl    %edi, %ecx
+;;   movq    8(%rsi), %rdi
+;;   movq    0(%rsi), %rsi
+;;   lea     4096(%rsi,%rcx,1), %r11
+;;   xorq    %rax, %rax, %rax
+;;   cmpq    %rdi, %rcx
+;;   cmovnbeq %rax, %r11, %r11
+;;   movzbq  0(%r11), %rax
 ;;   jmp     label1
 ;; block1:
 ;;   movq    %rbp, %rsp
diff --git a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat
index 05ca250ad..1efba8977 100644
--- a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat
@@ -45,18 +45,16 @@
 ;;   movq    %rsp, %rbp
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
-;;   movl    %edi, %r11d
-;;   movq    %r11, %rax
-;;   addq    %rax, const(0), %rax
-;;   jnb ; ud2 heap_oob ;
-;;   movq    8(%rdx), %rcx
-;;   addq    %r11, 0(%rdx), %r11
+;;   movl    %edi, %edi
+;;   movq    8(%rdx), %rax
+;;   movq    %rdi, %rcx
+;;   addq    %rcx, 0(%rdx), %rcx
 ;;   movl    $-65536, %edx
-;;   lea     0(%r11,%rdx,1), %rdx
-;;   xorq    %r8, %r8, %r8
-;;   cmpq    %rcx, %rax
-;;   cmovnbeq %r8, %rdx, %rdx
-;;   movb    %sil, 0(%rdx)
+;;   lea     0(%rcx,%rdx,1), %rcx
+;;   xorq    %rdx, %rdx, %rdx
+;;   cmpq    %rax, %rdi
+;;   cmovnbeq %rdx, %rcx, %rcx
+;;   movb    %sil, 0(%rcx)
 ;;   jmp     label1
 ;; block1:
 ;;   movq    %rbp, %rsp
@@ -69,18 +67,16 @@
 ;;   movq    %rsp, %rbp
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
-;;   movl    %edi, %r11d
-;;   movq    %r11, %rax
-;;   addq    %rax, const(0), %rax
-;;   jnb ; ud2 heap_oob ;
-;;   movq    8(%rsi), %rcx
-;;   addq    %r11, 0(%rsi), %r11
-;;   movl    $-65536, %edx
-;;   lea     0(%r11,%rdx,1), %rdx
-;;   xorq    %r8, %r8, %r8
-;;   cmpq    %rcx, %rax
-;;   cmovnbeq %r8, %rdx, %rdx
-;;   movzbq  0(%rdx), %rax
+;;   movl    %edi, %edi
+;;   movq    8(%rsi), %rax
+;;   movq    %rdi, %rcx
+;;   addq    %rcx, 0(%rsi), %rcx
+;;   movl    $-65536, %esi
+;;   lea     0(%rcx,%rsi,1), %rsi
+;;   xorq    %rcx, %rcx, %rcx
+;;   cmpq    %rax, %rdi
+;;   cmovnbeq %rcx, %rsi, %rsi
+;;   movzbq  0(%rsi), %rax
 ;;   jmp     label1
 ;; block1:
 ;;   movq    %rbp, %rsp
diff --git a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat
index e250215bb..73fef35ee 100644
--- a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat
+++ b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat
@@ -45,13 +45,12 @@
 ;;   movq    %rsp, %rbp
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
-;;   movabsq $-4, %r9
-;;   addq    %r9, 8(%rdx), %r9
-;;   cmpq    %r9, %rdi
+;;   movq    8(%rdx), %r8
+;;   cmpq    %r8, %rdi
 ;;   jnbe    label3; j label1
 ;; block1:
-;;   movq    0(%rdx), %r11
-;;   movl    %esi, 0(%r11,%rdi,1)
+;;   movq    0(%rdx), %r10
+;;   movl    %esi, 0(%r10,%rdi,1)
 ;;   jmp     label2
 ;; block2:
 ;;   movq    %rbp, %rsp
@@ -66,13 +65,12 @@
 ;;   movq    %rsp, %rbp
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
-;;   movabsq $-4, %r9
-;;   addq    %r9, 8(%rsi), %r9
-;;   cmpq    %r9, %rdi
+;;   movq    8(%rsi), %r8
+;;   cmpq    %r8, %rdi
 ;;   jnbe    label3; j label1
 ;; block1:
-;;   movq    0(%rsi), %r11
-;;   movl    0(%r11,%rdi,1), %eax
+;;   movq    0(%rsi), %r10
+;;   movl    0(%r10,%rdi,1), %eax
 ;;   jmp     label2
 ;; block2:
 ;;   movq    %rbp, %rsp
diff --git a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat
index 6372db6df..249d2ed6b 100644
--- a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat
@@ -45,13 +45,12 @@
 ;;   movq    %rsp, %rbp
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
-;;   movabsq $-4100, %r9
-;;   addq    %r9, 8(%rdx), %r9
-;;   cmpq    %r9, %rdi
+;;   movq    8(%rdx), %r8
+;;   cmpq    %r8, %rdi
 ;;   jnbe    label3; j label1
 ;; block1:
-;;   movq    0(%rdx), %r11
-;;   movl    %esi, 4096(%r11,%rdi,1)
+;;   movq    0(%rdx), %r10
+;;   movl    %esi, 4096(%r10,%rdi,1)
 ;;   jmp     label2
 ;; block2:
 ;;   movq    %rbp, %rsp
@@ -66,13 +65,12 @@
 ;;   movq    %rsp, %rbp
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
-;;   movabsq $-4100, %r9
-;;   addq    %r9, 8(%rsi), %r9
-;;   cmpq    %r9, %rdi
+;;   movq    8(%rsi), %r8
+;;   cmpq    %r8, %rdi
 ;;   jnbe    label3; j label1
 ;; block1:
-;;   movq    0(%rsi), %r11
-;;   movl    4096(%r11,%rdi,1), %eax
+;;   movq    0(%rsi), %r10
+;;   movl    4096(%r10,%rdi,1), %eax
 ;;   jmp     label2
 ;; block2:
 ;;   movq    %rbp, %rsp
diff --git a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat
index 95d01f56a..ffca63fbe 100644
--- a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat
@@ -45,16 +45,14 @@
 ;;   movq    %rsp, %rbp
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
-;;   movq    %rdi, %r10
-;;   addq    %r10, const(0), %r10
-;;   jnb ; ud2 heap_oob ;
-;;   movq    8(%rdx), %r11
-;;   cmpq    %r11, %r10
+;;   movq    8(%rdx), %r9
+;;   cmpq    %r9, %rdi
 ;;   jnbe    label3; j label1
 ;; block1:
-;;   addq    %rdi, 0(%rdx), %rdi
-;;   movl    $-65536, %eax
-;;   movl    %esi, 0(%rdi,%rax,1)
+;;   movq    %rdi, %r11
+;;   addq    %r11, 0(%rdx), %r11
+;;   movl    $-65536, %edi
+;;   movl    %esi, 0(%r11,%rdi,1)
 ;;   jmp     label2
 ;; block2:
 ;;   movq    %rbp, %rsp
@@ -69,16 +67,14 @@
 ;;   movq    %rsp, %rbp
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
-;;   movq    %rdi, %r10
-;;   addq    %r10, const(0), %r10
-;;   jnb ; ud2 heap_oob ;
-;;   movq    8(%rsi), %r11
-;;   cmpq    %r11, %r10
+;;   movq    8(%rsi), %r9
+;;   cmpq    %r9, %rdi
 ;;   jnbe    label3; j label1
 ;; block1:
-;;   addq    %rdi, 0(%rsi), %rdi
-;;   movl    $-65536, %esi
-;;   movl    0(%rdi,%rsi,1), %eax
+;;   movq    %rdi, %r11
+;;   addq    %r11, 0(%rsi), %r11
+;;   movl    $-65536, %r10d
+;;   movl    0(%r11,%r10,1), %eax
 ;;   jmp     label2
 ;; block2:
 ;;   movq    %rbp, %rsp
diff --git a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat
index 8e657b017..31864ae00 100644
--- a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat
@@ -45,13 +45,12 @@
 ;;   movq    %rsp, %rbp
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
-;;   movabsq $-4097, %r9
-;;   addq    %r9, 8(%rdx), %r9
-;;   cmpq    %r9, %rdi
+;;   movq    8(%rdx), %r8
+;;   cmpq    %r8, %rdi
 ;;   jnbe    label3; j label1
 ;; block1:
-;;   movq    0(%rdx), %r11
-;;   movb    %sil, 4096(%r11,%rdi,1)
+;;   movq    0(%rdx), %r10
+;;   movb    %sil, 4096(%r10,%rdi,1)
 ;;   jmp     label2
 ;; block2:
 ;;   movq    %rbp, %rsp
@@ -66,13 +65,12 @@
 ;;   movq    %rsp, %rbp
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
-;;   movabsq $-4097, %r9
-;;   addq    %r9, 8(%rsi), %r9
-;;   cmpq    %r9, %rdi
+;;   movq    8(%rsi), %r8
+;;   cmpq    %r8, %rdi
 ;;   jnbe    label3; j label1
 ;; block1:
-;;   movq    0(%rsi), %r11
-;;   movzbq  4096(%r11,%rdi,1), %rax
+;;   movq    0(%rsi), %r10
+;;   movzbq  4096(%r10,%rdi,1), %rax
 ;;   jmp     label2
 ;; block2:
 ;;   movq    %rbp, %rsp
diff --git a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat
index ebc17c889..59beae8c9 100644
--- a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat
@@ -45,16 +45,14 @@
 ;;   movq    %rsp, %rbp
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
-;;   movq    %rdi, %r10
-;;   addq    %r10, const(0), %r10
-;;   jnb ; ud2 heap_oob ;
-;;   movq    8(%rdx), %r11
-;;   cmpq    %r11, %r10
+;;   movq    8(%rdx), %r9
+;;   cmpq    %r9, %rdi
 ;;   jnbe    label3; j label1
 ;; block1:
-;;   addq    %rdi, 0(%rdx), %rdi
-;;   movl    $-65536, %eax
-;;   movb    %sil, 0(%rdi,%rax,1)
+;;   movq    %rdi, %r11
+;;   addq    %r11, 0(%rdx), %r11
+;;   movl    $-65536, %edi
+;;   movb    %sil, 0(%r11,%rdi,1)
 ;;   jmp     label2
 ;; block2:
 ;;   movq    %rbp, %rsp
@@ -69,16 +67,14 @@
 ;;   movq    %rsp, %rbp
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
-;;   movq    %rdi, %r10
-;;   addq    %r10, const(0), %r10
-;;   jnb ; ud2 heap_oob ;
-;;   movq    8(%rsi), %r11
-;;   cmpq    %r11, %r10
+;;   movq    8(%rsi), %r9
+;;   cmpq    %r9, %rdi
 ;;   jnbe    label3; j label1
 ;; block1:
-;;   addq    %rdi, 0(%rsi), %rdi
-;;   movl    $-65536, %esi
-;;   movzbq  0(%rdi,%rsi,1), %rax
+;;   movq    %rdi, %r11
+;;   addq    %r11, 0(%rsi), %r11
+;;   movl    $-65536, %r10d
+;;   movzbq  0(%r11,%r10,1), %rax
 ;;   jmp     label2
 ;; block2:
 ;;   movq    %rbp, %rsp
diff --git a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat
index 8dfbd5d9b..8919253b3 100644
--- a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat
+++ b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat
@@ -45,14 +45,13 @@
 ;;   movq    %rsp, %rbp
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
-;;   movabsq $-4, %r11
-;;   addq    %r11, 8(%rdx), %r11
-;;   movq    %rdi, %r10
-;;   addq    %r10, 0(%rdx), %r10
-;;   xorq    %rax, %rax, %rax
-;;   cmpq    %r11, %rdi
-;;   cmovnbeq %rax, %r10, %r10
-;;   movl    %esi, 0(%r10)
+;;   movq    8(%rdx), %r10
+;;   movq    %rdi, %r9
+;;   addq    %r9, 0(%rdx), %r9
+;;   xorq    %r11, %r11, %r11
+;;   cmpq    %r10, %rdi
+;;   cmovnbeq %r11, %r9, %r9
+;;   movl    %esi, 0(%r9)
 ;;   jmp     label1
 ;; block1:
 ;;   movq    %rbp, %rsp
@@ -65,16 +64,15 @@
 ;;   movq    %rsp, %rbp
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
-;;   movabsq $-4, %r11
-;;   addq    %r11, 8(%rsi), %r11
-;;   movq    %rdi, %r10
-;;   addq    %r10, 0(%rsi), %r10
-;;   xorq    %rsi, %rsi, %rsi
-;;   cmpq    %r11, %rdi
-;;   cmovnbeq %rsi, %r10, %r10
-;;   movl    0(%r10), %eax
+;;   movq    8(%rsi), %r10
+;;   movq    %rdi, %r9
+;;   addq    %r9, 0(%rsi), %r9
+;;   xorq    %r11, %r11, %r11
+;;   cmpq    %r10, %rdi
+;;   cmovnbeq %r11, %r9, %r9
+;;   movl    0(%r9), %eax
 ;;   jmp     label1
 ;; block1:
 ;;   movq    %rbp, %rsp
 ;;   popq    %rbp
-;;   ret
\ No newline at end of file
+;;   ret
diff --git a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat
index 99f3c89c1..2d4182b73 100644
--- a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat
@@ -45,14 +45,13 @@
 ;;   movq    %rsp, %rbp
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
-;;   movabsq $-4100, %rax
-;;   addq    %rax, 8(%rdx), %rax
-;;   movq    0(%rdx), %rcx
-;;   lea     4096(%rcx,%rdi,1), %r11
-;;   xorq    %rcx, %rcx, %rcx
-;;   cmpq    %rax, %rdi
-;;   cmovnbeq %rcx, %r11, %r11
-;;   movl    %esi, 0(%r11)
+;;   movq    8(%rdx), %r11
+;;   movq    0(%rdx), %rax
+;;   lea     4096(%rax,%rdi,1), %r10
+;;   xorq    %rax, %rax, %rax
+;;   cmpq    %r11, %rdi
+;;   cmovnbeq %rax, %r10, %r10
+;;   movl    %esi, 0(%r10)
 ;;   jmp     label1
 ;; block1:
 ;;   movq    %rbp, %rsp
@@ -65,14 +64,13 @@
 ;;   movq    %rsp, %rbp
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
-;;   movabsq $-4100, %rcx
-;;   addq    %rcx, 8(%rsi), %rcx
+;;   movq    8(%rsi), %r11
 ;;   movq    0(%rsi), %rsi
-;;   lea     4096(%rsi,%rdi,1), %r11
-;;   xorq    %rax, %rax, %rax
-;;   cmpq    %rcx, %rdi
-;;   cmovnbeq %rax, %r11, %r11
-;;   movl    0(%r11), %eax
+;;   lea     4096(%rsi,%rdi,1), %r10
+;;   xorq    %rsi, %rsi, %rsi
+;;   cmpq    %r11, %rdi
+;;   cmovnbeq %rsi, %r10, %r10
+;;   movl    0(%r10), %eax
 ;;   jmp     label1
 ;; block1:
 ;;   movq    %rbp, %rsp
diff --git a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat
index 95a7e4aff..f9840da3b 100644
--- a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat
@@ -45,18 +45,15 @@
 ;;   movq    %rsp, %rbp
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
-;;   movq    %rdi, %r8
-;;   addq    %r8, const(0), %r8
-;;   jnb ; ud2 heap_oob ;
 ;;   movq    8(%rdx), %rax
 ;;   movq    %rdi, %rcx
 ;;   addq    %rcx, 0(%rdx), %rcx
-;;   movl    $-65536, %edi
-;;   lea     0(%rcx,%rdi,1), %rcx
-;;   xorq    %rdi, %rdi, %rdi
-;;   cmpq    %rax, %r8
-;;   cmovnbeq %rdi, %rcx, %rcx
-;;   movl    %esi, 0(%rcx)
+;;   movl    $-65536, %r11d
+;;   lea     0(%rcx,%r11,1), %r11
+;;   xorq    %rcx, %rcx, %rcx
+;;   cmpq    %rax, %rdi
+;;   cmovnbeq %rcx, %r11, %r11
+;;   movl    %esi, 0(%r11)
 ;;   jmp     label1
 ;; block1:
 ;;   movq    %rbp, %rsp
@@ -69,18 +66,15 @@
 ;;   movq    %rsp, %rbp
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
-;;   movq    %rdi, %rdx
-;;   addq    %rdx, const(0), %rdx
-;;   jnb ; ud2 heap_oob ;
-;;   movq    8(%rsi), %rax
-;;   movq    %rdi, %rcx
-;;   addq    %rcx, 0(%rsi), %rcx
-;;   movl    $-65536, %edi
-;;   lea     0(%rcx,%rdi,1), %rcx
-;;   xorq    %rdi, %rdi, %rdi
-;;   cmpq    %rax, %rdx
-;;   cmovnbeq %rdi, %rcx, %rcx
-;;   movl    0(%rcx), %eax
+;;   movq    8(%rsi), %rcx
+;;   movq    %rdi, %rax
+;;   addq    %rax, 0(%rsi), %rax
+;;   movl    $-65536, %r11d
+;;   lea     0(%rax,%r11,1), %r11
+;;   xorq    %rax, %rax, %rax
+;;   cmpq    %rcx, %rdi
+;;   cmovnbeq %rax, %r11, %r11
+;;   movl    0(%r11), %eax
 ;;   jmp     label1
 ;; block1:
 ;;   movq    %rbp, %rsp
diff --git a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat
index a0cffc83b..d0b1536e8 100644
--- a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat
@@ -45,14 +45,13 @@
 ;;   movq    %rsp, %rbp
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
-;;   movabsq $-4097, %rax
-;;   addq    %rax, 8(%rdx), %rax
-;;   movq    0(%rdx), %rcx
-;;   lea     4096(%rcx,%rdi,1), %r11
-;;   xorq    %rcx, %rcx, %rcx
-;;   cmpq    %rax, %rdi
-;;   cmovnbeq %rcx, %r11, %r11
-;;   movb    %sil, 0(%r11)
+;;   movq    8(%rdx), %r11
+;;   movq    0(%rdx), %rax
+;;   lea     4096(%rax,%rdi,1), %r10
+;;   xorq    %rax, %rax, %rax
+;;   cmpq    %r11, %rdi
+;;   cmovnbeq %rax, %r10, %r10
+;;   movb    %sil, 0(%r10)
 ;;   jmp     label1
 ;; block1:
 ;;   movq    %rbp, %rsp
@@ -65,14 +64,13 @@
 ;;   movq    %rsp, %rbp
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
-;;   movabsq $-4097, %rcx
-;;   addq    %rcx, 8(%rsi), %rcx
+;;   movq    8(%rsi), %r11
 ;;   movq    0(%rsi), %rsi
-;;   lea     4096(%rsi,%rdi,1), %r11
-;;   xorq    %rax, %rax, %rax
-;;   cmpq    %rcx, %rdi
-;;   cmovnbeq %rax, %r11, %r11
-;;   movzbq  0(%r11), %rax
+;;   lea     4096(%rsi,%rdi,1), %r10
+;;   xorq    %rsi, %rsi, %rsi
+;;   cmpq    %r11, %rdi
+;;   cmovnbeq %rsi, %r10, %r10
+;;   movzbq  0(%r10), %rax
 ;;   jmp     label1
 ;; block1:
 ;;   movq    %rbp, %rsp
diff --git a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat
index 20977fe01..870594b12 100644
--- a/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/isa/x64/wasm/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat
@@ -45,18 +45,15 @@
 ;;   movq    %rsp, %rbp
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
-;;   movq    %rdi, %r8
-;;   addq    %r8, const(0), %r8
-;;   jnb ; ud2 heap_oob ;
 ;;   movq    8(%rdx), %rax
 ;;   movq    %rdi, %rcx
 ;;   addq    %rcx, 0(%rdx), %rcx
-;;   movl    $-65536, %edi
-;;   lea     0(%rcx,%rdi,1), %rcx
-;;   xorq    %rdi, %rdi, %rdi
-;;   cmpq    %rax, %r8
-;;   cmovnbeq %rdi, %rcx, %rcx
-;;   movb    %sil, 0(%rcx)
+;;   movl    $-65536, %r11d
+;;   lea     0(%rcx,%r11,1), %r11
+;;   xorq    %rcx, %rcx, %rcx
+;;   cmpq    %rax, %rdi
+;;   cmovnbeq %rcx, %r11, %r11
+;;   movb    %sil, 0(%r11)
 ;;   jmp     label1
 ;; block1:
 ;;   movq    %rbp, %rsp
@@ -69,18 +66,15 @@
 ;;   movq    %rsp, %rbp
 ;;   unwind DefineNewFrame { offset_upward_to_caller_sp: 16, offset_downward_to_clobbers: 0 }
 ;; block0:
-;;   movq    %rdi, %rdx
-;;   addq    %rdx, const(0), %rdx
-;;   jnb ; ud2 heap_oob ;
-;;   movq    8(%rsi), %rax
-;;   movq    %rdi, %rcx
-;;   addq    %rcx, 0(%rsi), %rcx
-;;   movl    $-65536, %edi
-;;   lea     0(%rcx,%rdi,1), %rcx
-;;   xorq    %rdi, %rdi, %rdi
-;;   cmpq    %rax, %rdx
-;;   cmovnbeq %rdi, %rcx, %rcx
-;;   movzbq  0(%rcx), %rax
+;;   movq    8(%rsi), %rcx
+;;   movq    %rdi, %rax
+;;   addq    %rax, 0(%rsi), %rax
+;;   movl    $-65536, %r11d
+;;   lea     0(%rax,%r11,1), %r11
+;;   xorq    %rax, %rax, %rax
+;;   cmpq    %rcx, %rdi
+;;   cmovnbeq %rax, %r11, %r11
+;;   movzbq  0(%r11), %rax
 ;;   jmp     label1
 ;; block1:
 ;;   movq    %rbp, %rsp
diff --git a/cranelift/filetests/filetests/wasm/duplicate-loads-dynamic-memory-egraph.wat b/cranelift/filetests/filetests/wasm/duplicate-loads-dynamic-memory-egraph.wat
index b6d4e88dc..f62f9177b 100644
--- a/cranelift/filetests/filetests/wasm/duplicate-loads-dynamic-memory-egraph.wat
+++ b/cranelift/filetests/filetests/wasm/duplicate-loads-dynamic-memory-egraph.wat
@@ -49,21 +49,19 @@
 ;;     gv2 = load.i64 notrap aligned gv0
 ;;
 ;;                                 block0(v0: i32, v1: i64):
+;; @0057                               v5 = load.i64 notrap aligned v1+8
+;; @0057                               v6 = load.i64 notrap aligned v1
 ;; @0057                               v4 = uextend.i64 v0
-;; @0057                               v5 = iconst.i64 4
-;; @0057                               v6 = uadd_overflow_trap v4, v5, heap_oob  ; v5 = 4
-;; @0057                               v7 = load.i64 notrap aligned v1+8
-;; @0057                               v8 = load.i64 notrap aligned v1
-;; @0057                               v11 = icmp ugt v6, v7
-;; @0057                               v10 = iconst.i64 0
-;; @0057                               v9 = iadd v8, v4
-;; @0057                               v12 = select_spectre_guard v11, v10, v9  ; v10 = 0
-;; @0057                               v13 = load.i32 little heap v12
-;;                                     v2 -> v13
+;; @0057                               v9 = icmp ugt v4, v5
+;; @0057                               v8 = iconst.i64 0
+;; @0057                               v7 = iadd v6, v4
+;; @0057                               v10 = select_spectre_guard v9, v8, v7  ; v8 = 0
+;; @0057                               v11 = load.i32 little heap v10
+;;                                     v2 -> v11
 ;; @005f                               jump block1
 ;;
 ;;                                 block1:
-;; @005f                               return v13, v13
+;; @005f                               return v11, v11
 ;; }
 ;;
 ;; function u0:1(i32, i64 vmctx) -> i32, i32 fast {
@@ -72,21 +70,19 @@
 ;;     gv2 = load.i64 notrap aligned gv0
 ;;
 ;;                                 block0(v0: i32, v1: i64):
+;; @0064                               v5 = load.i64 notrap aligned v1+8
+;; @0064                               v6 = load.i64 notrap aligned v1
 ;; @0064                               v4 = uextend.i64 v0
-;; @0064                               v5 = iconst.i64 1238
-;; @0064                               v6 = uadd_overflow_trap v4, v5, heap_oob  ; v5 = 1238
-;; @0064                               v7 = load.i64 notrap aligned v1+8
-;; @0064                               v8 = load.i64 notrap aligned v1
-;; @0064                               v12 = icmp ugt v6, v7
-;; @0064                               v11 = iconst.i64 0
-;; @0064                               v9 = iadd v8, v4
-;;                                     v26 = iconst.i64 1234
-;; @0064                               v10 = iadd v9, v26  ; v26 = 1234
-;; @0064                               v13 = select_spectre_guard v12, v11, v10  ; v11 = 0
-;; @0064                               v14 = load.i32 little heap v13
-;;                                     v2 -> v14
+;; @0064                               v10 = icmp ugt v4, v5
+;; @0064                               v9 = iconst.i64 0
+;; @0064                               v7 = iadd v6, v4
+;;                                     v22 = iconst.i64 1234
+;; @0064                               v8 = iadd v7, v22  ; v22 = 1234
+;; @0064                               v11 = select_spectre_guard v10, v9, v8  ; v9 = 0
+;; @0064                               v12 = load.i32 little heap v11
+;;                                     v2 -> v12
 ;; @006e                               jump block1
 ;;
 ;;                                 block1:
-;; @006e                               return v14, v14
+;; @006e                               return v12, v12
 ;; }
diff --git a/cranelift/filetests/filetests/wasm/duplicate-loads-dynamic-memory.wat b/cranelift/filetests/filetests/wasm/duplicate-loads-dynamic-memory.wat
index ac5d606cd..c53a9cdfc 100644
--- a/cranelift/filetests/filetests/wasm/duplicate-loads-dynamic-memory.wat
+++ b/cranelift/filetests/filetests/wasm/duplicate-loads-dynamic-memory.wat
@@ -50,31 +50,27 @@
 ;;
 ;;                                 block0(v0: i32, v1: i64):
 ;; @0057                               v4 = uextend.i64 v0
-;;                                     v14 -> v4
-;; @0057                               v5 = iconst.i64 4
-;;                                     v15 -> v5
-;; @0057                               v6 = uadd_overflow_trap v4, v5, heap_oob  ; v5 = 4
-;;                                     v16 -> v6
-;; @0057                               v7 = load.i64 notrap aligned v1+8
-;;                                     v17 -> v7
-;; @0057                               v8 = load.i64 notrap aligned v1
-;;                                     v18 -> v8
-;; @0057                               v9 = iadd v8, v4
-;;                                     v19 -> v9
-;; @0057                               v10 = iconst.i64 0
-;;                                     v20 -> v10
-;; @0057                               v11 = icmp ugt v6, v7
-;;                                     v21 -> v11
-;; @0057                               v12 = select_spectre_guard v11, v10, v9  ; v10 = 0
-;;                                     v22 -> v12
-;; @0057                               v13 = load.i32 little heap v12
-;;                                     v2 -> v13
-;;                                     v23 -> v13
-;;                                     v3 -> v23
+;;                                     v12 -> v4
+;; @0057                               v5 = load.i64 notrap aligned v1+8
+;;                                     v13 -> v5
+;; @0057                               v6 = load.i64 notrap aligned v1
+;;                                     v14 -> v6
+;; @0057                               v7 = iadd v6, v4
+;;                                     v15 -> v7
+;; @0057                               v8 = iconst.i64 0
+;;                                     v16 -> v8
+;; @0057                               v9 = icmp ugt v4, v5
+;;                                     v17 -> v9
+;; @0057                               v10 = select_spectre_guard v9, v8, v7  ; v8 = 0
+;;                                     v18 -> v10
+;; @0057                               v11 = load.i32 little heap v10
+;;                                     v2 -> v11
+;;                                     v19 -> v11
+;;                                     v3 -> v19
 ;; @005f                               jump block1
 ;;
 ;;                                 block1:
-;; @005f                               return v13, v13
+;; @005f                               return v11, v11
 ;; }
 ;;
 ;; function u0:1(i32, i64 vmctx) -> i32, i32 fast {
@@ -84,33 +80,29 @@
 ;;
 ;;                                 block0(v0: i32, v1: i64):
 ;; @0064                               v4 = uextend.i64 v0
-;;                                     v15 -> v4
-;; @0064                               v5 = iconst.i64 1238
-;;                                     v16 -> v5
-;; @0064                               v6 = uadd_overflow_trap v4, v5, heap_oob  ; v5 = 1238
-;;                                     v17 -> v6
-;; @0064                               v7 = load.i64 notrap aligned v1+8
-;;                                     v18 -> v7
-;; @0064                               v8 = load.i64 notrap aligned v1
-;;                                     v19 -> v8
-;; @0064                               v9 = iadd v8, v4
-;;                                     v20 -> v9
-;;                                     v26 = iconst.i64 1234
-;;                                     v27 -> v26
-;; @0064                               v10 = iadd v9, v26  ; v26 = 1234
-;;                                     v21 -> v10
-;; @0064                               v11 = iconst.i64 0
-;;                                     v22 -> v11
-;; @0064                               v12 = icmp ugt v6, v7
-;;                                     v23 -> v12
-;; @0064                               v13 = select_spectre_guard v12, v11, v10  ; v11 = 0
-;;                                     v24 -> v13
-;; @0064                               v14 = load.i32 little heap v13
-;;                                     v2 -> v14
-;;                                     v25 -> v14
-;;                                     v3 -> v25
+;;                                     v13 -> v4
+;; @0064                               v5 = load.i64 notrap aligned v1+8
+;;                                     v14 -> v5
+;; @0064                               v6 = load.i64 notrap aligned v1
+;;                                     v15 -> v6
+;; @0064                               v7 = iadd v6, v4
+;;                                     v16 -> v7
+;;                                     v22 = iconst.i64 1234
+;;                                     v23 -> v22
+;; @0064                               v8 = iadd v7, v22  ; v22 = 1234
+;;                                     v17 -> v8
+;; @0064                               v9 = iconst.i64 0
+;;                                     v18 -> v9
+;; @0064                               v10 = icmp ugt v4, v5
+;;                                     v19 -> v10
+;; @0064                               v11 = select_spectre_guard v10, v9, v8  ; v9 = 0
+;;                                     v20 -> v11
+;; @0064                               v12 = load.i32 little heap v11
+;;                                     v2 -> v12
+;;                                     v21 -> v12
+;;                                     v3 -> v21
 ;; @006e                               jump block1
 ;;
 ;;                                 block1:
-;; @006e                               return v14, v14
+;; @006e                               return v12, v12
 ;; }
diff --git a/cranelift/filetests/filetests/wasm/dynamic-memory-no-spectre-access-same-index-different-offsets.wat b/cranelift/filetests/filetests/wasm/dynamic-memory-no-spectre-access-same-index-different-offsets.wat
new file mode 100644
index 000000000..14da1eb48
--- /dev/null
+++ b/cranelift/filetests/filetests/wasm/dynamic-memory-no-spectre-access-same-index-different-offsets.wat
@@ -0,0 +1,154 @@
+;;! target = "x86_64"
+;;!
+;;! optimize = true
+;;!
+;;! settings = [
+;;!   "enable_heap_access_spectre_mitigation=false",
+;;!   "opt_level=speed_and_size",
+;;!   "use_egraphs=true"
+;;! ]
+;;!
+;;! [globals.vmctx]
+;;! type = "i64"
+;;! vmctx = true
+;;!
+;;! [globals.heap_base]
+;;! type = "i64"
+;;! load = { base = "vmctx", offset = 0 }
+;;!
+;;! [globals.heap_bound]
+;;! type = "i64"
+;;! load = { base = "vmctx", offset = 8 }
+;;!
+;;! [[heaps]]
+;;! base = "heap_base"
+;;! min_size = 0
+;;! offset_guard_size = 0x0000ffff
+;;! index_type = "i32"
+;;! style = { kind = "dynamic", bound = "heap_bound" }
+
+(module
+  (memory (export "memory") 0)
+
+  (func (export "loads") (param i32) (result i32 i32 i32)
+    ;; Within the guard region.
+    local.get 0
+    i32.load offset=0
+    ;; Also within the guard region, bounds check should GVN with previous.
+    local.get 0
+    i32.load offset=4
+    ;; Outside the guard region, needs additional bounds checks.
+    local.get 0
+    i32.load offset=0x000fffff
+  )
+
+  ;; Same as above, but for stores.
+  (func (export "stores") (param i32 i32 i32 i32)
+    local.get 0
+    local.get 1
+    i32.store offset=0
+    local.get 0
+    local.get 2
+    i32.store offset=4
+    local.get 0
+    local.get 3
+    i32.store offset=0x000fffff
+  )
+)
+
+;; function u0:0(i32, i64 vmctx) -> i32, i32, i32 fast {
+;;     gv0 = vmctx
+;;     gv1 = load.i64 notrap aligned gv0+8
+;;     gv2 = load.i64 notrap aligned gv0
+;;
+;;                                 block0(v0: i32, v1: i64):
+;; @0047                               v6 = load.i64 notrap aligned v1+8
+;; @0047                               v5 = uextend.i64 v0
+;; @0047                               v7 = icmp ugt v5, v6
+;; @0047                               brif v7, block2, block3
+;;
+;;                                 block2 cold:
+;; @0047                               trap heap_oob
+;;
+;;                                 block3:
+;; @0047                               v8 = load.i64 notrap aligned v1
+;; @0047                               v9 = iadd v8, v5
+;; @0047                               v10 = load.i32 little heap v9
+;;                                     v2 -> v10
+;; @004c                               brif.i8 v7, block4, block5
+;;
+;;                                 block4 cold:
+;; @004c                               trap heap_oob
+;;
+;;                                 block5:
+;;                                     v27 = iconst.i64 4
+;; @004c                               v16 = iadd.i64 v9, v27  ; v27 = 4
+;; @004c                               v17 = load.i32 little heap v16
+;;                                     v3 -> v17
+;; @0051                               v19 = iconst.i64 0x0010_0003
+;; @0051                               v20 = uadd_overflow_trap.i64 v5, v19, heap_oob  ; v19 = 0x0010_0003
+;; @0051                               v22 = icmp ugt v20, v6
+;; @0051                               brif v22, block6, block7
+;;
+;;                                 block6 cold:
+;; @0051                               trap heap_oob
+;;
+;;                                 block7:
+;; @0051                               v23 = load.i64 notrap aligned v1
+;; @0051                               v24 = iadd v23, v5
+;;                                     v28 = iconst.i64 0x000f_ffff
+;; @0051                               v25 = iadd v24, v28  ; v28 = 0x000f_ffff
+;; @0051                               v26 = load.i32 little heap v25
+;;                                     v4 -> v26
+;; @0056                               jump block1
+;;
+;;                                 block1:
+;; @0056                               return v10, v17, v26
+;; }
+;;
+;; function u0:1(i32, i32, i32, i32, i64 vmctx) fast {
+;;     gv0 = vmctx
+;;     gv1 = load.i64 notrap aligned gv0+8
+;;     gv2 = load.i64 notrap aligned gv0
+;;
+;;                                 block0(v0: i32, v1: i32, v2: i32, v3: i32, v4: i64):
+;; @005d                               v6 = load.i64 notrap aligned v4+8
+;; @005d                               v5 = uextend.i64 v0
+;; @005d                               v7 = icmp ugt v5, v6
+;; @005d                               brif v7, block2, block3
+;;
+;;                                 block2 cold:
+;; @005d                               trap heap_oob
+;;
+;;                                 block3:
+;; @005d                               v8 = load.i64 notrap aligned v4
+;; @005d                               v9 = iadd v8, v5
+;; @005d                               store.i32 little heap v1, v9
+;; @0064                               brif.i8 v7, block4, block5
+;;
+;;                                 block4 cold:
+;; @0064                               trap heap_oob
+;;
+;;                                 block5:
+;;                                     v24 = iconst.i64 4
+;; @0064                               v15 = iadd.i64 v9, v24  ; v24 = 4
+;; @0064                               store.i32 little heap v2, v15
+;; @006b                               v17 = iconst.i64 0x0010_0003
+;; @006b                               v18 = uadd_overflow_trap.i64 v5, v17, heap_oob  ; v17 = 0x0010_0003
+;; @006b                               v20 = icmp ugt v18, v6
+;; @006b                               brif v20, block6, block7
+;;
+;;                                 block6 cold:
+;; @006b                               trap heap_oob
+;;
+;;                                 block7:
+;; @006b                               v21 = load.i64 notrap aligned v4
+;; @006b                               v22 = iadd v21, v5
+;;                                     v25 = iconst.i64 0x000f_ffff
+;; @006b                               v23 = iadd v22, v25  ; v25 = 0x000f_ffff
+;; @006b                               store.i32 little heap v3, v23
+;; @0070                               jump block1
+;;
+;;                                 block1:
+;; @0070                               return
+;; }
diff --git a/cranelift/filetests/filetests/wasm/dynamic-memory-yes-spectre-access-same-index-different-offsets.wat b/cranelift/filetests/filetests/wasm/dynamic-memory-yes-spectre-access-same-index-different-offsets.wat
new file mode 100644
index 000000000..8d8dbf5e5
--- /dev/null
+++ b/cranelift/filetests/filetests/wasm/dynamic-memory-yes-spectre-access-same-index-different-offsets.wat
@@ -0,0 +1,122 @@
+;;! target = "x86_64"
+;;!
+;;! optimize = true
+;;!
+;;! settings = [
+;;!   "enable_heap_access_spectre_mitigation=true",
+;;!   "opt_level=speed_and_size",
+;;!   "use_egraphs=true"
+;;! ]
+;;!
+;;! [globals.vmctx]
+;;! type = "i64"
+;;! vmctx = true
+;;!
+;;! [globals.heap_base]
+;;! type = "i64"
+;;! load = { base = "vmctx", offset = 0 }
+;;!
+;;! [globals.heap_bound]
+;;! type = "i64"
+;;! load = { base = "vmctx", offset = 8 }
+;;!
+;;! [[heaps]]
+;;! base = "heap_base"
+;;! min_size = 0
+;;! offset_guard_size = 0x0000ffff
+;;! index_type = "i32"
+;;! style = { kind = "dynamic", bound = "heap_bound" }
+
+(module
+  (memory (export "memory") 0)
+
+  (func (export "loads") (param i32) (result i32 i32 i32)
+    ;; Within the guard region.
+    local.get 0
+    i32.load offset=0
+    ;; Also within the guard region, bounds check should GVN with previous.
+    local.get 0
+    i32.load offset=4
+    ;; Outside the guard region, needs additional bounds checks.
+    local.get 0
+    i32.load offset=0x000fffff
+  )
+
+  ;; Same as above, but for stores.
+  (func (export "stores") (param i32 i32 i32 i32)
+    local.get 0
+    local.get 1
+    i32.store offset=0
+    local.get 0
+    local.get 2
+    i32.store offset=4
+    local.get 0
+    local.get 3
+    i32.store offset=0x000fffff
+  )
+)
+
+;; function u0:0(i32, i64 vmctx) -> i32, i32, i32 fast {
+;;     gv0 = vmctx
+;;     gv1 = load.i64 notrap aligned gv0+8
+;;     gv2 = load.i64 notrap aligned gv0
+;;
+;;                                 block0(v0: i32, v1: i64):
+;; @0047                               v6 = load.i64 notrap aligned v1+8
+;; @0047                               v7 = load.i64 notrap aligned v1
+;; @0047                               v5 = uextend.i64 v0
+;; @0047                               v10 = icmp ugt v5, v6
+;; @0047                               v9 = iconst.i64 0
+;; @0047                               v8 = iadd v7, v5
+;; @0047                               v11 = select_spectre_guard v10, v9, v8  ; v9 = 0
+;; @0047                               v12 = load.i32 little heap v11
+;;                                     v2 -> v12
+;;                                     v33 = iconst.i64 4
+;; @004c                               v17 = iadd v8, v33  ; v33 = 4
+;; @004c                               v20 = select_spectre_guard v10, v9, v17  ; v9 = 0
+;; @004c                               v21 = load.i32 little heap v20
+;;                                     v3 -> v21
+;; @0051                               v23 = iconst.i64 0x0010_0003
+;; @0051                               v24 = uadd_overflow_trap v5, v23, heap_oob  ; v23 = 0x0010_0003
+;; @0051                               v30 = icmp ugt v24, v6
+;;                                     v34 = iconst.i64 0x000f_ffff
+;; @0051                               v28 = iadd v8, v34  ; v34 = 0x000f_ffff
+;; @0051                               v31 = select_spectre_guard v30, v9, v28  ; v9 = 0
+;; @0051                               v32 = load.i32 little heap v31
+;;                                     v4 -> v32
+;; @0056                               jump block1
+;;
+;;                                 block1:
+;; @0056                               return v12, v21, v32
+;; }
+;;
+;; function u0:1(i32, i32, i32, i32, i64 vmctx) fast {
+;;     gv0 = vmctx
+;;     gv1 = load.i64 notrap aligned gv0+8
+;;     gv2 = load.i64 notrap aligned gv0
+;;
+;;                                 block0(v0: i32, v1: i32, v2: i32, v3: i32, v4: i64):
+;; @005d                               v6 = load.i64 notrap aligned v4+8
+;; @005d                               v7 = load.i64 notrap aligned v4
+;; @005d                               v5 = uextend.i64 v0
+;; @005d                               v10 = icmp ugt v5, v6
+;; @005d                               v9 = iconst.i64 0
+;; @005d                               v8 = iadd v7, v5
+;; @005d                               v11 = select_spectre_guard v10, v9, v8  ; v9 = 0
+;; @005d                               store little heap v1, v11
+;;                                     v30 = iconst.i64 4
+;; @0064                               v16 = iadd v8, v30  ; v30 = 4
+;; @0064                               v19 = select_spectre_guard v10, v9, v16  ; v9 = 0
+;; @0064                               store little heap v2, v19
+;; @006b                               v21 = iconst.i64 0x0010_0003
+;; @006b                               v22 = uadd_overflow_trap v5, v21, heap_oob  ; v21 = 0x0010_0003
+;; @006b                               v28 = icmp ugt v22, v6
+;;                                     v31 = iconst.i64 0x000f_ffff
+;; @006b                               v26 = iadd v8, v31  ; v31 = 0x000f_ffff
+;; @006b                               v29 = select_spectre_guard v28, v9, v26  ; v9 = 0
+;; @006b                               store little heap v3, v29
+;; @0070                               jump block1
+;;
+;;                                 block1:
+;; @0070                               return
+;; }
diff --git a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat
index 6a2591c83..84cf2e055 100644
--- a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat
+++ b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat
@@ -47,12 +47,11 @@
 ;;                                 block0(v0: i32, v1: i32, v2: i64):
 ;; @0040                               v3 = uextend.i64 v0
 ;; @0040                               v4 = global_value.i64 gv1
-;; @0040                               v5 = iadd_imm v4, -4
-;; @0040                               v6 = icmp ugt v3, v5
-;; @0040                               trapnz v6, heap_oob
-;; @0040                               v7 = global_value.i64 gv2
-;; @0040                               v8 = iadd v7, v3
-;; @0040                               store little heap v1, v8
+;; @0040                               v5 = icmp ugt v3, v4
+;; @0040                               trapnz v5, heap_oob
+;; @0040                               v6 = global_value.i64 gv2
+;; @0040                               v7 = iadd v6, v3
+;; @0040                               store little heap v1, v7
 ;; @0043                               jump block1
 ;;
 ;;                                 block1:
@@ -67,14 +66,13 @@
 ;;                                 block0(v0: i32, v1: i64):
 ;; @0048                               v3 = uextend.i64 v0
 ;; @0048                               v4 = global_value.i64 gv1
-;; @0048                               v5 = iadd_imm v4, -4
-;; @0048                               v6 = icmp ugt v3, v5
-;; @0048                               trapnz v6, heap_oob
-;; @0048                               v7 = global_value.i64 gv2
-;; @0048                               v8 = iadd v7, v3
-;; @0048                               v9 = load.i32 little heap v8
-;; @004b                               jump block1(v9)
+;; @0048                               v5 = icmp ugt v3, v4
+;; @0048                               trapnz v5, heap_oob
+;; @0048                               v6 = global_value.i64 gv2
+;; @0048                               v7 = iadd v6, v3
+;; @0048                               v8 = load.i32 little heap v7
+;; @004b                               jump block1(v8)
 ;;
 ;;                                 block1(v2: i32):
 ;; @004b                               return v2
-;; }
\ No newline at end of file
+;; }
diff --git a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat
index b4a0c8a35..830fcdb0e 100644
--- a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat
@@ -47,13 +47,12 @@
 ;;                                 block0(v0: i32, v1: i32, v2: i64):
 ;; @0040                               v3 = uextend.i64 v0
 ;; @0040                               v4 = global_value.i64 gv1
-;; @0040                               v5 = iadd_imm v4, -4100
-;; @0040                               v6 = icmp ugt v3, v5
-;; @0040                               trapnz v6, heap_oob
-;; @0040                               v7 = global_value.i64 gv2
-;; @0040                               v8 = iadd v7, v3
-;; @0040                               v9 = iadd_imm v8, 4096
-;; @0040                               store little heap v1, v9
+;; @0040                               v5 = icmp ugt v3, v4
+;; @0040                               trapnz v5, heap_oob
+;; @0040                               v6 = global_value.i64 gv2
+;; @0040                               v7 = iadd v6, v3
+;; @0040                               v8 = iadd_imm v7, 4096
+;; @0040                               store little heap v1, v8
 ;; @0044                               jump block1
 ;;
 ;;                                 block1:
@@ -68,15 +67,14 @@
 ;;                                 block0(v0: i32, v1: i64):
 ;; @0049                               v3 = uextend.i64 v0
 ;; @0049                               v4 = global_value.i64 gv1
-;; @0049                               v5 = iadd_imm v4, -4100
-;; @0049                               v6 = icmp ugt v3, v5
-;; @0049                               trapnz v6, heap_oob
-;; @0049                               v7 = global_value.i64 gv2
-;; @0049                               v8 = iadd v7, v3
-;; @0049                               v9 = iadd_imm v8, 4096
-;; @0049                               v10 = load.i32 little heap v9
-;; @004d                               jump block1(v10)
+;; @0049                               v5 = icmp ugt v3, v4
+;; @0049                               trapnz v5, heap_oob
+;; @0049                               v6 = global_value.i64 gv2
+;; @0049                               v7 = iadd v6, v3
+;; @0049                               v8 = iadd_imm v7, 4096
+;; @0049                               v9 = load.i32 little heap v8
+;; @004d                               jump block1(v9)
 ;;
 ;;                                 block1(v2: i32):
 ;; @004d                               return v2
-;; }
\ No newline at end of file
+;; }
diff --git a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat
index 0aa179059..56f3565d1 100644
--- a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat
@@ -46,15 +46,13 @@
 ;;
 ;;                                 block0(v0: i32, v1: i32, v2: i64):
 ;; @0040                               v3 = uextend.i64 v0
-;; @0040                               v4 = iconst.i64 0xffff_0004
-;; @0040                               v5 = uadd_overflow_trap v3, v4, heap_oob  ; v4 = 0xffff_0004
-;; @0040                               v6 = global_value.i64 gv1
-;; @0040                               v7 = icmp ugt v5, v6
-;; @0040                               trapnz v7, heap_oob
-;; @0040                               v8 = global_value.i64 gv2
-;; @0040                               v9 = iadd v8, v3
-;; @0040                               v10 = iadd_imm v9, 0xffff_0000
-;; @0040                               store little heap v1, v10
+;; @0040                               v4 = global_value.i64 gv1
+;; @0040                               v5 = icmp ugt v3, v4
+;; @0040                               trapnz v5, heap_oob
+;; @0040                               v6 = global_value.i64 gv2
+;; @0040                               v7 = iadd v6, v3
+;; @0040                               v8 = iadd_imm v7, 0xffff_0000
+;; @0040                               store little heap v1, v8
 ;; @0047                               jump block1
 ;;
 ;;                                 block1:
@@ -68,17 +66,15 @@
 ;;
 ;;                                 block0(v0: i32, v1: i64):
 ;; @004c                               v3 = uextend.i64 v0
-;; @004c                               v4 = iconst.i64 0xffff_0004
-;; @004c                               v5 = uadd_overflow_trap v3, v4, heap_oob  ; v4 = 0xffff_0004
-;; @004c                               v6 = global_value.i64 gv1
-;; @004c                               v7 = icmp ugt v5, v6
-;; @004c                               trapnz v7, heap_oob
-;; @004c                               v8 = global_value.i64 gv2
-;; @004c                               v9 = iadd v8, v3
-;; @004c                               v10 = iadd_imm v9, 0xffff_0000
-;; @004c                               v11 = load.i32 little heap v10
-;; @0053                               jump block1(v11)
+;; @004c                               v4 = global_value.i64 gv1
+;; @004c                               v5 = icmp ugt v3, v4
+;; @004c                               trapnz v5, heap_oob
+;; @004c                               v6 = global_value.i64 gv2
+;; @004c                               v7 = iadd v6, v3
+;; @004c                               v8 = iadd_imm v7, 0xffff_0000
+;; @004c                               v9 = load.i32 little heap v8
+;; @0053                               jump block1(v9)
 ;;
 ;;                                 block1(v2: i32):
 ;; @0053                               return v2
-;; }
\ No newline at end of file
+;; }
diff --git a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat
index b347cf95d..72a89f431 100644
--- a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat
@@ -47,13 +47,12 @@
 ;;                                 block0(v0: i32, v1: i32, v2: i64):
 ;; @0040                               v3 = uextend.i64 v0
 ;; @0040                               v4 = global_value.i64 gv1
-;; @0040                               v5 = iadd_imm v4, -4097
-;; @0040                               v6 = icmp ugt v3, v5
-;; @0040                               trapnz v6, heap_oob
-;; @0040                               v7 = global_value.i64 gv2
-;; @0040                               v8 = iadd v7, v3
-;; @0040                               v9 = iadd_imm v8, 4096
-;; @0040                               istore8 little heap v1, v9
+;; @0040                               v5 = icmp ugt v3, v4
+;; @0040                               trapnz v5, heap_oob
+;; @0040                               v6 = global_value.i64 gv2
+;; @0040                               v7 = iadd v6, v3
+;; @0040                               v8 = iadd_imm v7, 4096
+;; @0040                               istore8 little heap v1, v8
 ;; @0044                               jump block1
 ;;
 ;;                                 block1:
@@ -68,15 +67,14 @@
 ;;                                 block0(v0: i32, v1: i64):
 ;; @0049                               v3 = uextend.i64 v0
 ;; @0049                               v4 = global_value.i64 gv1
-;; @0049                               v5 = iadd_imm v4, -4097
-;; @0049                               v6 = icmp ugt v3, v5
-;; @0049                               trapnz v6, heap_oob
-;; @0049                               v7 = global_value.i64 gv2
-;; @0049                               v8 = iadd v7, v3
-;; @0049                               v9 = iadd_imm v8, 4096
-;; @0049                               v10 = uload8.i32 little heap v9
-;; @004d                               jump block1(v10)
+;; @0049                               v5 = icmp ugt v3, v4
+;; @0049                               trapnz v5, heap_oob
+;; @0049                               v6 = global_value.i64 gv2
+;; @0049                               v7 = iadd v6, v3
+;; @0049                               v8 = iadd_imm v7, 4096
+;; @0049                               v9 = uload8.i32 little heap v8
+;; @004d                               jump block1(v9)
 ;;
 ;;                                 block1(v2: i32):
 ;; @004d                               return v2
-;; }
\ No newline at end of file
+;; }
diff --git a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat
index fa2d6148a..ea033f97e 100644
--- a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat
@@ -46,15 +46,13 @@
 ;;
 ;;                                 block0(v0: i32, v1: i32, v2: i64):
 ;; @0040                               v3 = uextend.i64 v0
-;; @0040                               v4 = iconst.i64 0xffff_0001
-;; @0040                               v5 = uadd_overflow_trap v3, v4, heap_oob  ; v4 = 0xffff_0001
-;; @0040                               v6 = global_value.i64 gv1
-;; @0040                               v7 = icmp ugt v5, v6
-;; @0040                               trapnz v7, heap_oob
-;; @0040                               v8 = global_value.i64 gv2
-;; @0040                               v9 = iadd v8, v3
-;; @0040                               v10 = iadd_imm v9, 0xffff_0000
-;; @0040                               istore8 little heap v1, v10
+;; @0040                               v4 = global_value.i64 gv1
+;; @0040                               v5 = icmp ugt v3, v4
+;; @0040                               trapnz v5, heap_oob
+;; @0040                               v6 = global_value.i64 gv2
+;; @0040                               v7 = iadd v6, v3
+;; @0040                               v8 = iadd_imm v7, 0xffff_0000
+;; @0040                               istore8 little heap v1, v8
 ;; @0047                               jump block1
 ;;
 ;;                                 block1:
@@ -68,17 +66,15 @@
 ;;
 ;;                                 block0(v0: i32, v1: i64):
 ;; @004c                               v3 = uextend.i64 v0
-;; @004c                               v4 = iconst.i64 0xffff_0001
-;; @004c                               v5 = uadd_overflow_trap v3, v4, heap_oob  ; v4 = 0xffff_0001
-;; @004c                               v6 = global_value.i64 gv1
-;; @004c                               v7 = icmp ugt v5, v6
-;; @004c                               trapnz v7, heap_oob
-;; @004c                               v8 = global_value.i64 gv2
-;; @004c                               v9 = iadd v8, v3
-;; @004c                               v10 = iadd_imm v9, 0xffff_0000
-;; @004c                               v11 = uload8.i32 little heap v10
-;; @0053                               jump block1(v11)
+;; @004c                               v4 = global_value.i64 gv1
+;; @004c                               v5 = icmp ugt v3, v4
+;; @004c                               trapnz v5, heap_oob
+;; @004c                               v6 = global_value.i64 gv2
+;; @004c                               v7 = iadd v6, v3
+;; @004c                               v8 = iadd_imm v7, 0xffff_0000
+;; @004c                               v9 = uload8.i32 little heap v8
+;; @0053                               jump block1(v9)
 ;;
 ;;                                 block1(v2: i32):
 ;; @0053                               return v2
-;; }
\ No newline at end of file
+;; }
diff --git a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat
index 8e5914575..6d362cec2 100644
--- a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat
+++ b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat
@@ -47,13 +47,12 @@
 ;;                                 block0(v0: i32, v1: i32, v2: i64):
 ;; @0040                               v3 = uextend.i64 v0
 ;; @0040                               v4 = global_value.i64 gv1
-;; @0040                               v5 = iadd_imm v4, -4
-;; @0040                               v6 = global_value.i64 gv2
-;; @0040                               v7 = iadd v6, v3
-;; @0040                               v8 = iconst.i64 0
-;; @0040                               v9 = icmp ugt v3, v5
-;; @0040                               v10 = select_spectre_guard v9, v8, v7  ; v8 = 0
-;; @0040                               store little heap v1, v10
+;; @0040                               v5 = global_value.i64 gv2
+;; @0040                               v6 = iadd v5, v3
+;; @0040                               v7 = iconst.i64 0
+;; @0040                               v8 = icmp ugt v3, v4
+;; @0040                               v9 = select_spectre_guard v8, v7, v6  ; v7 = 0
+;; @0040                               store little heap v1, v9
 ;; @0043                               jump block1
 ;;
 ;;                                 block1:
@@ -68,15 +67,14 @@
 ;;                                 block0(v0: i32, v1: i64):
 ;; @0048                               v3 = uextend.i64 v0
 ;; @0048                               v4 = global_value.i64 gv1
-;; @0048                               v5 = iadd_imm v4, -4
-;; @0048                               v6 = global_value.i64 gv2
-;; @0048                               v7 = iadd v6, v3
-;; @0048                               v8 = iconst.i64 0
-;; @0048                               v9 = icmp ugt v3, v5
-;; @0048                               v10 = select_spectre_guard v9, v8, v7  ; v8 = 0
-;; @0048                               v11 = load.i32 little heap v10
-;; @004b                               jump block1(v11)
+;; @0048                               v5 = global_value.i64 gv2
+;; @0048                               v6 = iadd v5, v3
+;; @0048                               v7 = iconst.i64 0
+;; @0048                               v8 = icmp ugt v3, v4
+;; @0048                               v9 = select_spectre_guard v8, v7, v6  ; v7 = 0
+;; @0048                               v10 = load.i32 little heap v9
+;; @004b                               jump block1(v10)
 ;;
 ;;                                 block1(v2: i32):
 ;; @004b                               return v2
-;; }
\ No newline at end of file
+;; }
diff --git a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat
index 4ed3c951f..43905bc0d 100644
--- a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat
@@ -47,14 +47,13 @@
 ;;                                 block0(v0: i32, v1: i32, v2: i64):
 ;; @0040                               v3 = uextend.i64 v0
 ;; @0040                               v4 = global_value.i64 gv1
-;; @0040                               v5 = iadd_imm v4, -4100
-;; @0040                               v6 = global_value.i64 gv2
-;; @0040                               v7 = iadd v6, v3
-;; @0040                               v8 = iadd_imm v7, 4096
-;; @0040                               v9 = iconst.i64 0
-;; @0040                               v10 = icmp ugt v3, v5
-;; @0040                               v11 = select_spectre_guard v10, v9, v8  ; v9 = 0
-;; @0040                               store little heap v1, v11
+;; @0040                               v5 = global_value.i64 gv2
+;; @0040                               v6 = iadd v5, v3
+;; @0040                               v7 = iadd_imm v6, 4096
+;; @0040                               v8 = iconst.i64 0
+;; @0040                               v9 = icmp ugt v3, v4
+;; @0040                               v10 = select_spectre_guard v9, v8, v7  ; v8 = 0
+;; @0040                               store little heap v1, v10
 ;; @0044                               jump block1
 ;;
 ;;                                 block1:
@@ -69,16 +68,15 @@
 ;;                                 block0(v0: i32, v1: i64):
 ;; @0049                               v3 = uextend.i64 v0
 ;; @0049                               v4 = global_value.i64 gv1
-;; @0049                               v5 = iadd_imm v4, -4100
-;; @0049                               v6 = global_value.i64 gv2
-;; @0049                               v7 = iadd v6, v3
-;; @0049                               v8 = iadd_imm v7, 4096
-;; @0049                               v9 = iconst.i64 0
-;; @0049                               v10 = icmp ugt v3, v5
-;; @0049                               v11 = select_spectre_guard v10, v9, v8  ; v9 = 0
-;; @0049                               v12 = load.i32 little heap v11
-;; @004d                               jump block1(v12)
+;; @0049                               v5 = global_value.i64 gv2
+;; @0049                               v6 = iadd v5, v3
+;; @0049                               v7 = iadd_imm v6, 4096
+;; @0049                               v8 = iconst.i64 0
+;; @0049                               v9 = icmp ugt v3, v4
+;; @0049                               v10 = select_spectre_guard v9, v8, v7  ; v8 = 0
+;; @0049                               v11 = load.i32 little heap v10
+;; @004d                               jump block1(v11)
 ;;
 ;;                                 block1(v2: i32):
 ;; @004d                               return v2
-;; }
\ No newline at end of file
+;; }
diff --git a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat
index 5d127f03c..9b1e91d75 100644
--- a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat
@@ -46,16 +46,14 @@
 ;;
 ;;                                 block0(v0: i32, v1: i32, v2: i64):
 ;; @0040                               v3 = uextend.i64 v0
-;; @0040                               v4 = iconst.i64 0xffff_0004
-;; @0040                               v5 = uadd_overflow_trap v3, v4, heap_oob  ; v4 = 0xffff_0004
-;; @0040                               v6 = global_value.i64 gv1
-;; @0040                               v7 = global_value.i64 gv2
-;; @0040                               v8 = iadd v7, v3
-;; @0040                               v9 = iadd_imm v8, 0xffff_0000
-;; @0040                               v10 = iconst.i64 0
-;; @0040                               v11 = icmp ugt v5, v6
-;; @0040                               v12 = select_spectre_guard v11, v10, v9  ; v10 = 0
-;; @0040                               store little heap v1, v12
+;; @0040                               v4 = global_value.i64 gv1
+;; @0040                               v5 = global_value.i64 gv2
+;; @0040                               v6 = iadd v5, v3
+;; @0040                               v7 = iadd_imm v6, 0xffff_0000
+;; @0040                               v8 = iconst.i64 0
+;; @0040                               v9 = icmp ugt v3, v4
+;; @0040                               v10 = select_spectre_guard v9, v8, v7  ; v8 = 0
+;; @0040                               store little heap v1, v10
 ;; @0047                               jump block1
 ;;
 ;;                                 block1:
@@ -69,18 +67,16 @@
 ;;
 ;;                                 block0(v0: i32, v1: i64):
 ;; @004c                               v3 = uextend.i64 v0
-;; @004c                               v4 = iconst.i64 0xffff_0004
-;; @004c                               v5 = uadd_overflow_trap v3, v4, heap_oob  ; v4 = 0xffff_0004
-;; @004c                               v6 = global_value.i64 gv1
-;; @004c                               v7 = global_value.i64 gv2
-;; @004c                               v8 = iadd v7, v3
-;; @004c                               v9 = iadd_imm v8, 0xffff_0000
-;; @004c                               v10 = iconst.i64 0
-;; @004c                               v11 = icmp ugt v5, v6
-;; @004c                               v12 = select_spectre_guard v11, v10, v9  ; v10 = 0
-;; @004c                               v13 = load.i32 little heap v12
-;; @0053                               jump block1(v13)
+;; @004c                               v4 = global_value.i64 gv1
+;; @004c                               v5 = global_value.i64 gv2
+;; @004c                               v6 = iadd v5, v3
+;; @004c                               v7 = iadd_imm v6, 0xffff_0000
+;; @004c                               v8 = iconst.i64 0
+;; @004c                               v9 = icmp ugt v3, v4
+;; @004c                               v10 = select_spectre_guard v9, v8, v7  ; v8 = 0
+;; @004c                               v11 = load.i32 little heap v10
+;; @0053                               jump block1(v11)
 ;;
 ;;                                 block1(v2: i32):
 ;; @0053                               return v2
-;; }
\ No newline at end of file
+;; }
diff --git a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat
index bca09c667..fedeb318f 100644
--- a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat
@@ -47,14 +47,13 @@
 ;;                                 block0(v0: i32, v1: i32, v2: i64):
 ;; @0040                               v3 = uextend.i64 v0
 ;; @0040                               v4 = global_value.i64 gv1
-;; @0040                               v5 = iadd_imm v4, -4097
-;; @0040                               v6 = global_value.i64 gv2
-;; @0040                               v7 = iadd v6, v3
-;; @0040                               v8 = iadd_imm v7, 4096
-;; @0040                               v9 = iconst.i64 0
-;; @0040                               v10 = icmp ugt v3, v5
-;; @0040                               v11 = select_spectre_guard v10, v9, v8  ; v9 = 0
-;; @0040                               istore8 little heap v1, v11
+;; @0040                               v5 = global_value.i64 gv2
+;; @0040                               v6 = iadd v5, v3
+;; @0040                               v7 = iadd_imm v6, 4096
+;; @0040                               v8 = iconst.i64 0
+;; @0040                               v9 = icmp ugt v3, v4
+;; @0040                               v10 = select_spectre_guard v9, v8, v7  ; v8 = 0
+;; @0040                               istore8 little heap v1, v10
 ;; @0044                               jump block1
 ;;
 ;;                                 block1:
@@ -69,16 +68,15 @@
 ;;                                 block0(v0: i32, v1: i64):
 ;; @0049                               v3 = uextend.i64 v0
 ;; @0049                               v4 = global_value.i64 gv1
-;; @0049                               v5 = iadd_imm v4, -4097
-;; @0049                               v6 = global_value.i64 gv2
-;; @0049                               v7 = iadd v6, v3
-;; @0049                               v8 = iadd_imm v7, 4096
-;; @0049                               v9 = iconst.i64 0
-;; @0049                               v10 = icmp ugt v3, v5
-;; @0049                               v11 = select_spectre_guard v10, v9, v8  ; v9 = 0
-;; @0049                               v12 = uload8.i32 little heap v11
-;; @004d                               jump block1(v12)
+;; @0049                               v5 = global_value.i64 gv2
+;; @0049                               v6 = iadd v5, v3
+;; @0049                               v7 = iadd_imm v6, 4096
+;; @0049                               v8 = iconst.i64 0
+;; @0049                               v9 = icmp ugt v3, v4
+;; @0049                               v10 = select_spectre_guard v9, v8, v7  ; v8 = 0
+;; @0049                               v11 = uload8.i32 little heap v10
+;; @004d                               jump block1(v11)
 ;;
 ;;                                 block1(v2: i32):
 ;; @004d                               return v2
-;; }
\ No newline at end of file
+;; }
diff --git a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat
index db6d99ea1..ddc27afa2 100644
--- a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i32_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat
@@ -46,16 +46,14 @@
 ;;
 ;;                                 block0(v0: i32, v1: i32, v2: i64):
 ;; @0040                               v3 = uextend.i64 v0
-;; @0040                               v4 = iconst.i64 0xffff_0001
-;; @0040                               v5 = uadd_overflow_trap v3, v4, heap_oob  ; v4 = 0xffff_0001
-;; @0040                               v6 = global_value.i64 gv1
-;; @0040                               v7 = global_value.i64 gv2
-;; @0040                               v8 = iadd v7, v3
-;; @0040                               v9 = iadd_imm v8, 0xffff_0000
-;; @0040                               v10 = iconst.i64 0
-;; @0040                               v11 = icmp ugt v5, v6
-;; @0040                               v12 = select_spectre_guard v11, v10, v9  ; v10 = 0
-;; @0040                               istore8 little heap v1, v12
+;; @0040                               v4 = global_value.i64 gv1
+;; @0040                               v5 = global_value.i64 gv2
+;; @0040                               v6 = iadd v5, v3
+;; @0040                               v7 = iadd_imm v6, 0xffff_0000
+;; @0040                               v8 = iconst.i64 0
+;; @0040                               v9 = icmp ugt v3, v4
+;; @0040                               v10 = select_spectre_guard v9, v8, v7  ; v8 = 0
+;; @0040                               istore8 little heap v1, v10
 ;; @0047                               jump block1
 ;;
 ;;                                 block1:
@@ -69,18 +67,16 @@
 ;;
 ;;                                 block0(v0: i32, v1: i64):
 ;; @004c                               v3 = uextend.i64 v0
-;; @004c                               v4 = iconst.i64 0xffff_0001
-;; @004c                               v5 = uadd_overflow_trap v3, v4, heap_oob  ; v4 = 0xffff_0001
-;; @004c                               v6 = global_value.i64 gv1
-;; @004c                               v7 = global_value.i64 gv2
-;; @004c                               v8 = iadd v7, v3
-;; @004c                               v9 = iadd_imm v8, 0xffff_0000
-;; @004c                               v10 = iconst.i64 0
-;; @004c                               v11 = icmp ugt v5, v6
-;; @004c                               v12 = select_spectre_guard v11, v10, v9  ; v10 = 0
-;; @004c                               v13 = uload8.i32 little heap v12
-;; @0053                               jump block1(v13)
+;; @004c                               v4 = global_value.i64 gv1
+;; @004c                               v5 = global_value.i64 gv2
+;; @004c                               v6 = iadd v5, v3
+;; @004c                               v7 = iadd_imm v6, 0xffff_0000
+;; @004c                               v8 = iconst.i64 0
+;; @004c                               v9 = icmp ugt v3, v4
+;; @004c                               v10 = select_spectre_guard v9, v8, v7  ; v8 = 0
+;; @004c                               v11 = uload8.i32 little heap v10
+;; @0053                               jump block1(v11)
 ;;
 ;;                                 block1(v2: i32):
 ;; @0053                               return v2
-;; }
\ No newline at end of file
+;; }
diff --git a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat
index cab9f4241..656a44c14 100644
--- a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat
+++ b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0_offset.wat
@@ -46,12 +46,11 @@
 ;;
 ;;                                 block0(v0: i64, v1: i32, v2: i64):
 ;; @0040                               v3 = global_value.i64 gv1
-;; @0040                               v4 = iadd_imm v3, -4
-;; @0040                               v5 = icmp ugt v0, v4
-;; @0040                               trapnz v5, heap_oob
-;; @0040                               v6 = global_value.i64 gv2
-;; @0040                               v7 = iadd v6, v0
-;; @0040                               store little heap v1, v7
+;; @0040                               v4 = icmp ugt v0, v3
+;; @0040                               trapnz v4, heap_oob
+;; @0040                               v5 = global_value.i64 gv2
+;; @0040                               v6 = iadd v5, v0
+;; @0040                               store little heap v1, v6
 ;; @0043                               jump block1
 ;;
 ;;                                 block1:
@@ -65,14 +64,13 @@
 ;;
 ;;                                 block0(v0: i64, v1: i64):
 ;; @0048                               v3 = global_value.i64 gv1
-;; @0048                               v4 = iadd_imm v3, -4
-;; @0048                               v5 = icmp ugt v0, v4
-;; @0048                               trapnz v5, heap_oob
-;; @0048                               v6 = global_value.i64 gv2
-;; @0048                               v7 = iadd v6, v0
-;; @0048                               v8 = load.i32 little heap v7
-;; @004b                               jump block1(v8)
+;; @0048                               v4 = icmp ugt v0, v3
+;; @0048                               trapnz v4, heap_oob
+;; @0048                               v5 = global_value.i64 gv2
+;; @0048                               v6 = iadd v5, v0
+;; @0048                               v7 = load.i32 little heap v6
+;; @004b                               jump block1(v7)
 ;;
 ;;                                 block1(v2: i32):
 ;; @004b                               return v2
-;; }
\ No newline at end of file
+;; }
diff --git a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat
index e42f905fa..c8f3414ad 100644
--- a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0x1000_offset.wat
@@ -46,13 +46,12 @@
 ;;
 ;;                                 block0(v0: i64, v1: i32, v2: i64):
 ;; @0040                               v3 = global_value.i64 gv1
-;; @0040                               v4 = iadd_imm v3, -4100
-;; @0040                               v5 = icmp ugt v0, v4
-;; @0040                               trapnz v5, heap_oob
-;; @0040                               v6 = global_value.i64 gv2
-;; @0040                               v7 = iadd v6, v0
-;; @0040                               v8 = iadd_imm v7, 4096
-;; @0040                               store little heap v1, v8
+;; @0040                               v4 = icmp ugt v0, v3
+;; @0040                               trapnz v4, heap_oob
+;; @0040                               v5 = global_value.i64 gv2
+;; @0040                               v6 = iadd v5, v0
+;; @0040                               v7 = iadd_imm v6, 4096
+;; @0040                               store little heap v1, v7
 ;; @0044                               jump block1
 ;;
 ;;                                 block1:
@@ -66,15 +65,14 @@
 ;;
 ;;                                 block0(v0: i64, v1: i64):
 ;; @0049                               v3 = global_value.i64 gv1
-;; @0049                               v4 = iadd_imm v3, -4100
-;; @0049                               v5 = icmp ugt v0, v4
-;; @0049                               trapnz v5, heap_oob
-;; @0049                               v6 = global_value.i64 gv2
-;; @0049                               v7 = iadd v6, v0
-;; @0049                               v8 = iadd_imm v7, 4096
-;; @0049                               v9 = load.i32 little heap v8
-;; @004d                               jump block1(v9)
+;; @0049                               v4 = icmp ugt v0, v3
+;; @0049                               trapnz v4, heap_oob
+;; @0049                               v5 = global_value.i64 gv2
+;; @0049                               v6 = iadd v5, v0
+;; @0049                               v7 = iadd_imm v6, 4096
+;; @0049                               v8 = load.i32 little heap v7
+;; @004d                               jump block1(v8)
 ;;
 ;;                                 block1(v2: i32):
 ;; @004d                               return v2
-;; }
\ No newline at end of file
+;; }
diff --git a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat
index f581508ed..4f1f011e6 100644
--- a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i32_access_0xffff0000_offset.wat
@@ -45,15 +45,13 @@
 ;;     gv2 = load.i64 notrap aligned readonly gv0
 ;;
 ;;                                 block0(v0: i64, v1: i32, v2: i64):
-;; @0040                               v3 = iconst.i64 0xffff_0004
-;; @0040                               v4 = uadd_overflow_trap v0, v3, heap_oob  ; v3 = 0xffff_0004
-;; @0040                               v5 = global_value.i64 gv1
-;; @0040                               v6 = icmp ugt v4, v5
-;; @0040                               trapnz v6, heap_oob
-;; @0040                               v7 = global_value.i64 gv2
-;; @0040                               v8 = iadd v7, v0
-;; @0040                               v9 = iadd_imm v8, 0xffff_0000
-;; @0040                               store little heap v1, v9
+;; @0040                               v3 = global_value.i64 gv1
+;; @0040                               v4 = icmp ugt v0, v3
+;; @0040                               trapnz v4, heap_oob
+;; @0040                               v5 = global_value.i64 gv2
+;; @0040                               v6 = iadd v5, v0
+;; @0040                               v7 = iadd_imm v6, 0xffff_0000
+;; @0040                               store little heap v1, v7
 ;; @0047                               jump block1
 ;;
 ;;                                 block1:
@@ -66,17 +64,15 @@
 ;;     gv2 = load.i64 notrap aligned readonly gv0
 ;;
 ;;                                 block0(v0: i64, v1: i64):
-;; @004c                               v3 = iconst.i64 0xffff_0004
-;; @004c                               v4 = uadd_overflow_trap v0, v3, heap_oob  ; v3 = 0xffff_0004
-;; @004c                               v5 = global_value.i64 gv1
-;; @004c                               v6 = icmp ugt v4, v5
-;; @004c                               trapnz v6, heap_oob
-;; @004c                               v7 = global_value.i64 gv2
-;; @004c                               v8 = iadd v7, v0
-;; @004c                               v9 = iadd_imm v8, 0xffff_0000
-;; @004c                               v10 = load.i32 little heap v9
-;; @0053                               jump block1(v10)
+;; @004c                               v3 = global_value.i64 gv1
+;; @004c                               v4 = icmp ugt v0, v3
+;; @004c                               trapnz v4, heap_oob
+;; @004c                               v5 = global_value.i64 gv2
+;; @004c                               v6 = iadd v5, v0
+;; @004c                               v7 = iadd_imm v6, 0xffff_0000
+;; @004c                               v8 = load.i32 little heap v7
+;; @0053                               jump block1(v8)
 ;;
 ;;                                 block1(v2: i32):
 ;; @0053                               return v2
-;; }
\ No newline at end of file
+;; }
diff --git a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat
index 146f58b03..d25588855 100644
--- a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0x1000_offset.wat
@@ -46,13 +46,12 @@
 ;;
 ;;                                 block0(v0: i64, v1: i32, v2: i64):
 ;; @0040                               v3 = global_value.i64 gv1
-;; @0040                               v4 = iadd_imm v3, -4097
-;; @0040                               v5 = icmp ugt v0, v4
-;; @0040                               trapnz v5, heap_oob
-;; @0040                               v6 = global_value.i64 gv2
-;; @0040                               v7 = iadd v6, v0
-;; @0040                               v8 = iadd_imm v7, 4096
-;; @0040                               istore8 little heap v1, v8
+;; @0040                               v4 = icmp ugt v0, v3
+;; @0040                               trapnz v4, heap_oob
+;; @0040                               v5 = global_value.i64 gv2
+;; @0040                               v6 = iadd v5, v0
+;; @0040                               v7 = iadd_imm v6, 4096
+;; @0040                               istore8 little heap v1, v7
 ;; @0044                               jump block1
 ;;
 ;;                                 block1:
@@ -66,15 +65,14 @@
 ;;
 ;;                                 block0(v0: i64, v1: i64):
 ;; @0049                               v3 = global_value.i64 gv1
-;; @0049                               v4 = iadd_imm v3, -4097
-;; @0049                               v5 = icmp ugt v0, v4
-;; @0049                               trapnz v5, heap_oob
-;; @0049                               v6 = global_value.i64 gv2
-;; @0049                               v7 = iadd v6, v0
-;; @0049                               v8 = iadd_imm v7, 4096
-;; @0049                               v9 = uload8.i32 little heap v8
-;; @004d                               jump block1(v9)
+;; @0049                               v4 = icmp ugt v0, v3
+;; @0049                               trapnz v4, heap_oob
+;; @0049                               v5 = global_value.i64 gv2
+;; @0049                               v6 = iadd v5, v0
+;; @0049                               v7 = iadd_imm v6, 4096
+;; @0049                               v8 = uload8.i32 little heap v7
+;; @004d                               jump block1(v8)
 ;;
 ;;                                 block1(v2: i32):
 ;; @004d                               return v2
-;; }
\ No newline at end of file
+;; }
diff --git a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat
index 8e1e4b857..eadb8b32c 100644
--- a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_no_spectre_i8_access_0xffff0000_offset.wat
@@ -45,15 +45,13 @@
 ;;     gv2 = load.i64 notrap aligned readonly gv0
 ;;
 ;;                                 block0(v0: i64, v1: i32, v2: i64):
-;; @0040                               v3 = iconst.i64 0xffff_0001
-;; @0040                               v4 = uadd_overflow_trap v0, v3, heap_oob  ; v3 = 0xffff_0001
-;; @0040                               v5 = global_value.i64 gv1
-;; @0040                               v6 = icmp ugt v4, v5
-;; @0040                               trapnz v6, heap_oob
-;; @0040                               v7 = global_value.i64 gv2
-;; @0040                               v8 = iadd v7, v0
-;; @0040                               v9 = iadd_imm v8, 0xffff_0000
-;; @0040                               istore8 little heap v1, v9
+;; @0040                               v3 = global_value.i64 gv1
+;; @0040                               v4 = icmp ugt v0, v3
+;; @0040                               trapnz v4, heap_oob
+;; @0040                               v5 = global_value.i64 gv2
+;; @0040                               v6 = iadd v5, v0
+;; @0040                               v7 = iadd_imm v6, 0xffff_0000
+;; @0040                               istore8 little heap v1, v7
 ;; @0047                               jump block1
 ;;
 ;;                                 block1:
@@ -66,17 +64,15 @@
 ;;     gv2 = load.i64 notrap aligned readonly gv0
 ;;
 ;;                                 block0(v0: i64, v1: i64):
-;; @004c                               v3 = iconst.i64 0xffff_0001
-;; @004c                               v4 = uadd_overflow_trap v0, v3, heap_oob  ; v3 = 0xffff_0001
-;; @004c                               v5 = global_value.i64 gv1
-;; @004c                               v6 = icmp ugt v4, v5
-;; @004c                               trapnz v6, heap_oob
-;; @004c                               v7 = global_value.i64 gv2
-;; @004c                               v8 = iadd v7, v0
-;; @004c                               v9 = iadd_imm v8, 0xffff_0000
-;; @004c                               v10 = uload8.i32 little heap v9
-;; @0053                               jump block1(v10)
+;; @004c                               v3 = global_value.i64 gv1
+;; @004c                               v4 = icmp ugt v0, v3
+;; @004c                               trapnz v4, heap_oob
+;; @004c                               v5 = global_value.i64 gv2
+;; @004c                               v6 = iadd v5, v0
+;; @004c                               v7 = iadd_imm v6, 0xffff_0000
+;; @004c                               v8 = uload8.i32 little heap v7
+;; @0053                               jump block1(v8)
 ;;
 ;;                                 block1(v2: i32):
 ;; @0053                               return v2
-;; }
\ No newline at end of file
+;; }
diff --git a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat
index 57bfbfbc8..939fbfe87 100644
--- a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat
+++ b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0_offset.wat
@@ -46,13 +46,12 @@
 ;;
 ;;                                 block0(v0: i64, v1: i32, v2: i64):
 ;; @0040                               v3 = global_value.i64 gv1
-;; @0040                               v4 = iadd_imm v3, -4
-;; @0040                               v5 = global_value.i64 gv2
-;; @0040                               v6 = iadd v5, v0
-;; @0040                               v7 = iconst.i64 0
-;; @0040                               v8 = icmp ugt v0, v4
-;; @0040                               v9 = select_spectre_guard v8, v7, v6  ; v7 = 0
-;; @0040                               store little heap v1, v9
+;; @0040                               v4 = global_value.i64 gv2
+;; @0040                               v5 = iadd v4, v0
+;; @0040                               v6 = iconst.i64 0
+;; @0040                               v7 = icmp ugt v0, v3
+;; @0040                               v8 = select_spectre_guard v7, v6, v5  ; v6 = 0
+;; @0040                               store little heap v1, v8
 ;; @0043                               jump block1
 ;;
 ;;                                 block1:
@@ -66,15 +65,14 @@
 ;;
 ;;                                 block0(v0: i64, v1: i64):
 ;; @0048                               v3 = global_value.i64 gv1
-;; @0048                               v4 = iadd_imm v3, -4
-;; @0048                               v5 = global_value.i64 gv2
-;; @0048                               v6 = iadd v5, v0
-;; @0048                               v7 = iconst.i64 0
-;; @0048                               v8 = icmp ugt v0, v4
-;; @0048                               v9 = select_spectre_guard v8, v7, v6  ; v7 = 0
-;; @0048                               v10 = load.i32 little heap v9
-;; @004b                               jump block1(v10)
+;; @0048                               v4 = global_value.i64 gv2
+;; @0048                               v5 = iadd v4, v0
+;; @0048                               v6 = iconst.i64 0
+;; @0048                               v7 = icmp ugt v0, v3
+;; @0048                               v8 = select_spectre_guard v7, v6, v5  ; v6 = 0
+;; @0048                               v9 = load.i32 little heap v8
+;; @004b                               jump block1(v9)
 ;;
 ;;                                 block1(v2: i32):
 ;; @004b                               return v2
-;; }
\ No newline at end of file
+;; }
diff --git a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat
index 5cc0fad0c..caf88242a 100644
--- a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0x1000_offset.wat
@@ -46,14 +46,13 @@
 ;;
 ;;                                 block0(v0: i64, v1: i32, v2: i64):
 ;; @0040                               v3 = global_value.i64 gv1
-;; @0040                               v4 = iadd_imm v3, -4100
-;; @0040                               v5 = global_value.i64 gv2
-;; @0040                               v6 = iadd v5, v0
-;; @0040                               v7 = iadd_imm v6, 4096
-;; @0040                               v8 = iconst.i64 0
-;; @0040                               v9 = icmp ugt v0, v4
-;; @0040                               v10 = select_spectre_guard v9, v8, v7  ; v8 = 0
-;; @0040                               store little heap v1, v10
+;; @0040                               v4 = global_value.i64 gv2
+;; @0040                               v5 = iadd v4, v0
+;; @0040                               v6 = iadd_imm v5, 4096
+;; @0040                               v7 = iconst.i64 0
+;; @0040                               v8 = icmp ugt v0, v3
+;; @0040                               v9 = select_spectre_guard v8, v7, v6  ; v7 = 0
+;; @0040                               store little heap v1, v9
 ;; @0044                               jump block1
 ;;
 ;;                                 block1:
@@ -67,16 +66,15 @@
 ;;
 ;;                                 block0(v0: i64, v1: i64):
 ;; @0049                               v3 = global_value.i64 gv1
-;; @0049                               v4 = iadd_imm v3, -4100
-;; @0049                               v5 = global_value.i64 gv2
-;; @0049                               v6 = iadd v5, v0
-;; @0049                               v7 = iadd_imm v6, 4096
-;; @0049                               v8 = iconst.i64 0
-;; @0049                               v9 = icmp ugt v0, v4
-;; @0049                               v10 = select_spectre_guard v9, v8, v7  ; v8 = 0
-;; @0049                               v11 = load.i32 little heap v10
-;; @004d                               jump block1(v11)
+;; @0049                               v4 = global_value.i64 gv2
+;; @0049                               v5 = iadd v4, v0
+;; @0049                               v6 = iadd_imm v5, 4096
+;; @0049                               v7 = iconst.i64 0
+;; @0049                               v8 = icmp ugt v0, v3
+;; @0049                               v9 = select_spectre_guard v8, v7, v6  ; v7 = 0
+;; @0049                               v10 = load.i32 little heap v9
+;; @004d                               jump block1(v10)
 ;;
 ;;                                 block1(v2: i32):
 ;; @004d                               return v2
-;; }
\ No newline at end of file
+;; }
diff --git a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat
index 6df2c93dd..c7508cee5 100644
--- a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i32_access_0xffff0000_offset.wat
@@ -45,16 +45,14 @@
 ;;     gv2 = load.i64 notrap aligned readonly gv0
 ;;
 ;;                                 block0(v0: i64, v1: i32, v2: i64):
-;; @0040                               v3 = iconst.i64 0xffff_0004
-;; @0040                               v4 = uadd_overflow_trap v0, v3, heap_oob  ; v3 = 0xffff_0004
-;; @0040                               v5 = global_value.i64 gv1
-;; @0040                               v6 = global_value.i64 gv2
-;; @0040                               v7 = iadd v6, v0
-;; @0040                               v8 = iadd_imm v7, 0xffff_0000
-;; @0040                               v9 = iconst.i64 0
-;; @0040                               v10 = icmp ugt v4, v5
-;; @0040                               v11 = select_spectre_guard v10, v9, v8  ; v9 = 0
-;; @0040                               store little heap v1, v11
+;; @0040                               v3 = global_value.i64 gv1
+;; @0040                               v4 = global_value.i64 gv2
+;; @0040                               v5 = iadd v4, v0
+;; @0040                               v6 = iadd_imm v5, 0xffff_0000
+;; @0040                               v7 = iconst.i64 0
+;; @0040                               v8 = icmp ugt v0, v3
+;; @0040                               v9 = select_spectre_guard v8, v7, v6  ; v7 = 0
+;; @0040                               store little heap v1, v9
 ;; @0047                               jump block1
 ;;
 ;;                                 block1:
@@ -67,18 +65,16 @@
 ;;     gv2 = load.i64 notrap aligned readonly gv0
 ;;
 ;;                                 block0(v0: i64, v1: i64):
-;; @004c                               v3 = iconst.i64 0xffff_0004
-;; @004c                               v4 = uadd_overflow_trap v0, v3, heap_oob  ; v3 = 0xffff_0004
-;; @004c                               v5 = global_value.i64 gv1
-;; @004c                               v6 = global_value.i64 gv2
-;; @004c                               v7 = iadd v6, v0
-;; @004c                               v8 = iadd_imm v7, 0xffff_0000
-;; @004c                               v9 = iconst.i64 0
-;; @004c                               v10 = icmp ugt v4, v5
-;; @004c                               v11 = select_spectre_guard v10, v9, v8  ; v9 = 0
-;; @004c                               v12 = load.i32 little heap v11
-;; @0053                               jump block1(v12)
+;; @004c                               v3 = global_value.i64 gv1
+;; @004c                               v4 = global_value.i64 gv2
+;; @004c                               v5 = iadd v4, v0
+;; @004c                               v6 = iadd_imm v5, 0xffff_0000
+;; @004c                               v7 = iconst.i64 0
+;; @004c                               v8 = icmp ugt v0, v3
+;; @004c                               v9 = select_spectre_guard v8, v7, v6  ; v7 = 0
+;; @004c                               v10 = load.i32 little heap v9
+;; @0053                               jump block1(v10)
 ;;
 ;;                                 block1(v2: i32):
 ;; @0053                               return v2
-;; }
\ No newline at end of file
+;; }
diff --git a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat
index f15a8869e..e0e6de339 100644
--- a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat
+++ b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0x1000_offset.wat
@@ -46,14 +46,13 @@
 ;;
 ;;                                 block0(v0: i64, v1: i32, v2: i64):
 ;; @0040                               v3 = global_value.i64 gv1
-;; @0040                               v4 = iadd_imm v3, -4097
-;; @0040                               v5 = global_value.i64 gv2
-;; @0040                               v6 = iadd v5, v0
-;; @0040                               v7 = iadd_imm v6, 4096
-;; @0040                               v8 = iconst.i64 0
-;; @0040                               v9 = icmp ugt v0, v4
-;; @0040                               v10 = select_spectre_guard v9, v8, v7  ; v8 = 0
-;; @0040                               istore8 little heap v1, v10
+;; @0040                               v4 = global_value.i64 gv2
+;; @0040                               v5 = iadd v4, v0
+;; @0040                               v6 = iadd_imm v5, 4096
+;; @0040                               v7 = iconst.i64 0
+;; @0040                               v8 = icmp ugt v0, v3
+;; @0040                               v9 = select_spectre_guard v8, v7, v6  ; v7 = 0
+;; @0040                               istore8 little heap v1, v9
 ;; @0044                               jump block1
 ;;
 ;;                                 block1:
@@ -67,16 +66,15 @@
 ;;
 ;;                                 block0(v0: i64, v1: i64):
 ;; @0049                               v3 = global_value.i64 gv1
-;; @0049                               v4 = iadd_imm v3, -4097
-;; @0049                               v5 = global_value.i64 gv2
-;; @0049                               v6 = iadd v5, v0
-;; @0049                               v7 = iadd_imm v6, 4096
-;; @0049                               v8 = iconst.i64 0
-;; @0049                               v9 = icmp ugt v0, v4
-;; @0049                               v10 = select_spectre_guard v9, v8, v7  ; v8 = 0
-;; @0049                               v11 = uload8.i32 little heap v10
-;; @004d                               jump block1(v11)
+;; @0049                               v4 = global_value.i64 gv2
+;; @0049                               v5 = iadd v4, v0
+;; @0049                               v6 = iadd_imm v5, 4096
+;; @0049                               v7 = iconst.i64 0
+;; @0049                               v8 = icmp ugt v0, v3
+;; @0049                               v9 = select_spectre_guard v8, v7, v6  ; v7 = 0
+;; @0049                               v10 = uload8.i32 little heap v9
+;; @004d                               jump block1(v10)
 ;;
 ;;                                 block1(v2: i32):
 ;; @004d                               return v2
-;; }
\ No newline at end of file
+;; }
diff --git a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat
index 5b1307c75..458138b26 100644
--- a/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat
+++ b/cranelift/filetests/filetests/wasm/load-store/load_store_dynamic_kind_i64_index_0xffffffff_guard_yes_spectre_i8_access_0xffff0000_offset.wat
@@ -45,16 +45,14 @@
 ;;     gv2 = load.i64 notrap aligned readonly gv0
 ;;
 ;;                                 block0(v0: i64, v1: i32, v2: i64):
-;; @0040                               v3 = iconst.i64 0xffff_0001
-;; @0040                               v4 = uadd_overflow_trap v0, v3, heap_oob  ; v3 = 0xffff_0001
-;; @0040                               v5 = global_value.i64 gv1
-;; @0040                               v6 = global_value.i64 gv2
-;; @0040                               v7 = iadd v6, v0
-;; @0040                               v8 = iadd_imm v7, 0xffff_0000
-;; @0040                               v9 = iconst.i64 0
-;; @0040                               v10 = icmp ugt v4, v5
-;; @0040                               v11 = select_spectre_guard v10, v9, v8  ; v9 = 0
-;; @0040                               istore8 little heap v1, v11
+;; @0040                               v3 = global_value.i64 gv1
+;; @0040                               v4 = global_value.i64 gv2
+;; @0040                               v5 = iadd v4, v0
+;; @0040                               v6 = iadd_imm v5, 0xffff_0000
+;; @0040                               v7 = iconst.i64 0
+;; @0040                               v8 = icmp ugt v0, v3
+;; @0040                               v9 = select_spectre_guard v8, v7, v6  ; v7 = 0
+;; @0040                               istore8 little heap v1, v9
 ;; @0047                               jump block1
 ;;
 ;;                                 block1:
@@ -67,18 +65,16 @@
 ;;     gv2 = load.i64 notrap aligned readonly gv0
 ;;
 ;;                                 block0(v0: i64, v1: i64):
-;; @004c                               v3 = iconst.i64 0xffff_0001
-;; @004c                               v4 = uadd_overflow_trap v0, v3, heap_oob  ; v3 = 0xffff_0001
-;; @004c                               v5 = global_value.i64 gv1
-;; @004c                               v6 = global_value.i64 gv2
-;; @004c                               v7 = iadd v6, v0
-;; @004c                               v8 = iadd_imm v7, 0xffff_0000
-;; @004c                               v9 = iconst.i64 0
-;; @004c                               v10 = icmp ugt v4, v5
-;; @004c                               v11 = select_spectre_guard v10, v9, v8  ; v9 = 0
-;; @004c                               v12 = uload8.i32 little heap v11
-;; @0053                               jump block1(v12)
+;; @004c                               v3 = global_value.i64 gv1
+;; @004c                               v4 = global_value.i64 gv2
+;; @004c                               v5 = iadd v4, v0
+;; @004c                               v6 = iadd_imm v5, 0xffff_0000
+;; @004c                               v7 = iconst.i64 0
+;; @004c                               v8 = icmp ugt v0, v3
+;; @004c                               v9 = select_spectre_guard v8, v7, v6  ; v7 = 0
+;; @004c                               v10 = uload8.i32 little heap v9
+;; @0053                               jump block1(v10)
 ;;
 ;;                                 block1(v2: i32):
 ;; @0053                               return v2
-;; }
\ No newline at end of file
+;; }
diff --git a/tests/all/pooling_allocator.rs b/tests/all/pooling_allocator.rs
index 331011a27..eb3ec2fe8 100644
--- a/tests/all/pooling_allocator.rs
+++ b/tests/all/pooling_allocator.rs
@@ -680,19 +680,21 @@ configured maximum of 16 bytes; breakdown of allocation requirement:
 
 #[test]
 fn dynamic_memory_pooling_allocator() -> Result<()> {
-    let max_size = 128 << 20;
-    let mut pool = PoolingAllocationConfig::default();
-    pool.instance_count(1)
-        .instance_memory_pages(max_size / (64 * 1024));
-    let mut config = Config::new();
-    config.static_memory_maximum_size(max_size);
-    config.allocation_strategy(InstanceAllocationStrategy::Pooling(pool));
-
-    let engine = Engine::new(&config)?;
-
-    let module = Module::new(
-        &engine,
-        r#"
+    for guard_size in [0, 1 << 16] {
+        let max_size = 128 << 20;
+        let mut pool = PoolingAllocationConfig::default();
+        pool.instance_count(1)
+            .instance_memory_pages(max_size / (64 * 1024));
+        let mut config = Config::new();
+        config.static_memory_maximum_size(max_size);
+        config.dynamic_memory_guard_size(guard_size);
+        config.allocation_strategy(InstanceAllocationStrategy::Pooling(pool));
+
+        let engine = Engine::new(&config)?;
+
+        let module = Module::new(
+            &engine,
+            r#"
             (module
                 (memory (export "memory") 1)
 
@@ -715,65 +717,69 @@ fn dynamic_memory_pooling_allocator() -> Result<()> {
                 (data (i32.const 100) "x")
             )
          "#,
-    )?;
+        )?;
 
-    let mut store = Store::new(&engine, ());
-    let instance = Instance::new(&mut store, &module, &[])?;
-
-    let grow = instance.get_typed_func::<u32, i32>(&mut store, "grow")?;
-    let size = instance.get_typed_func::<(), u32>(&mut store, "size")?;
-    let i32_load = instance.get_typed_func::<u32, i32>(&mut store, "i32.load")?;
-    let i32_store = instance.get_typed_func::<(u32, i32), ()>(&mut store, "i32.store")?;
-    let memory = instance.get_memory(&mut store, "memory").unwrap();
-
-    // basic length 1 tests
-    // assert_eq!(memory.grow(&mut store, 1)?, 0);
-    assert_eq!(memory.size(&store), 1);
-    assert_eq!(size.call(&mut store, ())?, 1);
-    assert_eq!(i32_load.call(&mut store, 0)?, 0);
-    assert_eq!(i32_load.call(&mut store, 100)?, i32::from(b'x'));
-    i32_store.call(&mut store, (0, 0))?;
-    i32_store.call(&mut store, (100, i32::from(b'y')))?;
-    assert_eq!(i32_load.call(&mut store, 100)?, i32::from(b'y'));
-
-    // basic length 2 tests
-    let page = 64 * 1024;
-    assert_eq!(grow.call(&mut store, 1)?, 1);
-    assert_eq!(memory.size(&store), 2);
-    assert_eq!(size.call(&mut store, ())?, 2);
-    i32_store.call(&mut store, (page, 200))?;
-    assert_eq!(i32_load.call(&mut store, page)?, 200);
-
-    // test writes are visible
-    i32_store.call(&mut store, (2, 100))?;
-    assert_eq!(i32_load.call(&mut store, 2)?, 100);
-
-    // test growth can't exceed maximum
-    let too_many = max_size / (64 * 1024);
-    assert_eq!(grow.call(&mut store, too_many as u32)?, -1);
-    assert!(memory.grow(&mut store, too_many).is_err());
-
-    assert_eq!(memory.data(&store)[page as usize], 200);
-
-    // Re-instantiate in another store.
-    store = Store::new(&engine, ());
-    let instance = Instance::new(&mut store, &module, &[])?;
-    let i32_load = instance.get_typed_func::<u32, i32>(&mut store, "i32.load")?;
-    let memory = instance.get_memory(&mut store, "memory").unwrap();
+        let mut store = Store::new(&engine, ());
+        let instance = Instance::new(&mut store, &module, &[])?;
 
-    // Technically this is out of bounds...
-    assert!(i32_load.call(&mut store, page).is_err());
-    // ... but implementation-wise it should still be mapped memory from before.
-    // Note though that prior writes should all appear as zeros and we can't see
-    // data from the prior instance.
-    //
-    // Note that this part is only implemented on Linux which has
-    // `MADV_DONTNEED`.
-    assert_eq!(memory.data_size(&store), page as usize);
-    if cfg!(target_os = "linux") {
-        unsafe {
-            let ptr = memory.data_ptr(&store);
-            assert_eq!(*ptr.offset(page as isize), 0);
+        let grow = instance.get_typed_func::<u32, i32>(&mut store, "grow")?;
+        let size = instance.get_typed_func::<(), u32>(&mut store, "size")?;
+        let i32_load = instance.get_typed_func::<u32, i32>(&mut store, "i32.load")?;
+        let i32_store = instance.get_typed_func::<(u32, i32), ()>(&mut store, "i32.store")?;
+        let memory = instance.get_memory(&mut store, "memory").unwrap();
+
+        // basic length 1 tests
+        // assert_eq!(memory.grow(&mut store, 1)?, 0);
+        assert_eq!(memory.size(&store), 1);
+        assert_eq!(size.call(&mut store, ())?, 1);
+        assert_eq!(i32_load.call(&mut store, 0)?, 0);
+        assert_eq!(i32_load.call(&mut store, 100)?, i32::from(b'x'));
+        i32_store.call(&mut store, (0, 0))?;
+        i32_store.call(&mut store, (100, i32::from(b'y')))?;
+        assert_eq!(i32_load.call(&mut store, 100)?, i32::from(b'y'));
+
+        // basic length 2 tests
+        let page = 64 * 1024;
+        assert_eq!(grow.call(&mut store, 1)?, 1);
+        assert_eq!(memory.size(&store), 2);
+        assert_eq!(size.call(&mut store, ())?, 2);
+        i32_store.call(&mut store, (page, 200))?;
+        assert_eq!(i32_load.call(&mut store, page)?, 200);
+
+        // test writes are visible
+        i32_store.call(&mut store, (2, 100))?;
+        assert_eq!(i32_load.call(&mut store, 2)?, 100);
+
+        // test growth can't exceed maximum
+        let too_many = max_size / (64 * 1024);
+        assert_eq!(grow.call(&mut store, too_many as u32)?, -1);
+        assert!(memory.grow(&mut store, too_many).is_err());
+
+        assert_eq!(memory.data(&store)[page as usize], 200);
+
+        // Re-instantiate in another store.
+        store = Store::new(&engine, ());
+        let instance = Instance::new(&mut store, &module, &[])?;
+        let i32_load = instance.get_typed_func::<u32, i32>(&mut store, "i32.load")?;
+        let memory = instance.get_memory(&mut store, "memory").unwrap();
+
+        // This is out of bounds...
+        assert!(i32_load.call(&mut store, page).is_err());
+        assert_eq!(memory.data_size(&store), page as usize);
+
+        // ... but implementation-wise it should still be mapped memory from
+        // before if we don't have any guard pages.
+        //
+        // Note though that prior writes should all appear as zeros and we can't see
+        // data from the prior instance.
+        //
+        // Note that this part is only implemented on Linux which has
+        // `MADV_DONTNEED`.
+        if cfg!(target_os = "linux") && guard_size == 0 {
+            unsafe {
+                let ptr = memory.data_ptr(&store);
+                assert_eq!(*ptr.offset(page as isize), 0);
+            }
         }
     }