1 ; RUN: llc -O3 -disable-peephole -mtriple=x86_64-unknown-unknown -mattr=+adx < %s | FileCheck %s --check-prefix=CHECK --check-prefix=ADX
2 ; RUN: llc -O3 -disable-peephole -mtriple=x86_64-unknown-unknown -mattr=-adx < %s | FileCheck %s --check-prefix=CHECK --check-prefix=NOADX
4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-unknown-unknown"
7 ; Stack reload folding tests.
9 ; By including a nop call with sideeffects we can force a partial register spill of the
10 ; relevant registers and check that the reload is correctly folded into the instruction.
12 define i8 @stack_fold_addcarry_u32(i8 %a0, i32 %a1, i32 %a2, i8* %a3) {
13 ;CHECK-LABEL: stack_fold_addcarry_u32
14 ;CHECK: adcl {{-?[0-9]*}}(%rsp), %{{.*}} {{.*#+}} 4-byte Folded Reload
15 %1 = tail call i64 asm sideeffect "nop", "=x,~{rax},~{rbx},~{rcx},~{rdx},~{rsi},~{rdi},~{rbp},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15}"()
16 %2 = call { i8, i32 } @llvm.x86.addcarry.32(i8 %a0, i32 %a1, i32 %a2)
17 %3 = extractvalue { i8, i32 } %2, 1
18 %4 = bitcast i8* %a3 to i32*
19 store i32 %3, i32* %4, align 1
20 %5 = extractvalue { i8, i32 } %2, 0
24 define i8 @stack_fold_addcarry_u64(i8 %a0, i64 %a1, i64 %a2, i8* %a3) {
25 ;CHECK-LABEL: stack_fold_addcarry_u64
26 ;CHECK: adcq {{-?[0-9]*}}(%rsp), %{{.*}} {{.*#+}} 8-byte Folded Reload
27 %1 = tail call i64 asm sideeffect "nop", "=x,~{rax},~{rbx},~{rcx},~{rdx},~{rsi},~{rdi},~{rbp},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15}"()
28 %2 = call { i8, i64 } @llvm.x86.addcarry.64(i8 %a0, i64 %a1, i64 %a2)
29 %3 = extractvalue { i8, i64 } %2, 1
30 %4 = bitcast i8* %a3 to i64*
31 store i64 %3, i64* %4, align 1
32 %5 = extractvalue { i8, i64 } %2, 0
36 define i8 @stack_fold_addcarryx_u32(i8 %a0, i32 %a1, i32 %a2, i8* %a3) {
37 ;CHECK-LABEL: stack_fold_addcarryx_u32
38 ;CHECK: adcl {{-?[0-9]*}}(%rsp), %{{.*}} {{.*#+}} 4-byte Folded Reload
39 %1 = tail call i64 asm sideeffect "nop", "=x,~{rax},~{rbx},~{rcx},~{rdx},~{rsi},~{rdi},~{rbp},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15}"()
40 %2 = call { i8, i32 } @llvm.x86.addcarry.32(i8 %a0, i32 %a1, i32 %a2)
41 %3 = extractvalue { i8, i32 } %2, 1
42 %4 = bitcast i8* %a3 to i32*
43 store i32 %3, i32* %4, align 1
44 %5 = extractvalue { i8, i32 } %2, 0
48 define i8 @stack_fold_addcarryx_u64(i8 %a0, i64 %a1, i64 %a2, i8* %a3) {
49 ;CHECK-LABEL: stack_fold_addcarryx_u64
50 ;CHECK: adcq {{-?[0-9]*}}(%rsp), %{{.*}} {{.*#+}} 8-byte Folded Reload
51 %1 = tail call i64 asm sideeffect "nop", "=x,~{rax},~{rbx},~{rcx},~{rdx},~{rsi},~{rdi},~{rbp},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15}"()
52 %2 = call { i8, i64 } @llvm.x86.addcarry.64(i8 %a0, i64 %a1, i64 %a2)
53 %3 = extractvalue { i8, i64 } %2, 1
54 %4 = bitcast i8* %a3 to i64*
55 store i64 %3, i64* %4, align 1
56 %5 = extractvalue { i8, i64 } %2, 0
60 define i8 @stack_fold_subborrow_u32(i8 %a0, i32 %a1, i32 %a2, i8* %a3) {
61 ;CHECK-LABEL: stack_fold_subborrow_u32
62 ;CHECK: sbbl {{-?[0-9]*}}(%rsp), %{{.*}} {{.*#+}} 4-byte Folded Reload
63 %1 = tail call i64 asm sideeffect "nop", "=x,~{rax},~{rbx},~{rcx},~{rdx},~{rsi},~{rdi},~{rbp},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15}"()
64 %2 = call { i8, i32 } @llvm.x86.subborrow.32(i8 %a0, i32 %a1, i32 %a2)
65 %3 = extractvalue { i8, i32 } %2, 1
66 %4 = bitcast i8* %a3 to i32*
67 store i32 %3, i32* %4, align 1
68 %5 = extractvalue { i8, i32 } %2, 0
72 define i8 @stack_fold_subborrow_u64(i8 %a0, i64 %a1, i64 %a2, i8* %a3) {
73 ;CHECK-LABEL: stack_fold_subborrow_u64
74 ;CHECK: sbbq {{-?[0-9]*}}(%rsp), %{{.*}} {{.*#+}} 8-byte Folded Reload
75 %1 = tail call i64 asm sideeffect "nop", "=x,~{rax},~{rbx},~{rcx},~{rdx},~{rsi},~{rdi},~{rbp},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15}"()
76 %2 = call { i8, i64 } @llvm.x86.subborrow.64(i8 %a0, i64 %a1, i64 %a2)
77 %3 = extractvalue { i8, i64 } %2, 1
78 %4 = bitcast i8* %a3 to i64*
79 store i64 %3, i64* %4, align 1
80 %5 = extractvalue { i8, i64 } %2, 0
84 declare { i8, i32 } @llvm.x86.addcarry.32(i8, i32, i32)
85 declare { i8, i64 } @llvm.x86.addcarry.64(i8, i64, i64)
86 declare { i8, i32 } @llvm.x86.subborrow.32(i8, i32, i32)
87 declare { i8, i64 } @llvm.x86.subborrow.64(i8, i64, i64)