| 1 |
// RUN: %clang_cc1 -x c -ffreestanding -triple i686--linux -no-enable-noundef-analysis -emit-llvm %s -o - | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG |
| 2 |
// RUN: %clang_cc1 -x c -ffreestanding -triple x86_64--linux -no-enable-noundef-analysis -emit-llvm %s -o - | FileCheck %s --check-prefixes CHECK,CHECK-64BIT-LONG |
| 3 |
// RUN: %clang_cc1 -x c -fms-extensions -fms-compatibility -ffreestanding %s -triple=i686-windows-msvc -target-feature +sse2 -no-enable-noundef-analysis -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG |
| 4 |
// RUN: %clang_cc1 -x c -fms-extensions -fms-compatibility -ffreestanding %s -triple=x86_64-windows-msvc -target-feature +sse2 -no-enable-noundef-analysis -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG |
| 5 |
// RUN: %clang_cc1 -x c -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 -ffreestanding %s -triple=i686-windows-msvc -target-feature +sse2 -no-enable-noundef-analysis -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG |
| 6 |
// RUN: %clang_cc1 -x c -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 -ffreestanding %s -triple=x86_64-windows-msvc -target-feature +sse2 -no-enable-noundef-analysis -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG |
| 7 |
|
| 8 |
// RUN: %clang_cc1 -x c++ -ffreestanding -triple i686--linux -no-enable-noundef-analysis -emit-llvm %s -o - | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG |
| 9 |
// RUN: %clang_cc1 -x c++ -ffreestanding -triple x86_64--linux -no-enable-noundef-analysis -emit-llvm %s -o - | FileCheck %s --check-prefixes CHECK,CHECK-64BIT-LONG |
| 10 |
// RUN: %clang_cc1 -x c++ -fms-extensions -fms-compatibility -ffreestanding %s -triple=i686-windows-msvc -target-feature +sse2 -no-enable-noundef-analysis -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG |
| 11 |
// RUN: %clang_cc1 -x c++ -fms-extensions -fms-compatibility -ffreestanding %s -triple=x86_64-windows-msvc -target-feature +sse2 -no-enable-noundef-analysis -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG |
| 12 |
// RUN: %clang_cc1 -x c++ -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 -ffreestanding %s -triple=i686-windows-msvc -target-feature +sse2 -no-enable-noundef-analysis -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG |
| 13 |
// RUN: %clang_cc1 -x c++ -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 -ffreestanding %s -triple=x86_64-windows-msvc -target-feature +sse2 -no-enable-noundef-analysis -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG |
| 14 |
|
| 15 |
// RUN: %clang_cc1 -x c++ -ffreestanding -triple i686--linux -no-enable-noundef-analysis -emit-llvm %s -o - -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG |
| 16 |
// RUN: %clang_cc1 -x c++ -ffreestanding -triple x86_64--linux -no-enable-noundef-analysis -emit-llvm %s -o - -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes CHECK,CHECK-64BIT-LONG |
| 17 |
// RUN: %clang_cc1 -x c++ -fms-extensions -fms-compatibility -ffreestanding %s -triple=i686-windows-msvc -target-feature +sse2 -no-enable-noundef-analysis -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG |
| 18 |
// RUN: %clang_cc1 -x c++ -fms-extensions -fms-compatibility -ffreestanding %s -triple=x86_64-windows-msvc -target-feature +sse2 -no-enable-noundef-analysis -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG |
| 19 |
// RUN: %clang_cc1 -x c++ -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 -ffreestanding %s -triple=i686-windows-msvc -target-feature +sse2 -no-enable-noundef-analysis -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG |
| 20 |
// RUN: %clang_cc1 -x c++ -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 -ffreestanding %s -triple=x86_64-windows-msvc -target-feature +sse2 -no-enable-noundef-analysis -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG |
| 21 |
|
| 22 |
#include <x86intrin.h> |
| 23 |
#include "builtin_test_helpers.h" |
| 24 |
|
| 25 |
unsigned char test__rolb(unsigned char value, int shift) { |
| 26 |
// CHECK-LABEL: test__rolb |
| 27 |
// CHECK: [[R:%.*]] = call i8 @llvm.fshl.i8(i8 [[X:%.*]], i8 [[X]], i8 [[Y:%.*]]) |
| 28 |
// CHECK: ret i8 [[R]] |
| 29 |
return __rolb(value, shift); |
| 30 |
} |
| 31 |
TEST_CONSTEXPR(__rolb(0x01, 5) == 0x20); |
| 32 |
|
| 33 |
unsigned short test__rolw(unsigned short value, int shift) { |
| 34 |
// CHECK-LABEL: test__rolw |
| 35 |
// CHECK: [[R:%.*]] = call i16 @llvm.fshl.i16(i16 [[X:%.*]], i16 [[X]], i16 [[Y:%.*]]) |
| 36 |
// CHECK: ret i16 [[R]] |
| 37 |
return __rolw(value, shift); |
| 38 |
} |
| 39 |
TEST_CONSTEXPR(__rolw(0x3210, 11) == 0x8190); |
| 40 |
|
| 41 |
unsigned int test__rold(unsigned int value, int shift) { |
| 42 |
// CHECK-LABEL: test__rold |
| 43 |
// CHECK: [[R:%.*]] = call i32 @llvm.fshl.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]]) |
| 44 |
// CHECK: ret i32 [[R]] |
| 45 |
return __rold(value, shift); |
| 46 |
} |
| 47 |
TEST_CONSTEXPR(__rold(0x76543210, 22) == 0x841D950C); |
| 48 |
|
| 49 |
#if defined(__x86_64__) |
| 50 |
unsigned long test__rolq(unsigned long value, int shift) { |
| 51 |
// CHECK-LONG-LABEL: test__rolq |
| 52 |
// CHECK-LONG: [[R:%.*]] = call i64 @llvm.fshl.i64(i64 [[X:%.*]], i64 [[X]], i64 [[Y:%.*]]) |
| 53 |
// CHECK-LONG: ret i64 [[R]] |
| 54 |
return __rolq(value, shift); |
| 55 |
} |
| 56 |
TEST_CONSTEXPR(__rolq(0xFEDCBA9876543210ULL, 55) == 0x087F6E5D4C3B2A19ULL); |
| 57 |
#endif |
| 58 |
|
| 59 |
unsigned char test__rorb(unsigned char value, int shift) { |
| 60 |
// CHECK-LABEL: test__rorb |
| 61 |
// CHECK: [[R:%.*]] = call i8 @llvm.fshr.i8(i8 [[X:%.*]], i8 [[X]], i8 [[Y:%.*]]) |
| 62 |
// CHECK: ret i8 [[R]] |
| 63 |
return __rorb(value, shift); |
| 64 |
} |
| 65 |
TEST_CONSTEXPR(__rorb(0x01, 5) == 0x08); |
| 66 |
|
| 67 |
unsigned short test__rorw(unsigned short value, int shift) { |
| 68 |
// CHECK-LABEL: test__rorw |
| 69 |
// CHECK: [[R:%.*]] = call i16 @llvm.fshr.i16(i16 [[X:%.*]], i16 [[X]], i16 [[Y:%.*]]) |
| 70 |
// CHECK: ret i16 [[R]] |
| 71 |
return __rorw(value, shift); |
| 72 |
} |
| 73 |
TEST_CONSTEXPR(__rorw(0x3210, 11) == 0x4206); |
| 74 |
|
| 75 |
unsigned int test__rord(unsigned int value, int shift) { |
| 76 |
// CHECK-LABEL: test__rord |
| 77 |
// CHECK: [[R:%.*]] = call i32 @llvm.fshr.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]]) |
| 78 |
// CHECK: ret i32 [[R]] |
| 79 |
return __rord(value, shift); |
| 80 |
} |
| 81 |
TEST_CONSTEXPR(__rord(0x76543210, 22) == 0x50C841D9); |
| 82 |
|
| 83 |
#if defined(__x86_64__) |
| 84 |
unsigned long test__rorq(unsigned long value, int shift) { |
| 85 |
// CHECK-LONG-LABEL: test__rorq |
| 86 |
// CHECK-LONG: [[R:%.*]] = call i64 @llvm.fshr.i64(i64 [[X:%.*]], i64 [[X]], i64 [[Y:%.*]]) |
| 87 |
// CHECK-LONG: ret i64 [[R]] |
| 88 |
return __rorq(value, shift); |
| 89 |
} |
| 90 |
TEST_CONSTEXPR(__rorq(0xFEDCBA9876543210ULL, 55) == 0xB97530ECA86421FDULL); |
| 91 |
#endif |
| 92 |
|
| 93 |
unsigned short test_rotwl(unsigned short value, int shift) { |
| 94 |
// CHECK-LABEL: test_rotwl |
| 95 |
// CHECK: [[R:%.*]] = call i16 @llvm.fshl.i16(i16 [[X:%.*]], i16 [[X]], i16 [[Y:%.*]]) |
| 96 |
// CHECK: ret i16 [[R]] |
| 97 |
return _rotwl(value, shift); |
| 98 |
} |
| 99 |
TEST_CONSTEXPR(_rotwl(0x3210, 4) == 0x2103); |
| 100 |
|
| 101 |
unsigned int test_rotl(unsigned int value, int shift) { |
| 102 |
// CHECK-LABEL: test_rotl |
| 103 |
// CHECK: [[R:%.*]] = call i32 @llvm.fshl.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]]) |
| 104 |
// CHECK: ret i32 [[R]] |
| 105 |
return _rotl(value, shift); |
| 106 |
} |
| 107 |
TEST_CONSTEXPR(_rotl(0x76543210, 8) == 0x54321076); |
| 108 |
|
| 109 |
unsigned long test_lrotl(unsigned long value, int shift) { |
| 110 |
// CHECK-32BIT-LONG-LABEL: test_lrotl |
| 111 |
// CHECK-32BIT-LONG: [[R:%.*]] = call i32 @llvm.fshl.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]]) |
| 112 |
// CHECK-32BIT-LONG: ret i32 [[R]] |
| 113 |
// |
| 114 |
// CHECK-64BIT-LONG-LABEL: test_lrotl |
| 115 |
// CHECK-64BIT-LONG: [[R:%.*]] = call i64 @llvm.fshl.i64(i64 [[X:%.*]], i64 [[X]], i64 [[Y:%.*]]) |
| 116 |
// CHECK-64BIT-LONG: ret i64 [[R]] |
| 117 |
return _lrotl(value, shift); |
| 118 |
} |
| 119 |
#if defined(__LP64__) && !defined(_MSC_VER) |
| 120 |
TEST_CONSTEXPR(_lrotl(0xFEDCBA9876543210ULL, 55) == 0x087F6E5D4C3B2A19ULL); |
| 121 |
#else |
| 122 |
TEST_CONSTEXPR(_lrotl(0x76543210, 22) == 0x841D950C); |
| 123 |
#endif |
| 124 |
|
| 125 |
|
| 126 |
unsigned short test_rotwr(unsigned short value, int shift) { |
| 127 |
// CHECK-LABEL: test_rotwr |
| 128 |
// CHECK: [[R:%.*]] = call i16 @llvm.fshr.i16(i16 [[X:%.*]], i16 [[X]], i16 [[Y:%.*]]) |
| 129 |
// CHECK: ret i16 [[R]] |
| 130 |
return _rotwr(value, shift); |
| 131 |
} |
| 132 |
TEST_CONSTEXPR(_rotwr(0x3210, 4) == 0x0321); |
| 133 |
|
| 134 |
unsigned int test_rotr(unsigned int value, int shift) { |
| 135 |
// CHECK-LABEL: test_rotr |
| 136 |
// CHECK: [[R:%.*]] = call i32 @llvm.fshr.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]]) |
| 137 |
// CHECK: ret i32 [[R]] |
| 138 |
return _rotr(value, shift); |
| 139 |
} |
| 140 |
TEST_CONSTEXPR(_rotr(0x76543210, 8) == 0x10765432); |
| 141 |
|
| 142 |
unsigned long test_lrotr(unsigned long value, int shift) { |
| 143 |
// CHECK-32BIT-LONG-LABEL: test_lrotr |
| 144 |
// CHECK-32BIT-LONG: [[R:%.*]] = call i32 @llvm.fshr.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]]) |
| 145 |
// CHECK-32BIT-LONG: ret i32 [[R]] |
| 146 |
// |
| 147 |
// CHECK-64BIT-LONG-LABEL: test_lrotr |
| 148 |
// CHECK-64BIT-LONG: [[R:%.*]] = call i64 @llvm.fshr.i64(i64 [[X:%.*]], i64 [[X]], i64 [[Y:%.*]]) |
| 149 |
// CHECK-64BIT-LONG: ret i64 [[R]] |
| 150 |
return _lrotr(value, shift); |
| 151 |
} |
| 152 |
#if defined(__LP64__) && !defined(_MSC_VER) |
| 153 |
TEST_CONSTEXPR(_lrotr(0xFEDCBA9876543210ULL, 55) == 0xB97530ECA86421FDULL); |
| 154 |
#else |
| 155 |
TEST_CONSTEXPR(_lrotr(0x76543210, 22) == 0x50C841D9); |
| 156 |
#endif |
| 157 |
|