about summary refs log tree commit diff
path: root/tests/codegen
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-01-26 06:59:26 +0000
committerbors <bors@rust-lang.org>2024-01-26 06:59:26 +0000
commitfae15df5c60ccf0f9eaa96651c869d2c2001fddb (patch)
treeb452546913281a644984fff0862defd7ec76890e /tests/codegen
parent9f4d1a41a6dccf00caace1e9fd20011d586d8b69 (diff)
parent2318b0825cc2892a388b307d38389658f09ac3b6 (diff)
downloadrust-fae15df5c60ccf0f9eaa96651c869d2c2001fddb.tar.gz
rust-fae15df5c60ccf0f9eaa96651c869d2c2001fddb.zip
Auto merge of #3280 - rust-lang:rustup-2024-01-26, r=RalfJung
Automatic Rustup
Diffstat (limited to 'tests/codegen')
-rw-r--r--tests/codegen/alloc-optimisation.rs2
-rw-r--r--tests/codegen/array-map.rs3
-rw-r--r--tests/codegen/dealloc-no-unwind.rs1
-rw-r--r--tests/codegen/fewer-names.rs1
-rw-r--r--tests/codegen/integer-overflow.rs1
-rw-r--r--tests/codegen/is_val_statically_known.rs48
-rw-r--r--tests/codegen/issues/issue-116878.rs1
-rw-r--r--tests/codegen/issues/issue-44056-macos-tls-align.rs1
-rw-r--r--tests/codegen/issues/issue-69101-bounds-check.rs1
-rw-r--r--tests/codegen/match-optimizes-away.rs1
-rw-r--r--tests/codegen/pow_of_two.rs55
-rw-r--r--tests/codegen/ptr-read-metadata.rs1
-rw-r--r--tests/codegen/slice-as_chunks.rs1
-rw-r--r--tests/codegen/slice-iter-len-eq-zero.rs1
-rw-r--r--tests/codegen/slice-iter-nonnull.rs1
-rw-r--r--tests/codegen/slice-position-bounds-check.rs1
-rw-r--r--tests/codegen/vec-iter-collect-len.rs1
-rw-r--r--tests/codegen/vec-optimizes-away.rs1
18 files changed, 104 insertions, 18 deletions
diff --git a/tests/codegen/alloc-optimisation.rs b/tests/codegen/alloc-optimisation.rs
index f88d695d87e..900eb687a45 100644
--- a/tests/codegen/alloc-optimisation.rs
+++ b/tests/codegen/alloc-optimisation.rs
@@ -1,5 +1,3 @@
-//
-// no-system-llvm
 // compile-flags: -O
 #![crate_type = "lib"]
 
diff --git a/tests/codegen/array-map.rs b/tests/codegen/array-map.rs
index 4d218e6a951..9846cc7f5c8 100644
--- a/tests/codegen/array-map.rs
+++ b/tests/codegen/array-map.rs
@@ -1,5 +1,4 @@
 // compile-flags: -C opt-level=3 -C target-cpu=x86-64-v3
-// no-system-llvm
 // only-x86_64
 // ignore-debug (the extra assertions get in the way)
 
@@ -10,7 +9,7 @@
 pub fn short_integer_map(x: [u32; 8]) -> [u32; 8] {
     // CHECK: load <8 x i32>
     // CHECK: shl <8 x i32>
-    // CHECK: or <8 x i32>
+    // CHECK: or{{( disjoint)?}} <8 x i32>
     // CHECK: store <8 x i32>
     x.map(|x| 2 * x + 1)
 }
diff --git a/tests/codegen/dealloc-no-unwind.rs b/tests/codegen/dealloc-no-unwind.rs
index 3812ef44ff2..c2656908f16 100644
--- a/tests/codegen/dealloc-no-unwind.rs
+++ b/tests/codegen/dealloc-no-unwind.rs
@@ -1,4 +1,3 @@
-// no-system-llvm
 // compile-flags: -O
 
 #![crate_type="lib"]
diff --git a/tests/codegen/fewer-names.rs b/tests/codegen/fewer-names.rs
index df1080bff2b..05643fab96a 100644
--- a/tests/codegen/fewer-names.rs
+++ b/tests/codegen/fewer-names.rs
@@ -1,4 +1,3 @@
-// no-system-llvm
 // compile-flags: -Coverflow-checks=no -O
 // revisions: YES NO
 // [YES]compile-flags: -Zfewer-names=yes
diff --git a/tests/codegen/integer-overflow.rs b/tests/codegen/integer-overflow.rs
index 183de56db96..b5c351b5e35 100644
--- a/tests/codegen/integer-overflow.rs
+++ b/tests/codegen/integer-overflow.rs
@@ -1,4 +1,3 @@
-// no-system-llvm
 // compile-flags: -O -C overflow-checks=on
 
 #![crate_type = "lib"]
