diff options
| author | Oli Scherer <github35764891676564198441@oli-obk.de> | 2025-01-31 06:12:43 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-31 06:12:43 +0000 |
| commit | bcda8927d010915dd50991cda41d01ee16e545ee (patch) | |
| tree | 2f5b7438dad8635d3d521bb0d04428eed0c4b2cd /tests/codegen/lib-optimizations | |
| parent | e1d050732198114a28cca6749375236cab5b21e8 (diff) | |
| parent | 74ca1cfb2aec94ae9e6c277b20c2caa4588c9993 (diff) | |
| download | rust-bcda8927d010915dd50991cda41d01ee16e545ee.tar.gz rust-bcda8927d010915dd50991cda41d01ee16e545ee.zip | |
Merge pull request #4166 from rust-lang/rustup-2025-01-31
Automatic Rustup
Diffstat (limited to 'tests/codegen/lib-optimizations')
| -rw-r--r-- | tests/codegen/lib-optimizations/slice_rotate.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/codegen/lib-optimizations/slice_rotate.rs b/tests/codegen/lib-optimizations/slice_rotate.rs new file mode 100644 index 00000000000..d0a7b328d18 --- /dev/null +++ b/tests/codegen/lib-optimizations/slice_rotate.rs @@ -0,0 +1,30 @@ +//@ compile-flags: -O + +#![crate_type = "lib"] + +// Ensure that the simple case of rotating by a constant 1 optimizes to the obvious thing + +// CHECK-LABEL: @rotate_left_by_one +#[no_mangle] +pub fn rotate_left_by_one(slice: &mut [i32]) { + // CHECK-NOT: phi + // CHECK-NOT: call + // CHECK-NOT: load + // CHECK-NOT: store + // CHECK-NOT: getelementptr + // CHECK: %[[END:.+]] = getelementptr + // CHECK-NEXT: %[[DIM:.+]] = getelementptr + // CHECK-NEXT: %[[LAST:.+]] = load + // CHECK-NEXT: %[[FIRST:.+]] = shl + // CHECK-NEXT: call void @llvm.memmove + // CHECK-NEXT: store i32 %[[LAST]], ptr %[[DIM:.+]] + // CHECK-NOT: phi + // CHECK-NOT: call + // CHECK-NOT: load + // CHECK-NOT: store + // CHECK-NOT: getelementptr + // CHECK: ret void + if !slice.is_empty() { + slice.rotate_left(1); + } +} |
