Clang Project

clang_source_code/test/CodeGen/rot-intrinsics.c
1// RUN: %clang_cc1 -ffreestanding -triple i686--linux -emit-llvm %s -o - | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
2// RUN: %clang_cc1 -ffreestanding -triple x86_64--linux -emit-llvm %s -o - | FileCheck %s --check-prefixes CHECK,CHECK-64BIT-LONG
3// RUN: %clang_cc1 -fms-extensions -fms-compatibility -ffreestanding %s -triple=i686-windows-msvc -target-feature +sse2 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
4// RUN: %clang_cc1 -fms-extensions -fms-compatibility -ffreestanding %s -triple=x86_64-windows-msvc -target-feature +sse2 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
5// RUN: %clang_cc1 -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 -ffreestanding %s -triple=i686-windows-msvc -target-feature +sse2 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
6// RUN: %clang_cc1 -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 -ffreestanding %s -triple=x86_64-windows-msvc -target-feature +sse2 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
7
8#include <x86intrin.h>
9
10unsigned char test__rolb(unsigned char value, int shift) {
11// CHECK-LABEL: i8 @test__rolb
12// CHECK:   [[R:%.*]] = call i8 @llvm.fshl.i8(i8 [[X:%.*]], i8 [[X]], i8 [[Y:%.*]])
13// CHECK:   ret i8 [[R]]
14  return __rolb(value, shift);
15}
16
17unsigned short test__rolw(unsigned short value, int shift) {
18// CHECK-LABEL: i16 @test__rolw
19// CHECK:   [[R:%.*]] = call i16 @llvm.fshl.i16(i16 [[X:%.*]], i16 [[X]], i16 [[Y:%.*]])
20// CHECK:   ret i16 [[R]]
21  return __rolw(value, shift);
22}
23
24unsigned int test__rold(unsigned int value, int shift) {
25// CHECK-LABEL: i32 @test__rold
26// CHECK:   [[R:%.*]] = call i32 @llvm.fshl.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]])
27// CHECK:   ret i32 [[R]]
28  return __rold(value, shift);
29}
30
31#if defined(__x86_64__)
32unsigned long test__rolq(unsigned long value, int shift) {
33// CHECK-LONG-LABEL: i64 @test__rolq
34// CHECK-LONG:   [[R:%.*]] = call i64 @llvm.fshl.i64(i64 [[X:%.*]], i64 [[X]], i64 [[Y:%.*]])
35// CHECK-LONG:   ret i64 [[R]]
36  return __rolq(value, shift);
37}
38#endif
39
40unsigned char test__rorb(unsigned char value, int shift) {
41// CHECK-LABEL: i8 @test__rorb
42// CHECK:   [[R:%.*]] = call i8 @llvm.fshr.i8(i8 [[X:%.*]], i8 [[X]], i8 [[Y:%.*]])
43// CHECK:   ret i8 [[R]]
44  return __rorb(value, shift);
45}
46
47unsigned short test__rorw(unsigned short value, int shift) {
48// CHECK-LABEL: i16 @test__rorw
49// CHECK:   [[R:%.*]] = call i16 @llvm.fshr.i16(i16 [[X:%.*]], i16 [[X]], i16 [[Y:%.*]])
50// CHECK:   ret i16 [[R]]
51  return __rorw(value, shift);
52}
53
54unsigned int test__rord(unsigned int value, int shift) {
55// CHECK-LABEL: i32 @test__rord
56// CHECK:   [[R:%.*]] = call i32 @llvm.fshr.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]])
57// CHECK:   ret i32 [[R]]
58  return __rord(value, shift);
59}
60
61#if defined(__x86_64__)
62unsigned long test__rorq(unsigned long value, int shift) {
63// CHECK-LONG-LABEL: i64 @test__rorq
64// CHECK-LONG:   [[R:%.*]] = call i64 @llvm.fshr.i64(i64 [[X:%.*]], i64 [[X]], i64 [[Y:%.*]])
65// CHECK-LONG:   ret i64 [[R]]
66  return __rorq(value, shift);
67}
68#endif
69
70unsigned short test_rotwl(unsigned short value, int shift) {
71// CHECK-LABEL: i16 @test_rotwl
72// CHECK:   [[R:%.*]] = call i16 @llvm.fshl.i16(i16 [[X:%.*]], i16 [[X]], i16 [[Y:%.*]])
73// CHECK:   ret i16 [[R]]
74  return _rotwl(value, shift);
75}
76
77unsigned int test_rotl(unsigned int value, int shift) {
78// CHECK-LABEL: i32 @test_rotl
79// CHECK:   [[R:%.*]] = call i32 @llvm.fshl.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]])
80// CHECK:   ret i32 [[R]]
81  return _rotl(value, shift);
82}
83
84unsigned long test_lrotl(unsigned long value, int shift) {
85// CHECK-32BIT-LONG-LABEL: i32 @test_lrotl
86// CHECK-32BIT-LONG:   [[R:%.*]] = call i32 @llvm.fshl.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]])
87// CHECK-32BIT-LONG:   ret i32 [[R]]
88//
89// CHECK-64BIT-LONG-LABEL: i64 @test_lrotl
90// CHECK-64BIT-LONG:   [[R:%.*]] = call i64 @llvm.fshl.i64(i64 [[X:%.*]], i64 [[X]], i64 [[Y:%.*]])
91// CHECK-64BIT-LONG:   ret i64 [[R]]
92  return _lrotl(value, shift);
93}
94
95
96unsigned short test_rotwr(unsigned short value, int shift) {
97// CHECK-LABEL: i16 @test_rotwr
98// CHECK:   [[R:%.*]] = call i16 @llvm.fshr.i16(i16 [[X:%.*]], i16 [[X]], i16 [[Y:%.*]])
99// CHECK:   ret i16 [[R]]
100  return _rotwr(value, shift);
101}
102
103unsigned int test_rotr(unsigned int value, int shift) {
104// CHECK-LABEL: i32 @test_rotr
105// CHECK:   [[R:%.*]] = call i32 @llvm.fshr.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]])
106// CHECK:   ret i32 [[R]]
107  return _rotr(value, shift);
108}
109
110unsigned long test_lrotr(unsigned long value, int shift) {
111// CHECK-32BIT-LONG-LABEL: i32 @test_lrotr
112// CHECK-32BIT-LONG:   [[R:%.*]] = call i32 @llvm.fshr.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]])
113// CHECK-32BIT-LONG:   ret i32 [[R]]
114//
115// CHECK-64BIT-LONG-LABEL: i64 @test_lrotr
116// CHECK-64BIT-LONG:   [[R:%.*]] = call i64 @llvm.fshr.i64(i64 [[X:%.*]], i64 [[X]], i64 [[Y:%.*]])
117// CHECK-64BIT-LONG:   ret i64 [[R]]
118  return _lrotr(value, shift);
119}
120
121