[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGen / builtin-rotate.c
blob8fc1701c6c9bbe4306ad6492e93aa91b10f596e8
1 // RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
3 unsigned char rotl8(unsigned char x, unsigned char y) {
4 // CHECK-LABEL: rotl8
5 // CHECK: [[F:%.*]] = call i8 @llvm.fshl.i8(i8 [[X:%.*]], i8 [[X]], i8 [[Y:%.*]])
6 // CHECK-NEXT: ret i8 [[F]]
8 return __builtin_rotateleft8(x, y);
11 short rotl16(short x, short y) {
12 // CHECK-LABEL: rotl16
13 // CHECK: [[F:%.*]] = call i16 @llvm.fshl.i16(i16 [[X:%.*]], i16 [[X]], i16 [[Y:%.*]])
14 // CHECK-NEXT: ret i16 [[F]]
16 return __builtin_rotateleft16(x, y);
19 int rotl32(int x, unsigned int y) {
20 // CHECK-LABEL: rotl32
21 // CHECK: [[F:%.*]] = call i32 @llvm.fshl.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]])
22 // CHECK-NEXT: ret i32 [[F]]
24 return __builtin_rotateleft32(x, y);
27 unsigned long long rotl64(unsigned long long x, long long y) {
28 // CHECK-LABEL: rotl64
29 // CHECK: [[F:%.*]] = call i64 @llvm.fshl.i64(i64 [[X:%.*]], i64 [[X]], i64 [[Y:%.*]])
30 // CHECK-NEXT: ret i64 [[F]]
32 return __builtin_rotateleft64(x, y);
35 char rotr8(char x, char y) {
36 // CHECK-LABEL: rotr8
37 // CHECK: [[F:%.*]] = call i8 @llvm.fshr.i8(i8 [[X:%.*]], i8 [[X]], i8 [[Y:%.*]])
38 // CHECK-NEXT: ret i8 [[F]]
40 return __builtin_rotateright8(x, y);
43 unsigned short rotr16(unsigned short x, unsigned short y) {
44 // CHECK-LABEL: rotr16
45 // CHECK: [[F:%.*]] = call i16 @llvm.fshr.i16(i16 [[X:%.*]], i16 [[X]], i16 [[Y:%.*]])
46 // CHECK-NEXT: ret i16 [[F]]
48 return __builtin_rotateright16(x, y);
51 unsigned int rotr32(unsigned int x, int y) {
52 // CHECK-LABEL: rotr32
53 // CHECK: [[F:%.*]] = call i32 @llvm.fshr.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]])
54 // CHECK-NEXT: ret i32 [[F]]
56 return __builtin_rotateright32(x, y);
59 long long rotr64(long long x, unsigned long long y) {
60 // CHECK-LABEL: rotr64
61 // CHECK: [[F:%.*]] = call i64 @llvm.fshr.i64(i64 [[X:%.*]], i64 [[X]], i64 [[Y:%.*]])
62 // CHECK-NEXT: ret i64 [[F]]
64 return __builtin_rotateright64(x, y);