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