1
Fork 0

add inline attribute and codegen test

This commit is contained in:
edwloef 2025-01-28 12:26:32 +01:00
parent 311c3b71f0
commit fb3d1d0c4b
No known key found for this signature in database
2 changed files with 34 additions and 0 deletions

View file

@ -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);
}
}