1 ; RUN: llc -O3 -disable-peephole -mtriple=x86_64-unknown-unknown -mattr=+bmi,+bmi2 < %s | FileCheck %s
3 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-unknown-unknown"
6 ; Stack reload folding tests.
8 ; By including a nop call with sideeffects we can force a partial register spill of the
9 ; relevant registers and check that the reload is correctly folded into the instruction.
11 define i32 @stack_fold_bzhi_u32(i32 %a0, i32 %a1) {
12 ;CHECK-LABEL: stack_fold_bzhi_u32
13 ;CHECK: bzhil %eax, {{-?[0-9]*}}(%rsp), %eax {{.*#+}} 4-byte Folded Reload
14 %1 = tail call i32 asm sideeffect "nop", "=x,~{rax},~{rbx},~{rcx},~{rdx},~{rsi},~{rdi},~{rbp},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15}"()
15 %2 = tail call i32 @llvm.x86.bmi.bzhi.32(i32 %a0, i32 %a1)
18 declare i32 @llvm.x86.bmi.bzhi.32(i32, i32)
20 define i64 @stack_fold_bzhi_u64(i64 %a0, i64 %a1) {
21 ;CHECK-LABEL: stack_fold_bzhi_u64
22 ;CHECK: bzhiq %rax, {{-?[0-9]*}}(%rsp), %rax {{.*#+}} 8-byte Folded Reload
23 %1 = tail call i64 asm sideeffect "nop", "=x,~{rax},~{rbx},~{rcx},~{rdx},~{rsi},~{rdi},~{rbp},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15}"()
24 %2 = tail call i64 @llvm.x86.bmi.bzhi.64(i64 %a0, i64 %a1)
27 declare i64 @llvm.x86.bmi.bzhi.64(i64, i64)
29 define i32 @stack_fold_pdep_u32(i32 %a0, i32 %a1) {
30 ;CHECK-LABEL: stack_fold_pdep_u32
31 ;CHECK: pdepl {{-?[0-9]*}}(%rsp), %eax, %eax {{.*#+}} 4-byte Folded Reload
32 %1 = tail call i32 asm sideeffect "nop", "=x,~{rax},~{rbx},~{rcx},~{rdx},~{rsi},~{rdi},~{rbp},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15}"()
33 %2 = tail call i32 @llvm.x86.bmi.pdep.32(i32 %a0, i32 %a1)
36 declare i32 @llvm.x86.bmi.pdep.32(i32, i32)
38 define i64 @stack_fold_pdep_u64(i64 %a0, i64 %a1) {
39 ;CHECK-LABEL: stack_fold_pdep_u64
40 ;CHECK: pdepq {{-?[0-9]*}}(%rsp), %rax, %rax {{.*#+}} 8-byte Folded Reload
41 %1 = tail call i64 asm sideeffect "nop", "=x,~{rax},~{rbx},~{rcx},~{rdx},~{rsi},~{rdi},~{rbp},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15}"()
42 %2 = tail call i64 @llvm.x86.bmi.pdep.64(i64 %a0, i64 %a1)
45 declare i64 @llvm.x86.bmi.pdep.64(i64, i64)
47 define i32 @stack_fold_pext_u32(i32 %a0, i32 %a1) {
48 ;CHECK-LABEL: stack_fold_pext_u32
49 ;CHECK: pextl {{-?[0-9]*}}(%rsp), %eax, %eax {{.*#+}} 4-byte Folded Reload
50 %1 = tail call i32 asm sideeffect "nop", "=x,~{rax},~{rbx},~{rcx},~{rdx},~{rsi},~{rdi},~{rbp},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15}"()
51 %2 = tail call i32 @llvm.x86.bmi.pext.32(i32 %a0, i32 %a1)
54 declare i32 @llvm.x86.bmi.pext.32(i32, i32)
56 define i64 @stack_fold_pext_u64(i64 %a0, i64 %a1) {
57 ;CHECK-LABEL: stack_fold_pext_u64
58 ;CHECK: pextq {{-?[0-9]*}}(%rsp), %rax, %rax {{.*#+}} 8-byte Folded Reload
59 %1 = tail call i64 asm sideeffect "nop", "=x,~{rax},~{rbx},~{rcx},~{rdx},~{rsi},~{rdi},~{rbp},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15}"()
60 %2 = tail call i64 @llvm.x86.bmi.pext.64(i64 %a0, i64 %a1)
63 declare i64 @llvm.x86.bmi.pext.64(i64, i64)