diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-07-21 14:34:12 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-07-22 14:28:48 +0200 |
| commit | a27f3e3fd1e4d16160f8885b6b06665b5319f56c (patch) | |
| tree | b033935392cbadf6f85d2dbddf433a88e323aeeb /tests/codegen-llvm/issues/issue-126585.rs | |
| parent | ed93c1783b404d728d4809973a0550eb33cd293f (diff) | |
| download | rust-a27f3e3fd1e4d16160f8885b6b06665b5319f56c.tar.gz rust-a27f3e3fd1e4d16160f8885b6b06665b5319f56c.zip | |
Rename `tests/codegen` into `tests/codegen-llvm`
Diffstat (limited to 'tests/codegen-llvm/issues/issue-126585.rs')
| -rw-r--r-- | tests/codegen-llvm/issues/issue-126585.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/codegen-llvm/issues/issue-126585.rs b/tests/codegen-llvm/issues/issue-126585.rs new file mode 100644 index 00000000000..466dab64cdc --- /dev/null +++ b/tests/codegen-llvm/issues/issue-126585.rs @@ -0,0 +1,23 @@ +//@ compile-flags: -Copt-level=s +//@ only-x86_64 + +// Test for #126585. +// Ensure that this IR doesn't have extra undef phi input, which also guarantees that this asm +// doesn't have subsequent labels and unnecessary `jmp` instructions. + +#![crate_type = "lib"] + +#[no_mangle] +fn checked_div_round(a: u64, b: u64) -> Option<u64> { + // CHECK-LABEL: @checked_div_round + // CHECK: phi + // CHECK-NOT: undef + // CHECK: phi + // CHECK-NOT: undef + match b { + 0 => None, + 1 => Some(a), + // `a / b` is computable and `(a % b) * 2` can not overflow since `b >= 2`. + b => Some(a / b + if (a % b) * 2 >= b { 1 } else { 0 }), + } +} |
