1 // RUN: %clang_cc1 -x c -triple x86_64-unknown-unknown -ffreestanding -target-feature +adx -emit-llvm -o - %s | FileCheck %s
2 // RUN: %clang_cc1 -x c++ -triple x86_64-unknown-unknown -ffreestanding -target-feature +adx -emit-llvm -o - %s | FileCheck %s
6 unsigned char test_addcarryx_u32(unsigned char __cf
, unsigned int __x
,
7 unsigned int __y
, unsigned int *__p
) {
8 // CHECK-LABEL: test_addcarryx_u32
9 // CHECK: [[ADC:%.*]] = call { i8, i32 } @llvm.x86.addcarry.32
10 // CHECK: [[DATA:%.*]] = extractvalue { i8, i32 } [[ADC]], 1
11 // CHECK: store i32 [[DATA]], ptr %{{.*}}
12 // CHECK: [[CF:%.*]] = extractvalue { i8, i32 } [[ADC]], 0
13 return _addcarryx_u32(__cf
, __x
, __y
, __p
);
16 unsigned char test_addcarryx_u64(unsigned char __cf
, unsigned long long __x
,
17 unsigned long long __y
,
18 unsigned long long *__p
) {
19 // CHECK-LABEL: test_addcarryx_u64
20 // CHECK: [[ADC:%.*]] = call { i8, i64 } @llvm.x86.addcarry.64
21 // CHECK: [[DATA:%.*]] = extractvalue { i8, i64 } [[ADC]], 1
22 // CHECK: store i64 [[DATA]], ptr %{{.*}}
23 // CHECK: [[CF:%.*]] = extractvalue { i8, i64 } [[ADC]], 0
24 return _addcarryx_u64(__cf
, __x
, __y
, __p
);
27 // Test constexpr handling.
28 #if defined(__cplusplus) && (__cplusplus >= 201103L)
34 constexpr bool operator==(const Result
<X
> &Other
) {
35 return A
== Other
.A
&& B
== Other
.B
;
39 constexpr Result
<unsigned int>
40 const_test_addcarryx_u32(unsigned char __cf
, unsigned int __x
, unsigned int __y
)
43 return { _addcarryx_u32(__cf
, __x
, __y
, &__r
), __r
};
46 void constexpr addxu32() {
47 static_assert(const_test_addcarryx_u32(0, 0x00000000, 0x00000000) == Result
<unsigned int>{0, 0x00000000});
48 static_assert(const_test_addcarryx_u32(1, 0xFFFFFFFE, 0x00000000) == Result
<unsigned int>{0, 0xFFFFFFFF});
49 static_assert(const_test_addcarryx_u32(1, 0xFFFFFFFE, 0x00000001) == Result
<unsigned int>{1, 0x00000000});
50 static_assert(const_test_addcarryx_u32(0, 0xFFFFFFFF, 0xFFFFFFFF) == Result
<unsigned int>{1, 0xFFFFFFFE});
51 static_assert(const_test_addcarryx_u32(1, 0xFFFFFFFF, 0xFFFFFFFF) == Result
<unsigned int>{1, 0xFFFFFFFF});
54 constexpr Result
<unsigned long long>
55 const_test_addcarryx_u64(unsigned char __cf
, unsigned long long __x
, unsigned long long __y
)
57 unsigned long long __r
{};
58 return { _addcarryx_u64(__cf
, __x
, __y
, &__r
), __r
};
61 void constexpr addxu64() {
62 static_assert(const_test_addcarryx_u64(0, 0x0000000000000000ULL
, 0x0000000000000000ULL
) == Result
<unsigned long long>{0, 0x0000000000000000ULL
});
63 static_assert(const_test_addcarryx_u64(1, 0xFFFFFFFFFFFFFFFEULL
, 0x0000000000000000ULL
) == Result
<unsigned long long>{0, 0xFFFFFFFFFFFFFFFFULL
});
64 static_assert(const_test_addcarryx_u64(1, 0xFFFFFFFFFFFFFFFEULL
, 0x0000000000000001ULL
) == Result
<unsigned long long>{1, 0x0000000000000000ULL
});
65 static_assert(const_test_addcarryx_u64(0, 0xFFFFFFFFFFFFFFFFULL
, 0xFFFFFFFFFFFFFFFFULL
) == Result
<unsigned long long>{1, 0xFFFFFFFFFFFFFFFEULL
});
66 static_assert(const_test_addcarryx_u64(1, 0xFFFFFFFFFFFFFFFFULL
, 0xFFFFFFFFFFFFFFFFULL
) == Result
<unsigned long long>{1, 0xFFFFFFFFFFFFFFFFULL
});