Skip to content

Commit

Permalink
Update codegen tests
Browse files Browse the repository at this point in the history
  • Loading branch information
saethlin committed Aug 21, 2024
1 parent a89894d commit 66653dc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
4 changes: 1 addition & 3 deletions tests/codegen/constant-branch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ pub fn if_constant_match() {
_ => 4,
};

// CHECK: br label %[[MINUS1:.+]]
// CHECK: br label %{{.+}}
_ = match -1 {
// CHECK: [[MINUS1]]:
// CHECK: store i32 1
-1 => 1,
_ => 0,
}
Expand Down
23 changes: 23 additions & 0 deletions tests/codegen/no-alloca-inside-if-false.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//@ compile-flags: -Cno-prepopulate-passes -Copt-level=0

#![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
if const { SIZE < 4096 } {
let arr = [0u8; SIZE];
std::hint::black_box(&arr);
} else {
let vec = vec![0u8; SIZE];
std::hint::black_box(&vec);
}
}

pub fn main() {
test::<8192>();
}

0 comments on commit 66653dc

Please sign in to comment.