| 2234 | free(q) |
| 2235 | if v == 30 { |
| 2236 | return 0 |
| 2237 | } |
| 2238 | return 1 |
| 2239 | } |
| 2240 | "#, |
| 2241 | ); |
| 2242 | assert!( |
| 2243 | matches!(outcome, RunOutcome::Halted(0)), |
| 2244 | "two separate heap i32 values sum to 30, got {outcome:?}" |
| 2245 | ); |
| 2246 | } |
| 2247 | |
| 2248 | /// Signed right shift (`sra`): -8 >> 2 must equal -2. Built directly in IR. |
| 2249 | #[test] |
| 2250 | fn ir_math_shr_signed() { |
| 2251 | let i32_ty = IrType::Integer(IntWidth::I32); |
| 2252 | let mut entry = IrBlock::new("entry"); |
| 2253 | entry.push_instruction(IrInstruction::Math { |
| 2254 | dest: IrRegister::Named("shifted".into()), |
| 2255 | op: IrMathOp::Shr, |
| 2256 | ty: i32_ty.clone(), |
| 2257 | lhs: IrValue::Integer(-8), |