1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=x86_64-linux-gnu -run-pass=legalizer -verify-machineinstrs %s -o - | FileCheck %s --check-prefixes=CHECK,X64
3 # RUN: llc -mtriple=i686-linux-gnu -run-pass=legalizer -verify-machineinstrs %s -o - | FileCheck %s --check-prefixes=CHECK,X86
8 tracksRegLiveness: true
13 ; CHECK-LABEL: name: test_sdiv_i8
14 ; CHECK: liveins: $edi, $esi
16 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $edi
17 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[COPY]](s32)
18 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $esi
19 ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s8) = G_TRUNC [[COPY1]](s32)
20 ; CHECK-NEXT: [[SDIV:%[0-9]+]]:_(s8) = G_SDIV [[TRUNC]], [[TRUNC1]]
21 ; CHECK-NEXT: $al = COPY [[SDIV]](s8)
22 ; CHECK-NEXT: RET 0, implicit $al
24 %0:_(s8) = G_TRUNC %2(s32)
26 %1:_(s8) = G_TRUNC %3(s32)
27 %4:_(s8) = G_SDIV %0, %1
34 tracksRegLiveness: true
39 ; CHECK-LABEL: name: test_sdiv_i16
40 ; CHECK: liveins: $edi, $esi
42 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $edi
43 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[COPY]](s32)
44 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $esi
45 ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[COPY1]](s32)
46 ; CHECK-NEXT: [[SDIV:%[0-9]+]]:_(s16) = G_SDIV [[TRUNC]], [[TRUNC1]]
47 ; CHECK-NEXT: $ax = COPY [[SDIV]](s16)
48 ; CHECK-NEXT: RET 0, implicit $ax
50 %0:_(s16) = G_TRUNC %2(s32)
52 %1:_(s16) = G_TRUNC %3(s32)
53 %4:_(s16) = G_SDIV %0, %1
60 tracksRegLiveness: true
65 ; CHECK-LABEL: name: test_sdiv_i32
66 ; CHECK: liveins: $edi, $esi
68 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $edi
69 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $esi
70 ; CHECK-NEXT: [[SDIV:%[0-9]+]]:_(s32) = G_SDIV [[COPY]], [[COPY1]]
71 ; CHECK-NEXT: $eax = COPY [[SDIV]](s32)
72 ; CHECK-NEXT: RET 0, implicit $eax
75 %2:_(s32) = G_SDIV %0, %1
82 tracksRegLiveness: true
85 ; X64-LABEL: name: test_sdiv_i64
86 ; X64: [[DEF:%[0-9]+]]:_(s64) = IMPLICIT_DEF
87 ; X64-NEXT: [[DEF1:%[0-9]+]]:_(s64) = IMPLICIT_DEF
88 ; X64-NEXT: [[SDIV:%[0-9]+]]:_(s64) = G_SDIV [[DEF]], [[DEF1]]
89 ; X64-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY [[SDIV]](s64)
90 ; X64-NEXT: RET 0, implicit [[COPY]](s64)
92 ; X86-LABEL: name: test_sdiv_i64
93 ; X86: [[DEF:%[0-9]+]]:_(s64) = IMPLICIT_DEF
94 ; X86-NEXT: [[DEF1:%[0-9]+]]:_(s64) = IMPLICIT_DEF
95 ; X86-NEXT: ADJCALLSTACKDOWN32 16, 0, 0, implicit-def $esp, implicit-def $eflags, implicit-def $ssp, implicit $esp, implicit $ssp
96 ; X86-NEXT: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[DEF]](s64)
97 ; X86-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $esp
98 ; X86-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
99 ; X86-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[C]](s32)
100 ; X86-NEXT: G_STORE [[UV]](s32), [[PTR_ADD]](p0) :: (store (s32) into stack, align 1)
101 ; X86-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $esp
102 ; X86-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 4
103 ; X86-NEXT: [[PTR_ADD1:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY1]], [[C1]](s32)
104 ; X86-NEXT: G_STORE [[UV1]](s32), [[PTR_ADD1]](p0) :: (store (s32) into stack + 4, align 1)
105 ; X86-NEXT: [[UV2:%[0-9]+]]:_(s32), [[UV3:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[DEF1]](s64)
106 ; X86-NEXT: [[COPY2:%[0-9]+]]:_(p0) = COPY $esp
107 ; X86-NEXT: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 8
108 ; X86-NEXT: [[PTR_ADD2:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY2]], [[C2]](s32)
109 ; X86-NEXT: G_STORE [[UV2]](s32), [[PTR_ADD2]](p0) :: (store (s32) into stack + 8, align 1)
110 ; X86-NEXT: [[COPY3:%[0-9]+]]:_(p0) = COPY $esp
111 ; X86-NEXT: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 12
112 ; X86-NEXT: [[PTR_ADD3:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY3]], [[C3]](s32)
113 ; X86-NEXT: G_STORE [[UV3]](s32), [[PTR_ADD3]](p0) :: (store (s32) into stack + 12, align 1)
114 ; X86-NEXT: CALLpcrel32 &__divdi3, csr_32, implicit $esp, implicit $ssp, implicit-def $eax, implicit-def $edx
115 ; X86-NEXT: [[COPY4:%[0-9]+]]:_(s32) = COPY $eax
116 ; X86-NEXT: [[COPY5:%[0-9]+]]:_(s32) = COPY $edx
117 ; X86-NEXT: [[MV:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[COPY4]](s32), [[COPY5]](s32)
118 ; X86-NEXT: ADJCALLSTACKUP32 16, 0, implicit-def $esp, implicit-def $eflags, implicit-def $ssp, implicit $esp, implicit $ssp
119 ; X86-NEXT: [[COPY6:%[0-9]+]]:_(s64) = COPY [[MV]](s64)
120 ; X86-NEXT: RET 0, implicit [[COPY6]](s64)
121 %0:_(s64) = IMPLICIT_DEF
122 %1:_(s64) = IMPLICIT_DEF
123 %2:_(s64) = G_SDIV %0, %1
124 %3:_(s64) = COPY %2(s64)