blob: e635220e8c13fd05e68774b6469f33fc9e705134 [file] [log] [blame]
Albert Gutowski7216f172016-10-10 18:09:27 +00001// RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \
2// RUN: -triple i686--windows -Oz -emit-llvm %s -o - \
3// RUN: | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-I386
4// RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \
5// RUN: -triple x86_64--windows -Oz -emit-llvm %s -o - \
6// RUN: | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-X64
7
8#if defined(__i386__)
9long test__readfsdword(unsigned long Offset) {
10 return __readfsdword(Offset);
11}
12
13// CHECK-I386-LABEL: define i32 @test__readfsdword(i32 %Offset){{.*}}{
14// CHECK-I386: [[PTR:%[0-9]+]] = inttoptr i32 %Offset to i32 addrspace(257)*
15// CHECK-I386: [[VALUE:%[0-9]+]] = load volatile i32, i32 addrspace(257)* [[PTR]], align 4
16// CHECK-I386: ret i32 [[VALUE:%[0-9]+]]
17// CHECK-I386: }
18#endif
19
20__int64 test__emul(int a, int b) {
21 return __emul(a, b);
22}
23// CHECK-LABEL: define i64 @test__emul(i32 %a, i32 %b)
24// CHECK: [[X:%[0-9]+]] = sext i32 %a to i64
25// CHECK: [[Y:%[0-9]+]] = sext i32 %b to i64
26// CHECK: [[RES:%[0-9]+]] = mul nsw i64 [[Y]], [[X]]
27// CHECK: ret i64 [[RES]]
28
29unsigned __int64 test__emulu(unsigned int a, unsigned int b) {
30 return __emulu(a, b);
31}
32// CHECK-LABEL: define i64 @test__emulu(i32 %a, i32 %b)
33// CHECK: [[X:%[0-9]+]] = zext i32 %a to i64
34// CHECK: [[Y:%[0-9]+]] = zext i32 %b to i64
35// CHECK: [[RES:%[0-9]+]] = mul nuw i64 [[Y]], [[X]]
36// CHECK: ret i64 [[RES]]
37
38#if defined(__x86_64__)
39__int64 test__mulh(__int64 a, __int64 b) {
40 return __mulh(a, b);
41}
42// CHECK-X64-LABEL: define i64 @test__mulh(i64 %a, i64 %b)
43// CHECK-X64: = mul nsw i128 %
44
45unsigned __int64 test__umulh(unsigned __int64 a, unsigned __int64 b) {
46 return __umulh(a, b);
47}
48// CHECK-X64-LABEL: define i64 @test__umulh(i64 %a, i64 %b)
49// CHECK-X64: = mul nuw i128 %
50
51__int64 test_mul128(__int64 Multiplier,
52 __int64 Multiplicand,
53 __int64 *HighProduct) {
54 return _mul128(Multiplier, Multiplicand, HighProduct);
55}
56// CHECK-X64-LABEL: define i64 @test_mul128(i64 %Multiplier, i64 %Multiplicand, i64*{{[a-z_ ]*}}%HighProduct)
57// CHECK-X64: = sext i64 %Multiplier to i128
58// CHECK-X64: = sext i64 %Multiplicand to i128
59// CHECK-X64: = mul nsw i128 %
60// CHECK-X64: store i64 %
61// CHECK-X64: ret i64 %
62
63unsigned __int64 test_umul128(unsigned __int64 Multiplier,
64 unsigned __int64 Multiplicand,
65 unsigned __int64 *HighProduct) {
66 return _umul128(Multiplier, Multiplicand, HighProduct);
67}
68// CHECK-X64-LABEL: define i64 @test_umul128(i64 %Multiplier, i64 %Multiplicand, i64*{{[a-z_ ]*}}%HighProduct)
69// CHECK-X64: = zext i64 %Multiplier to i128
70// CHECK-X64: = zext i64 %Multiplicand to i128
71// CHECK-X64: = mul nuw i128 %
72// CHECK-X64: store i64 %
73// CHECK-X64: ret i64 %
74#endif