| 1 |
// RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-apple-darwin -no-enable-noundef-analysis -emit-llvm -o - | FileCheck %s |
| 2 |
// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin -no-enable-noundef-analysis -emit-llvm -o - | FileCheck %s |
| 3 |
|
| 4 |
// RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-apple-darwin -no-enable-noundef-analysis -emit-llvm -o - -fexperimental-new-constant-interpreter | FileCheck %s |
| 5 |
// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin -no-enable-noundef-analysis -emit-llvm -o - -fexperimental-new-constant-interpreter | FileCheck %s |
| 6 |
|
| 7 |
|
| 8 |
#include <x86intrin.h> |
| 9 |
#include "builtin_test_helpers.h" |
| 10 |
|
| 11 |
int test__bswapd(int X) { |
| 12 |
// CHECK-LABEL: test__bswapd |
| 13 |
// CHECK: call i32 @llvm.bswap.i32 |
| 14 |
return __bswapd(X); |
| 15 |
} |
| 16 |
TEST_CONSTEXPR(__bswapd(0x00000000) == 0x00000000); |
| 17 |
TEST_CONSTEXPR(__bswapd(0x01020304) == 0x04030201); |
| 18 |
|
| 19 |
int test_bswap(int X) { |
| 20 |
// CHECK-LABEL: test_bswap |
| 21 |
// CHECK: call i32 @llvm.bswap.i32 |
| 22 |
return _bswap(X); |
| 23 |
} |
| 24 |
TEST_CONSTEXPR(_bswap(0x00000000) == 0x00000000); |
| 25 |
TEST_CONSTEXPR(_bswap(0x10203040) == 0x40302010); |
| 26 |
|
| 27 |
long test__bswapq(long long X) { |
| 28 |
// CHECK-LABEL: test__bswapq |
| 29 |
// CHECK: call i64 @llvm.bswap.i64 |
| 30 |
return __bswapq(X); |
| 31 |
} |
| 32 |
TEST_CONSTEXPR(__bswapq(0x0000000000000000ULL) == 0x0000000000000000); |
| 33 |
TEST_CONSTEXPR(__bswapq(0x0102030405060708ULL) == 0x0807060504030201); |
| 34 |
|
| 35 |
long test_bswap64(long long X) { |
| 36 |
// CHECK-LABEL: test_bswap64 |
| 37 |
// CHECK: call i64 @llvm.bswap.i64 |
| 38 |
return _bswap64(X); |
| 39 |
} |
| 40 |
TEST_CONSTEXPR(_bswap64(0x0000000000000000ULL) == 0x0000000000000000); |
| 41 |
TEST_CONSTEXPR(_bswap64(0x1020304050607080ULL) == 0x8070605040302010); |