Skip to content

Commit

Permalink
Improve test clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
saethlin committed Sep 20, 2024
1 parent 5ff2c12 commit 04f2f63
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
12 changes: 6 additions & 6 deletions tests/codegen/constant-branch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@
// CHECK-LABEL: @if_bool
#[no_mangle]
pub fn if_bool() {
// CHECK: br label %{{.+}}
// CHECK-NOT: br i1
// CHECK-NOT: switch
_ = if true { 0 } else { 1 };

// CHECK: br label %{{.+}}
_ = if false { 0 } else { 1 };
}

// CHECK-LABEL: @if_constant_int_eq
#[no_mangle]
pub fn if_constant_int_eq() {
// CHECK-NOT: br i1
// CHECK-NOT: switch
let val = 0;
// CHECK: br label %{{.+}}
_ = if val == 0 { 0 } else { 1 };

// CHECK: br label %{{.+}}
Expand All @@ -28,20 +29,19 @@ pub fn if_constant_int_eq() {
// CHECK-LABEL: @if_constant_match
#[no_mangle]
pub fn if_constant_match() {
// CHECK: br label %{{.+}}
// CHECK-NOT: br i1
// CHECK-NOT: switch
_ = match 1 {
1 => 2,
2 => 3,
_ => 4,
};

// CHECK: br label %{{.+}}
_ = match 1 {
2 => 3,
_ => 4,
};

// CHECK: br label %{{.+}}
_ = match -1 {
-1 => 1,
_ => 0,
Expand Down
9 changes: 6 additions & 3 deletions tests/codegen/no-alloca-inside-if-false.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
//@ compile-flags: -Cno-prepopulate-passes -Copt-level=0
// Check that there's an alloca for the reference and the vector, but nothing else.

#![crate_type = "lib"]

#[inline(never)]
fn test<const SIZE: usize>() {
// CHECK-LABEL: no_alloca_inside_if_false::test
// CHECK: start:
// CHECK-NEXT: %0 = alloca
// CHECK-NEXT: %vec = alloca
// CHECK-NOT: %arr = alloca
// CHECK-NEXT: alloca [{{8|16}} x i8]
// CHECK-NEXT: alloca [{{12|24}} x i8]
// CHECK-NOT: alloca
if const { SIZE < 4096 } {
let arr = [0u8; SIZE];
std::hint::black_box(&arr);
Expand All @@ -18,6 +19,8 @@ fn test<const SIZE: usize>() {
}
}

// CHECK-LABEL: @main
#[no_mangle]
pub fn main() {
test::<8192>();
}

0 comments on commit 04f2f63

Please sign in to comment.