xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGen/arm-neon-shifts.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // REQUIRES: arm-registered-target
2*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple thumbv7-apple-darwin \
3*f4a2713aSLionel Sambuc // RUN:   -target-cpu cortex-a8 \
4*f4a2713aSLionel Sambuc // RUN:   -ffreestanding \
5*f4a2713aSLionel Sambuc // RUN:   -emit-llvm -w -O1 -o - %s | FileCheck %s
6*f4a2713aSLionel Sambuc 
7*f4a2713aSLionel Sambuc #include <arm_neon.h>
8*f4a2713aSLionel Sambuc 
test_shift_vshr(uint8x8_t a)9*f4a2713aSLionel Sambuc uint8x8_t test_shift_vshr(uint8x8_t a) {
10*f4a2713aSLionel Sambuc   // CHECK-LABEL: test_shift_vshr
11*f4a2713aSLionel Sambuc   // CHECK: %{{.*}} = lshr <8 x i8> %a, <i8 5, i8 5, i8 5, i8 5, i8 5, i8 5, i8 5, i8 5>
12*f4a2713aSLionel Sambuc   return vshr_n_u8(a, 5);
13*f4a2713aSLionel Sambuc }
14*f4a2713aSLionel Sambuc 
test_shift_vshr_smax(int8x8_t a)15*f4a2713aSLionel Sambuc int8x8_t test_shift_vshr_smax(int8x8_t a) {
16*f4a2713aSLionel Sambuc   // CHECK-LABEL: test_shift_vshr_smax
17*f4a2713aSLionel Sambuc   // CHECK: %{{.*}} = ashr <8 x i8> %a, <i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7>
18*f4a2713aSLionel Sambuc   return vshr_n_s8(a, 8);
19*f4a2713aSLionel Sambuc }
20*f4a2713aSLionel Sambuc 
test_shift_vshr_umax(uint8x8_t a)21*f4a2713aSLionel Sambuc uint8x8_t test_shift_vshr_umax(uint8x8_t a) {
22*f4a2713aSLionel Sambuc   // CHECK-LABEL: test_shift_vshr_umax
23*f4a2713aSLionel Sambuc   // CHECK: ret <8 x i8> zeroinitializer
24*f4a2713aSLionel Sambuc   return vshr_n_u8(a, 8);
25*f4a2713aSLionel Sambuc }
26*f4a2713aSLionel Sambuc 
test_shift_vsra(uint8x8_t a,uint8x8_t b)27*f4a2713aSLionel Sambuc uint8x8_t test_shift_vsra(uint8x8_t a, uint8x8_t b) {
28*f4a2713aSLionel Sambuc   // CHECK-LABEL: test_shift_vsra
29*f4a2713aSLionel Sambuc   // CHECK: %[[SHR:.*]] = lshr <8 x i8> %b, <i8 5, i8 5, i8 5, i8 5, i8 5, i8 5, i8 5, i8 5>
30*f4a2713aSLionel Sambuc   // CHECK: %{{.*}} = add <8 x i8> %[[SHR]], %a
31*f4a2713aSLionel Sambuc   return vsra_n_u8(a, b, 5);
32*f4a2713aSLionel Sambuc }
33*f4a2713aSLionel Sambuc 
test_shift_vsra_smax(int8x8_t a,int8x8_t b)34*f4a2713aSLionel Sambuc int8x8_t test_shift_vsra_smax(int8x8_t a, int8x8_t b) {
35*f4a2713aSLionel Sambuc   // CHECK-LABEL: test_shift_vsra_smax
36*f4a2713aSLionel Sambuc   // CHECK: %[[SHR:.*]] = ashr <8 x i8> %b, <i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7>
37*f4a2713aSLionel Sambuc   // CHECK: %{{.*}} = add <8 x i8> %[[SHR]], %a
38*f4a2713aSLionel Sambuc   return vsra_n_s8(a, b, 8);
39*f4a2713aSLionel Sambuc }
40*f4a2713aSLionel Sambuc 
test_shift_vsra_umax(uint8x8_t a,uint8x8_t b)41*f4a2713aSLionel Sambuc uint8x8_t test_shift_vsra_umax(uint8x8_t a, uint8x8_t b) {
42*f4a2713aSLionel Sambuc   // CHECK-LABEL: test_shift_vsra_umax
43*f4a2713aSLionel Sambuc   // CHECK: ret <8 x i8> %a
44*f4a2713aSLionel Sambuc   return vsra_n_u8(a, b, 8);
45*f4a2713aSLionel Sambuc }
46