diff options
| author | bors <bors@rust-lang.org> | 2023-08-21 06:00:57 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-08-21 06:00:57 +0000 |
| commit | 83ca92243ccbc0484b0c34371479db715ad79d9c (patch) | |
| tree | 7f576cc61c9908958d393f01133f5ccf0832579d /tests/codegen | |
| parent | 92217bb93dc0b959efc83ce55dbe00f38e8307a1 (diff) | |
| parent | 5356aa43044e6e142985ff169bd14423220f34ff (diff) | |
| download | rust-83ca92243ccbc0484b0c34371479db715ad79d9c.tar.gz rust-83ca92243ccbc0484b0c34371479db715ad79d9c.zip | |
Auto merge of #3033 - rust-lang:rustup-2023-08-21, r=RalfJung
Automatic sync from rustc
Diffstat (limited to 'tests/codegen')
| -rw-r--r-- | tests/codegen/issues/issue-114312.rs | 27 | ||||
| -rw-r--r-- | tests/codegen/slice-ref-equality.rs | 32 | ||||
| -rw-r--r-- | tests/codegen/trailing_zeros.rs | 22 |
3 files changed, 65 insertions, 16 deletions
diff --git a/tests/codegen/issues/issue-114312.rs b/tests/codegen/issues/issue-114312.rs new file mode 100644 index 00000000000..e2fbcef721e --- /dev/null +++ b/tests/codegen/issues/issue-114312.rs @@ -0,0 +1,27 @@ +// compile-flags: -O +// min-llvm-version: 17 +// only-x86_64-unknown-linux-gnu + +// We want to check that this function does not mis-optimize to loop jumping. + +#![crate_type = "lib"] + +#[repr(C)] +pub enum Expr { + Sum, + // must have more than usize data + Sub(usize, u8), +} + +#[no_mangle] +pub extern "C" fn issue_114312(expr: Expr) { + // CHECK-LABEL: @issue_114312( + // CHECK-NOT: readonly + // CHECK-SAME: byval + // CHECK-NEXT: start: + // CHECK-NEXT: ret void + match expr { + Expr::Sum => {} + Expr::Sub(_, _) => issue_114312(Expr::Sum), + } +} diff --git a/tests/codegen/slice-ref-equality.rs b/tests/codegen/slice-ref-equality.rs index 4d0dce7b074..afbdf66ce0a 100644 --- a/tests/codegen/slice-ref-equality.rs +++ b/tests/codegen/slice-ref-equality.rs @@ -44,48 +44,48 @@ pub fn is_zero_array(data: &[u8; 4]) -> bool { // equality for non-byte types also just emit a `bcmp`, not a loop. // CHECK-LABEL: @eq_slice_of_nested_u8( -// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %x.1 -// CHECK-SAME: [[USIZE]] noundef %y.1 +// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %1 +// CHECK-SAME: [[USIZE]] noundef %3 #[no_mangle] fn eq_slice_of_nested_u8(x: &[[u8; 3]], y: &[[u8; 3]]) -> bool { - // CHECK: icmp eq [[USIZE]] %x.1, %y.1 - // CHECK: %[[BYTES:.+]] = mul nsw [[USIZE]] %x.1, 3 + // CHECK: icmp eq [[USIZE]] %1, %3 + // CHECK: %[[BYTES:.+]] = mul nsw [[USIZE]] %1, 3 // CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}(ptr // CHECK-SAME: , [[USIZE]]{{( noundef)?}} %[[BYTES]]) x == y } // CHECK-LABEL: @eq_slice_of_i32( -// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %x.1 -// CHECK-SAME: [[USIZE]] noundef %y.1 +// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %1 +// CHECK-SAME: [[USIZE]] noundef %3 #[no_mangle] fn eq_slice_of_i32(x: &[i32], y: &[i32]) -> bool { - // CHECK: icmp eq [[USIZE]] %x.1, %y.1 - // CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] %x.1, 2 + // CHECK: icmp eq [[USIZE]] %1, %3 + // CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] %1, 2 // CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}(ptr // CHECK-SAME: , [[USIZE]]{{( noundef)?}} %[[BYTES]]) x == y } // CHECK-LABEL: @eq_slice_of_nonzero( -// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %x.1 -// CHECK-SAME: [[USIZE]] noundef %y.1 +// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %1 +// CHECK-SAME: [[USIZE]] noundef %3 #[no_mangle] fn eq_slice_of_nonzero(x: &[NonZeroU32], y: &[NonZeroU32]) -> bool { - // CHECK: icmp eq [[USIZE]] %x.1, %y.1 - // CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] %x.1, 2 + // CHECK: icmp eq [[USIZE]] %1, %3 + // CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] %1, 2 // CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}(ptr // CHECK-SAME: , [[USIZE]]{{( noundef)?}} %[[BYTES]]) x == y } // CHECK-LABEL: @eq_slice_of_option_of_nonzero( -// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %x.1 -// CHECK-SAME: [[USIZE]] noundef %y.1 +// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %1 +// CHECK-SAME: [[USIZE]] noundef %3 #[no_mangle] fn eq_slice_of_option_of_nonzero(x: &[Option<NonZeroI16>], y: &[Option<NonZeroI16>]) -> bool { - // CHECK: icmp eq [[USIZE]] %x.1, %y.1 - // CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] %x.1, 1 + // CHECK: icmp eq [[USIZE]] %1, %3 + // CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] %1, 1 // CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}(ptr // CHECK-SAME: , [[USIZE]]{{( noundef)?}} %[[BYTES]]) x == y diff --git a/tests/codegen/trailing_zeros.rs b/tests/codegen/trailing_zeros.rs new file mode 100644 index 00000000000..2ea0e447abe --- /dev/null +++ b/tests/codegen/trailing_zeros.rs @@ -0,0 +1,22 @@ +// compile-flags: -O +// min-llvm-version: 17 + +#![crate_type = "lib"] + +// CHECK-LABEL: @trailing_zeros_ge +#[no_mangle] +pub fn trailing_zeros_ge(val: u32) -> bool { + // CHECK: %[[AND:.*]] = and i32 %val, 7 + // CHECK: %[[ICMP:.*]] = icmp eq i32 %[[AND]], 0 + // CHECK: ret i1 %[[ICMP]] + val.trailing_zeros() >= 3 +} + +// CHECK-LABEL: @trailing_zeros_gt +#[no_mangle] +pub fn trailing_zeros_gt(val: u64) -> bool { + // CHECK: %[[AND:.*]] = and i64 %val, 15 + // CHECK: %[[ICMP:.*]] = icmp eq i64 %[[AND]], 0 + // CHECK: ret i1 %[[ICMP]] + val.trailing_zeros() > 3 +} |
