@@ -146,6 +146,71 @@ fn simple_local_i128_eqne_emits_pair_compare_ops_at_o0() { |
| 146 | 146 | ); |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | +#[test] |
| 150 | +fn simple_local_i128_ordered_compares_emit_signed_and_unsigned_limb_checks_at_o0() { |
| 151 | + let asm = capture_text( |
| 152 | + CaptureRequest { |
| 153 | + input: fixture("integer16_ordered_branch.f90"), |
| 154 | + requested: BTreeSet::from([Stage::Asm]), |
| 155 | + opt_level: OptLevel::O0, |
| 156 | + }, |
| 157 | + Stage::Asm, |
| 158 | + ); |
| 159 | + |
| 160 | + assert!( |
| 161 | + asm.contains("cset w10, lt"), |
| 162 | + "backend should use signed high-limb compare for i128 lt/le:\n{}", |
| 163 | + asm |
| 164 | + ); |
| 165 | + assert!( |
| 166 | + asm.contains("cset w8, lo"), |
| 167 | + "backend should use unsigned low-limb compare for strict ordered i128 compares:\n{}", |
| 168 | + asm |
| 169 | + ); |
| 170 | + assert!( |
| 171 | + asm.contains("cset w8, ls"), |
| 172 | + "backend should use unsigned low-limb <= compare for i128 le:\n{}", |
| 173 | + asm |
| 174 | + ); |
| 175 | + assert!( |
| 176 | + asm.contains("cset w10, gt"), |
| 177 | + "backend should use signed high-limb compare for i128 gt/ge:\n{}", |
| 178 | + asm |
| 179 | + ); |
| 180 | + assert!( |
| 181 | + asm.contains("cset w8, hi"), |
| 182 | + "backend should use unsigned low-limb > compare for i128 gt:\n{}", |
| 183 | + asm |
| 184 | + ); |
| 185 | + assert!( |
| 186 | + asm.contains("cset w8, hs"), |
| 187 | + "backend should use unsigned low-limb >= compare for i128 ge:\n{}", |
| 188 | + asm |
| 189 | + ); |
| 190 | +} |
| 191 | + |
| 192 | +#[test] |
| 193 | +fn simple_local_i128_ordered_branch_runs_at_o0() { |
| 194 | + let result = capture_from_path(&CaptureRequest { |
| 195 | + input: fixture("integer16_ordered_branch.f90"), |
| 196 | + requested: BTreeSet::from([Stage::Run]), |
| 197 | + opt_level: OptLevel::O0, |
| 198 | + }) |
| 199 | + .expect("ordered i128 branch program should run"); |
| 200 | + |
| 201 | + let run = result |
| 202 | + .get(Stage::Run) |
| 203 | + .and_then(CapturedStage::as_run) |
| 204 | + .expect("missing run capture"); |
| 205 | + |
| 206 | + assert_eq!(run.exit_code, 0, "expected successful ordered branch run:\n{:#?}", run); |
| 207 | + assert!( |
| 208 | + run.stdout.contains('4'), |
| 209 | + "ordered i128 branch program should print score 4:\n{}", |
| 210 | + run.stdout |
| 211 | + ); |
| 212 | +} |
| 213 | + |
| 149 | 214 | #[test] |
| 150 | 215 | fn simple_local_i128_object_snapshot_is_deterministic_at_o0() { |
| 151 | 216 | let source = fixture("integer16_local_roundtrip.f90"); |