diff --git a/tests/codegen/is_val_statically_known.rs b/tests/codegen/is_val_statically_known.rs
new file mode 100644
index 00000000000..44187d4f667
--- /dev/null
+++ b/tests/codegen/is_val_statically_known.rs
@@ -0,0 +1,48 @@
+// compile-flags: --crate-type=lib -Zmerge-functions=disabled -O
+
+#![feature(core_intrinsics)]
+
+use std::intrinsics::is_val_statically_known;
+
+pub struct A(u32);
+pub enum B {
+    Ye(u32),
+}
+
+#[inline]
+pub fn _u32(a: u32) -> i32 {
+    if unsafe { is_val_statically_known(a) } { 1 } else { 0 }
+}
+
+// CHECK-LABEL: @_u32_true(
+#[no_mangle]
+pub fn _u32_true() -> i32 {
+    // CHECK: ret i32 1
+    _u32(1)
+}
+
+// CHECK-LABEL: @_u32_false(
+#[no_mangle]
+pub fn _u32_false(a: u32) -> i32 {
+    // CHECK: ret i32 0
+    _u32(a)
+}
+
+#[inline]
+pub fn _bool(b: bool) -> i32 {
+    if unsafe { is_val_statically_known(b) } { 3 } else { 2 }
+}
+
+// CHECK-LABEL: @_bool_true(
+#[no_mangle]
+pub fn _bool_true() -> i32 {
+    // CHECK: ret i32 3
+    _bool(true)
+}
+
+// CHECK-LABEL: @_bool_false(
+#[no_mangle]
+pub fn _bool_false(b: bool) -> i32 {
+    // CHECK: ret i32 2
+    _bool(b)
+}
diff --git a/tests/codegen/issues/issue-116878.rs b/tests/codegen/issues/issue-116878.rs
index d5f679459f7..5864f532324 100644
--- a/tests/codegen/issues/issue-116878.rs
+++ b/tests/codegen/issues/issue-116878.rs
@@ -1,4 +1,3 @@
-// no-system-llvm
 // compile-flags: -O
 // ignore-debug: the debug assertions get in the way
 #![crate_type = "lib"]
diff --git a/tests/codegen/issues/issue-44056-macos-tls-align.rs b/tests/codegen/issues/issue-44056-macos-tls-align.rs
index 1a3923f1bb1..44aa9766d3c 100644
--- a/tests/codegen/issues/issue-44056-macos-tls-align.rs
+++ b/tests/codegen/issues/issue-44056-macos-tls-align.rs
@@ -1,6 +1,5 @@
 //
 // only-macos
-// no-system-llvm
 // compile-flags: -O
 
 #![crate_type = "rlib"]
diff --git a/tests/codegen/issues/issue-69101-bounds-check.rs b/tests/codegen/issues/issue-69101-bounds-check.rs
index a3aca3a2912..655de45fd51 100644
--- a/tests/codegen/issues/issue-69101-bounds-check.rs
+++ b/tests/codegen/issues/issue-69101-bounds-check.rs
@@ -1,4 +1,3 @@
-// no-system-llvm
 // compile-flags: -O
 // ignore-debug: the debug assertions get in the way
 #![crate_type = "lib"]
diff --git a/tests/codegen/match-optimizes-away.rs b/tests/codegen/match-optimizes-away.rs
index 8f66c518ccf..400606b42d5 100644
--- a/tests/codegen/match-optimizes-away.rs
+++ b/tests/codegen/match-optimizes-away.rs
@@ -1,5 +1,4 @@
 //
-// no-system-llvm
 // compile-flags: -O
 #![crate_type="lib"]
 
