Add codegen tests for changed intrinsics
This commit is contained in:
parent
7ce867f552
commit
c2046c4b09
56
tests/codegen/intrinsics/ctlz.rs
Normal file
56
tests/codegen/intrinsics/ctlz.rs
Normal file
@ -0,0 +1,56 @@
|
||||
//@ compile-flags: -C no-prepopulate-passes
|
||||
|
||||
#![crate_type = "lib"]
|
||||
#![feature(core_intrinsics)]
|
||||
|
||||
use std::intrinsics::{ctlz, ctlz_nonzero};
|
||||
|
||||
// CHECK-LABEL: @ctlz_u16
|
||||
#[no_mangle]
|
||||
pub unsafe fn ctlz_u16(x: u16) -> u32 {
|
||||
// CHECK: %[[tmp:.*]] = call i16 @llvm.ctlz.i16(i16 %x, i1 false)
|
||||
// CHECK: zext i16 %[[tmp]] to i32
|
||||
ctlz(x)
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @ctlz_nzu16
|
||||
#[no_mangle]
|
||||
pub unsafe fn ctlz_nzu16(x: u16) -> u32 {
|
||||
// CHECK: %[[tmp:.*]] = call i16 @llvm.ctlz.i16(i16 %x, i1 true)
|
||||
// CHECK: zext i16 %[[tmp]] to i32
|
||||
ctlz_nonzero(x)
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @ctlz_u32
|
||||
#[no_mangle]
|
||||
pub unsafe fn ctlz_u32(x: u32) -> u32 {
|
||||
// CHECK: call i32 @llvm.ctlz.i32(i32 %x, i1 false)
|
||||
// CHECK-NOT: zext
|
||||
// CHECK-NOT: trunc
|
||||
ctlz(x)
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @ctlz_nzu32
|
||||
#[no_mangle]
|
||||
pub unsafe fn ctlz_nzu32(x: u32) -> u32 {
|
||||
// CHECK: call i32 @llvm.ctlz.i32(i32 %x, i1 true)
|
||||
// CHECK-NOT: zext
|
||||
// CHECK-NOT: trunc
|
||||
ctlz_nonzero(x)
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @ctlz_u64
|
||||
#[no_mangle]
|
||||
pub unsafe fn ctlz_u64(x: u64) -> u32 {
|
||||
// CHECK: %[[tmp:.*]] = call i64 @llvm.ctlz.i64(i64 %x, i1 false)
|
||||
// CHECK: trunc i64 %[[tmp]] to i32
|
||||
ctlz(x)
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @ctlz_nzu64
|
||||
#[no_mangle]
|
||||
pub unsafe fn ctlz_nzu64(x: u64) -> u32 {
|
||||
// CHECK: %[[tmp:.*]] = call i64 @llvm.ctlz.i64(i64 %x, i1 true)
|
||||
// CHECK: trunc i64 %[[tmp]] to i32
|
||||
ctlz_nonzero(x)
|
||||
}
|
31
tests/codegen/intrinsics/ctpop.rs
Normal file
31
tests/codegen/intrinsics/ctpop.rs
Normal file
@ -0,0 +1,31 @@
|
||||
//@ compile-flags: -C no-prepopulate-passes
|
||||
|
||||
#![crate_type = "lib"]
|
||||
#![feature(core_intrinsics)]
|
||||
|
||||
use std::intrinsics::ctpop;
|
||||
|
||||
// CHECK-LABEL: @ctpop_u16
|
||||
#[no_mangle]
|
||||
pub unsafe fn ctpop_u16(x: u16) -> u32 {
|
||||
// CHECK: %[[tmp:.*]] = call i16 @llvm.ctpop.i16(i16 %x)
|
||||
// CHECK: zext i16 %[[tmp]] to i32
|
||||
ctpop(x)
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @ctpop_u32
|
||||
#[no_mangle]
|
||||
pub unsafe fn ctpop_u32(x: u32) -> u32 {
|
||||
// CHECK: call i32 @llvm.ctpop.i32(i32 %x)
|
||||
// CHECK-NOT: zext
|
||||
// CHECK-NOT: trunc
|
||||
ctpop(x)
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @ctpop_u64
|
||||
#[no_mangle]
|
||||
pub unsafe fn ctpop_u64(x: u64) -> u32 {
|
||||
// CHECK: %[[tmp:.*]] = call i64 @llvm.ctpop.i64(i64 %x)
|
||||
// CHECK: trunc i64 %[[tmp]] to i32
|
||||
ctpop(x)
|
||||
}
|
31
tests/codegen/intrinsics/rotate_left.rs
Normal file
31
tests/codegen/intrinsics/rotate_left.rs
Normal file
@ -0,0 +1,31 @@
|
||||
//@ compile-flags: -C no-prepopulate-passes
|
||||
|
||||
#![crate_type = "lib"]
|
||||
#![feature(core_intrinsics)]
|
||||
|
||||
use std::intrinsics::rotate_left;
|
||||
|
||||
// CHECK-LABEL: @rotate_left_u16
|
||||
#[no_mangle]
|
||||
pub unsafe fn rotate_left_u16(x: u16, shift: u32) -> u16 {
|
||||
// CHECK: %[[tmp:.*]] = trunc i32 %shift to i16
|
||||
// CHECK: call i16 @llvm.fshl.i16(i16 %x, i16 %x, i16 %[[tmp]])
|
||||
rotate_left(x, shift)
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @rotate_left_u32
|
||||
#[no_mangle]
|
||||
pub unsafe fn rotate_left_u32(x: u32, shift: u32) -> u32 {
|
||||
// CHECK-NOT: trunc
|
||||
// CHECK-NOT: zext
|
||||
// CHECK: call i32 @llvm.fshl.i32(i32 %x, i32 %x, i32 %shift)
|
||||
rotate_left(x, shift)
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @rotate_left_u64
|
||||
#[no_mangle]
|
||||
pub unsafe fn rotate_left_u64(x: u64, shift: u32) -> u64 {
|
||||
// CHECK: %[[tmp:.*]] = zext i32 %shift to i64
|
||||
// CHECK: call i64 @llvm.fshl.i64(i64 %x, i64 %x, i64 %[[tmp]])
|
||||
rotate_left(x, shift)
|
||||
}
|
Loading…
Reference in New Issue
Block a user