Skip to content

Commit 6a37129

Browse files
committed
Add a set of tests for LLVM 19
1 parent 1df0458 commit 6a37129

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

tests/assembly/issues/issue-126585.rs

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//@ assembly-output: emit-asm
2+
//@ only-x86_64
3+
//@ compile-flags: -Copt-level=s -Cllvm-args=-x86-asm-syntax=intel
4+
//@ min-llvm-version: 19
5+
6+
// Test for #126585.
7+
// Ensure that we do not create subsequent labels and unnecessary `jmp` instructions.
8+
9+
#![crate_type = "lib"]
10+
11+
#[no_mangle]
12+
fn checked_div_round(a: u64, b: u64) -> Option<u64> {
13+
// CHECK-LABEL: checked_div_round:
14+
// CHECK-NEXT: .cfi_startproc
15+
// CHECK-NEXT: cmp
16+
// CHECK-NEXT: jbe [[L1:..*]]
17+
// CHECK-NOT: je
18+
// CHECK-NOT: jmp
19+
// CHECK-NOT: .{{.*}}:
20+
// CHECK: [[L1]]:
21+
// CHECK-NOT: .{{.*}}:
22+
// CHECK: ret
23+
match b {
24+
0 => None,
25+
1 => Some(a),
26+
// `a / b` is computable and `(a % b) * 2` can not overflow since `b >= 2`.
27+
b => Some(a / b + if (a % b) * 2 >= b { 1 } else { 0 }),
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//@ compile-flags: -O
2+
//@ min-llvm-version: 19
3+
4+
// Test for #107681.
5+
// Make sure we don't create `br` or `select` instructions.
6+
7+
#![crate_type = "lib"]
8+
9+
use std::iter::Copied;
10+
use std::slice::Iter;
11+
12+
#[no_mangle]
13+
pub unsafe fn foo(x: &mut Copied<Iter<'_, u32>>) -> u32 {
14+
// CHECK-LABEL: @foo(
15+
// CHECK-NOT: br
16+
// CHECK-NOT: select
17+
// CHECK: [[RET:%.*]] = load i32, ptr
18+
// CHECK-NEXT: ret i32 [[RET]]
19+
x.next().unwrap_unchecked()
20+
}

tests/codegen/issues/issue-118306.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//@ compile-flags: -O
2+
//@ min-llvm-version: 19
3+
4+
// Test for #118306.
5+
// Make sure we don't create `br` or `select` instructions.
6+
7+
#![crate_type = "lib"]
8+
9+
#[no_mangle]
10+
pub fn branchy(input: u64) -> u64 {
11+
// CHECK-LABEL: @branchy(
12+
// CHECK-NEXT: start:
13+
// CHECK-NEXT: [[_2:%.*]] = and i64 [[INPUT:%.*]], 3
14+
// CHECK-NEXT: [[SWITCH_GEP:%.*]] = getelementptr inbounds [4 x i64], ptr @switch.table.branchy, i64 0, i64 [[_2]]
15+
// CHECK-NEXT: [[SWITCH_LOAD:%.*]] = load i64, ptr [[SWITCH_GEP]]
16+
// CHECK-NEXT: ret i64 [[SWITCH_LOAD]]
17+
match input % 4 {
18+
1 | 2 => 1,
19+
3 => 2,
20+
_ => 0,
21+
}
22+
}

0 commit comments

Comments
 (0)