xref: /llvm-project/clang/test/CodeGen/AArch64/neon-shifts.c (revision 207e5ccceec8d3cc3f32723e78f2a142bc61b07d)
1*207e5cccSFangrui Song // RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon \
2*207e5cccSFangrui Song // RUN:  -disable-O0-optnone -ffp-contract=fast -emit-llvm -o - %s | opt -S -passes=mem2reg | FileCheck %s
3*207e5cccSFangrui Song 
4*207e5cccSFangrui Song // REQUIRES: aarch64-registered-target || arm-registered-target
5*207e5cccSFangrui Song 
6*207e5cccSFangrui Song #include <arm_neon.h>
7*207e5cccSFangrui Song 
8*207e5cccSFangrui Song uint8x8_t test_shift_vshr(uint8x8_t a) {
9*207e5cccSFangrui Song   // CHECK-LABEL: test_shift_vshr
10*207e5cccSFangrui Song   // CHECK: %{{.*}} = lshr <8 x i8> %a, splat (i8 5)
11*207e5cccSFangrui Song   return vshr_n_u8(a, 5);
12*207e5cccSFangrui Song }
13*207e5cccSFangrui Song 
14*207e5cccSFangrui Song int8x8_t test_shift_vshr_smax(int8x8_t a) {
15*207e5cccSFangrui Song   // CHECK-LABEL: test_shift_vshr_smax
16*207e5cccSFangrui Song   // CHECK: %{{.*}} = ashr <8 x i8> %a, splat (i8 7)
17*207e5cccSFangrui Song   return vshr_n_s8(a, 8);
18*207e5cccSFangrui Song }
19*207e5cccSFangrui Song 
20*207e5cccSFangrui Song uint8x8_t test_shift_vshr_umax(uint8x8_t a) {
21*207e5cccSFangrui Song   // CHECK-LABEL: test_shift_vshr_umax
22*207e5cccSFangrui Song   // CHECK: ret <8 x i8> zeroinitializer
23*207e5cccSFangrui Song   return vshr_n_u8(a, 8);
24*207e5cccSFangrui Song }
25*207e5cccSFangrui Song 
26*207e5cccSFangrui Song uint8x8_t test_shift_vsra(uint8x8_t a, uint8x8_t b) {
27*207e5cccSFangrui Song   // CHECK-LABEL: test_shift_vsra
28*207e5cccSFangrui Song   // CHECK: %[[SHR:.*]] = lshr <8 x i8> %b, splat (i8 5)
29*207e5cccSFangrui Song   // CHECK: %{{.*}} = add <8 x i8> %a, %[[SHR]]
30*207e5cccSFangrui Song   return vsra_n_u8(a, b, 5);
31*207e5cccSFangrui Song }
32*207e5cccSFangrui Song 
33*207e5cccSFangrui Song int8x8_t test_shift_vsra_smax(int8x8_t a, int8x8_t b) {
34*207e5cccSFangrui Song   // CHECK-LABEL: test_shift_vsra_smax
35*207e5cccSFangrui Song   // CHECK: %[[SHR:.*]] = ashr <8 x i8> %b, splat (i8 7)
36*207e5cccSFangrui Song   // CHECK: %{{.*}} = add <8 x i8> %a, %[[SHR]]
37*207e5cccSFangrui Song   return vsra_n_s8(a, b, 8);
38*207e5cccSFangrui Song }
39*207e5cccSFangrui Song 
40*207e5cccSFangrui Song uint8x8_t test_shift_vsra_umax(uint8x8_t a, uint8x8_t b) {
41*207e5cccSFangrui Song   // CHECK-LABEL: test_shift_vsra_umax
42*207e5cccSFangrui Song   // CHECK: [[RES:%.*]] = add <8 x i8> %a, zeroinitializer
43*207e5cccSFangrui Song   // CHECK: ret <8 x i8> [[RES]]
44*207e5cccSFangrui Song   return vsra_n_u8(a, b, 8);
45*207e5cccSFangrui Song }
46