• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -mtriple=x86_64-unknown-linux-gnu -enable-misched=false < %s | FileCheck %s
2
3define i32 @fold64to32(i64 %add, i32 %spill) {
4; CHECK-LABEL: fold64to32:
5; CHECK:    movq %rdi, -{{[0-9]+}}(%rsp) # 8-byte Spill
6; CHECK:    subl -{{[0-9]+}}(%rsp), %esi # 4-byte Folded Reload
7entry:
8  tail call void asm sideeffect "", "~{rax},~{rbx},~{rcx},~{rdx},~{rdi},~{rbp},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15},~{dirflag},~{fpsr},~{flags}"()
9  %trunc = trunc i64 %add to i32
10  %sub = sub i32 %spill, %trunc
11  ret i32 %sub
12}
13
14define i8 @fold64to8(i64 %add, i8 %spill) {
15; CHECK-LABEL: fold64to8:
16; CHECK:    movq %rdi, -{{[0-9]+}}(%rsp) # 8-byte Spill
17; CHECK:    subb -{{[0-9]+}}(%rsp), %sil # 1-byte Folded Reload
18entry:
19  tail call void asm sideeffect "", "~{rax},~{rbx},~{rcx},~{rdx},~{rdi},~{rbp},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15},~{dirflag},~{fpsr},~{flags}"()
20  %trunc = trunc i64 %add to i8
21  %sub = sub i8 %spill, %trunc
22  ret i8 %sub
23}
24
25; Do not fold a 4-byte store into a 8-byte spill slot
26; CHECK-LABEL: nofold
27; CHECK:    movq %rsi, -{{[0-9]+}}(%rsp) # 8-byte Spill
28; CHECK:    movq -{{[0-9]+}}(%rsp), %rax # 8-byte Reload
29; CHECK:    subl %edi, %eax
30; CHECK:    movq %rax, -{{[0-9]+}}(%rsp) # 8-byte Spill
31; CHECK:    movq -{{[0-9]+}}(%rsp), %rax # 8-byte Reload
32define i32 @nofold(i64 %add, i64 %spill) {
33entry:
34  tail call void asm sideeffect "", "~{rax},~{rbx},~{rcx},~{rdx},~{rsi},~{rbp},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15},~{dirflag},~{fpsr},~{flags}"()
35  %trunc = trunc i64 %add to i32
36  %truncspill = trunc i64 %spill to i32
37  %sub = sub i32 %truncspill, %trunc
38  tail call void asm sideeffect "", "~{rax},~{rbx},~{rcx},~{rdx},~{rsi},~{rdi},~{rbp},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15},~{dirflag},~{fpsr},~{flags}"()
39  ret i32 %sub
40}
41
42