xref: /llvm-project/llvm/test/CodeGen/X86/partial-fold32.ll (revision 47eb85a0033fd21764fe100e736c3ec54d4f741f)
1; RUN: llc -mtriple=i686-unknown-linux-gnu -enable-misched=false < %s | FileCheck %s
2
3define fastcc i8 @fold32to8(i32 %add, i8 %spill) {
4; CHECK-LABEL: fold32to8:
5; CHECK:    movl %ecx, (%esp) # 4-byte Spill
6; CHECK:    subb (%esp), %dl  # 1-byte Folded Reload
7entry:
8  tail call void asm sideeffect "", "~{eax},~{ebx},~{ecx},~{edi},~{esi},~{ebp},~{dirflag},~{fpsr},~{flags}"()
9  %trunc = trunc i32 %add to i8
10  %sub = sub i8 %spill, %trunc
11  ret i8 %sub
12}
13
14; Do not fold a 1-byte store into a 4-byte spill slot
15define fastcc i8 @nofold(i32 %add, i8 %spill) {
16; CHECK-LABEL: nofold:
17; CHECK:    movl %edx, (%esp) # 4-byte Spill
18; CHECK:    movl (%esp), %eax # 4-byte Reload
19; CHECK:    subb %cl, %al
20entry:
21  tail call void asm sideeffect "", "~{eax},~{ebx},~{edx},~{edi},~{esi},~{ebp},~{dirflag},~{fpsr},~{flags}"()
22  %trunc = trunc i32 %add to i8
23  %sub = sub i8 %spill, %trunc
24  ret i8 %sub
25}
26