// ---
// tags: trident, rust
// crystal-type: source
// crystal-domain: comp
// ---
/// Dead spill and dead store elimination.
use TIROp;
use ;
/// Eliminate dead spills and dead stores.
///
/// Two patterns are handled:
///
/// 1. **Spill/reload pairs** -- address written once and read once:
/// Write: `Push(addr), Swap(1), WriteMem(1), Pop(1)` -> removed
/// Read: `Push(addr), ReadMem(1), Pop(1)` -> removed
/// The value stays on the stack instead of round-tripping through RAM.
///
/// 2. **Dead stores** -- address written but never read:
/// `Push(addr), Swap(1), WriteMem(1), Pop(1)` -> `Pop(1)`
/// The value was going to be discarded into RAM; just pop it.
/// Also handles: `Swap(D), Push(addr), Swap(1), WriteMem(1), Pop(1)` -> `Swap(D), Pop(1)`
pub
trident/src/ir/tir/optimize/spill.rs
ฯ 0.0%