diff --git a/tests/codegen/pow_of_two.rs b/tests/codegen/pow_of_two.rs
new file mode 100644
index 00000000000..a8c0550e332
--- /dev/null
+++ b/tests/codegen/pow_of_two.rs
@@ -0,0 +1,55 @@
+// compile-flags: --crate-type=lib -Zmerge-functions=disabled -O -C overflow-checks=false
+
+// CHECK-LABEL: @a(
+#[no_mangle]
+pub fn a(exp: u32) -> u64 {
+    // CHECK: %{{[^ ]+}} = icmp ugt i32 %exp, 64
+    // CHECK: %{{[^ ]+}} = zext i32 %exp to i64
+    // CHECK: %{{[^ ]+}} = shl nuw i64 {{[^ ]+}}, %{{[^ ]+}}
+    // CHECK: ret i64 %{{[^ ]+}}
+    2u64.pow(exp)
+}
+
+// CHECK-LABEL: @b(
+#[no_mangle]
+pub fn b(exp: u32) -> i64 {
+    // CHECK: %{{[^ ]+}} = icmp ugt i32 %exp, 64
+    // CHECK: %{{[^ ]+}} = zext i32 %exp to i64
+    // CHECK: %{{[^ ]+}} = shl nuw i64 {{[^ ]+}}, %{{[^ ]+}}
+    // CHECK: ret i64 %{{[^ ]+}}
+    2i64.pow(exp)
+}
+
+// CHECK-LABEL: @c(
+#[no_mangle]
+pub fn c(exp: u32) -> u32 {
+    // CHECK: %{{[^ ]+}} = icmp ugt i32 %exp, 16
+    // CHECK: %{{[^ ]+}} = shl nuw nsw i32 %exp, 1
+    // CHECK: %{{[^ ]+}} = shl nuw i32 1, %{{[^ ]+}}
+    // CHECK: %{{[^ ]+}} = select i1 %{{[^ ]+}}, i32 0, i32 %{{[^ ]+}}
+    // CHECK: ret i32 %{{[^ ]+}}
+    4u32.pow(exp)
+}
+
+// CHECK-LABEL: @d(
+#[no_mangle]
+pub fn d(exp: u32) -> u32 {
+    // CHECK: %{{[^ ]+}} = icmp ugt i32 %exp, 6
+    // CHECK: %{{[^ ]+}} = mul nuw nsw i32 %exp, 5
+    // CHECK: %{{[^ ]+}} = shl nuw nsw i32 1, %{{[^ ]+}}
+    // CHECK: %{{[^ ]+}} = select i1 {{[^ ]+}}, i32 0, i32 %{{[^ ]+}}
+    // CHECK: ret i32 %{{[^ ]+}}
+    32u32.pow(exp)
+}
+
+// CHECK-LABEL: @e(
+#[no_mangle]
+pub fn e(exp: u32) -> i32 {
+    // CHECK: %{{[^ ]+}} = icmp ugt i32 %exp, 6
+    // CHECK: %{{[^ ]+}} = mul nuw {{(nsw )?}}i32 %exp, 5
+    // CHECK: %{{[^ ]+}} = shl nuw {{(nsw )?}}i32 1, %{{[^ ]+}}
+    // CHECK: %{{[^ ]+}} = select i1 {{[^ ]+}}, i32 0, i32 %{{[^ ]+}}
+    // CHECK: ret i32 %{{[^ ]+}}
+    32i32.pow(exp)
+}
+// note: d and e are expected to yield the same IR
diff --git a/tests/codegen/ptr-read-metadata.rs b/tests/codegen/ptr-read-metadata.rs
index 73d1db6df27..94152ed11ba 100644
--- a/tests/codegen/ptr-read-metadata.rs
+++ b/tests/codegen/ptr-read-metadata.rs
@@ -1,5 +1,4 @@
 // compile-flags: -O -Z merge-functions=disabled
-// no-system-llvm
 // ignore-debug (the extra assertions get in the way)
 
 #![crate_type = "lib"]
diff --git a/tests/codegen/slice-as_chunks.rs b/tests/codegen/slice-as_chunks.rs
index efac9f3d68d..e832f90d07a 100644
--- a/tests/codegen/slice-as_chunks.rs
+++ b/tests/codegen/slice-as_chunks.rs
@@ -1,4 +1,3 @@
-// no-system-llvm
 // compile-flags: -O
 // only-64bit (because the LLVM type of i64 for usize shows up)
 // ignore-debug: the debug assertions get in the way
diff --git a/tests/codegen/slice-iter-len-eq-zero.rs b/tests/codegen/slice-iter-len-eq-zero.rs
index c7515ce35a3..77febf5170d 100644
--- a/tests/codegen/slice-iter-len-eq-zero.rs
+++ b/tests/codegen/slice-iter-len-eq-zero.rs
@@ -1,4 +1,3 @@
-// no-system-llvm
 // compile-flags: -O
 // ignore-debug: the debug assertions add extra comparisons
 #![crate_type = "lib"]
diff --git a/tests/codegen/slice-iter-nonnull.rs b/tests/codegen/slice-iter-nonnull.rs
index 1e691cc34c9..93c8828ccd3 100644
--- a/tests/codegen/slice-iter-nonnull.rs
+++ b/tests/codegen/slice-iter-nonnull.rs
@@ -1,4 +1,3 @@
-// no-system-llvm
 // compile-flags: -O
 // ignore-debug (these add extra checks that make it hard to verify)
 #![crate_type = "lib"]
diff --git a/tests/codegen/slice-position-bounds-check.rs b/tests/codegen/slice-position-bounds-check.rs
index b494f42b296..57904e5e499 100644
--- a/tests/codegen/slice-position-bounds-check.rs
+++ b/tests/codegen/slice-position-bounds-check.rs
@@ -1,4 +1,3 @@
-// no-system-llvm
 // compile-flags: -O -C panic=abort
 #![crate_type = "lib"]
 
diff --git a/tests/codegen/vec-iter-collect-len.rs b/tests/codegen/vec-iter-collect-len.rs
index 73348ddd063..3a0d6c30919 100644
--- a/tests/codegen/vec-iter-collect-len.rs
+++ b/tests/codegen/vec-iter-collect-len.rs
@@ -1,5 +1,4 @@
 // ignore-debug: the debug assertions get in the way
-// no-system-llvm
 // compile-flags: -O
 #![crate_type="lib"]
 
diff --git a/tests/codegen/vec-optimizes-away.rs b/tests/codegen/vec-optimizes-away.rs
index 6f477a796b6..3be342dabeb 100644
--- a/tests/codegen/vec-optimizes-away.rs
+++ b/tests/codegen/vec-optimizes-away.rs
@@ -1,5 +1,4 @@
 // ignore-debug: the debug assertions get in the way
-// no-system-llvm
 // compile-flags: -O
 #![crate_type = "lib"]