1 # RUN: llc -mtriple thumbv8m.base-none-eabi -run-pass=peephole-opt -verify-machineinstrs -o - %s | FileCheck %s
3 target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
4 target triple = "thumbv8m.base-none-none-eabi"
6 define i32 @test_subrr(i32 %a, i32 %b) { ret i32 %a }
7 define i32 @test_subrr_c(i32 %a, i32 %b) { ret i32 %a }
8 define i32 @test_subri3(i32 %a) { ret i32 %a }
9 define i32 @test_subri8(i32 %a) { ret i32 %a }
10 define i32 @test_addrr(i32 %a) { ret i32 %a }
11 define i32 @test_addri3(i32 %a) { ret i32 %a }
12 define i32 @test_addri8(i32 %a) { ret i32 %a }
18 - { reg: '$r0', virtual-reg: '%1' }
19 - { reg: '$r1', virtual-reg: '%2' }
22 successors: %bb.2(0x40000000), %bb.1(0x40000000)
27 %0:tgpr, $cpsr = tSUBrr %2, %1, 14, $noreg
28 tCMPr %1, %2, 14, $noreg, implicit-def $cpsr
34 tBX_RET 14, $noreg, implicit $r0
37 %3:tgpr, dead $cpsr = tMOVi8 0, 14, $noreg
39 tBX_RET 14, $noreg, implicit $r0
41 # CHECK-LABEL: name: test_subrr
42 # CHECK: [[COPY1:%[0-9]+]]:tgpr = COPY $r1
43 # CHECK-NEXT: [[COPY0:%[0-9]+]]:tgpr = COPY $r0
44 # CHECK-NEXT: [[ADD:%[0-9]+]]:tgpr, $cpsr = tSUBrr [[COPY1]], [[COPY0]], 14, $noreg
45 # CHECK-NEXT: tBcc %bb.2, 8, $cpsr
50 - { reg: '$r0', virtual-reg: '%1' }
51 - { reg: '$r1', virtual-reg: '%2' }
54 successors: %bb.2(0x40000000), %bb.1(0x40000000)
59 %0:tgpr, $cpsr = tSUBrr %1, %2, 14, $noreg
60 tCMPr %1, %2, 14, $noreg, implicit-def $cpsr
66 tBX_RET 14, $noreg, implicit $r0
69 %3:tgpr, dead $cpsr = tMOVi8 0, 14, $noreg
71 tBX_RET 14, $noreg, implicit $r0
73 # CHECK-LABEL: name: test_subrr_c
74 # CHECK: [[COPY1:%[0-9]+]]:tgpr = COPY $r1
75 # CHECK-NEXT: [[COPY0:%[0-9]+]]:tgpr = COPY $r0
76 # CHECK-NEXT: [[ADD:%[0-9]+]]:tgpr, $cpsr = tSUBrr [[COPY0]], [[COPY1]], 14, $noreg
77 # CHECK-NEXT: tBcc %bb.2, 3, $cpsr
82 - { reg: '$r0', virtual-reg: '%1' }
85 successors: %bb.2(0x40000000), %bb.1(0x40000000)
89 %0:tgpr, $cpsr = tSUBi3 %1, 1, 14, $noreg
90 tCMPi8 %1, 1, 14, $noreg, implicit-def $cpsr
96 tBX_RET 14, $noreg, implicit $r0
99 %2:tgpr, dead $cpsr = tMOVi8 0, 14, $noreg
101 tBX_RET 14, $noreg, implicit $r0
103 # CHECK-LABEL: name: test_subri3
104 # CHECK: [[COPY:%[0-9]+]]:tgpr = COPY $r0
105 # CHECK-NEXT: [[ADD:%[0-9]+]]:tgpr, $cpsr = tSUBi3 [[COPY]], 1, 14, $noreg
106 # CHECK-NEXT: tBcc %bb.2, 3, $cpsr
111 - { reg: '$r0', virtual-reg: '%1' }
114 successors: %bb.2(0x40000000), %bb.1(0x40000000)
118 %0:tgpr, $cpsr = tSUBi8 %1, 1, 14, $noreg
119 tCMPi8 %1, 1, 14, $noreg, implicit-def $cpsr
125 tBX_RET 14, $noreg, implicit $r0
128 %2:tgpr, dead $cpsr = tMOVi8 0, 14, $noreg
130 tBX_RET 14, $noreg, implicit $r0
132 # CHECK-LABEL: name: test_subri8
133 # CHECK: [[COPY:%[0-9]+]]:tgpr = COPY $r0
134 # CHECK-NEXT: [[ADD:%[0-9]+]]:tgpr, $cpsr = tSUBi8 [[COPY]], 1, 14, $noreg
135 # CHECK-NEXT: tBcc %bb.2, 3, $cpsr
140 - { reg: '$r0', virtual-reg: '%1' }
141 - { reg: '$r1', virtual-reg: '%2' }
144 successors: %bb.2(0x40000000), %bb.1(0x40000000)
149 %0:tgpr, $cpsr = tADDrr %2, %1, 14, $noreg
150 tCMPr %0, %2, 14, $noreg, implicit-def $cpsr
156 tBX_RET 14, $noreg, implicit $r0
159 %3:tgpr, dead $cpsr = tMOVi8 0, 14, $noreg
161 tBX_RET 14, $noreg, implicit $r0
163 # CHECK-LABEL: name: test_addrr
164 # CHECK: [[COPY1:%[0-9]+]]:tgpr = COPY $r1
165 # CHECK-NEXT: [[COPY0:%[0-9]+]]:tgpr = COPY $r0
166 # CHECK-NEXT: [[ADD:%[0-9]+]]:tgpr, $cpsr = tADDrr [[COPY1]], [[COPY0]], 14, $noreg
167 # CHECK-NEXT: tBcc %bb.2, 2, $cpsr
172 - { reg: '$r0', virtual-reg: '%1' }
175 successors: %bb.2(0x40000000), %bb.1(0x40000000)
179 %1:tgpr, $cpsr = tADDi3 %0, 1, 14, $noreg
180 tCMPr %1, %0, 14, $noreg, implicit-def $cpsr
186 tBX_RET 14, $noreg, implicit $r0
189 %2:tgpr, dead $cpsr = tMOVi8 0, 14, $noreg
191 tBX_RET 14, $noreg, implicit $r0
193 # CHECK-LABEL: name: test_addri3
194 # CHECK: [[COPY:%[0-9]+]]:tgpr = COPY $r0
195 # CHECK-NEXT: [[ADD:%[0-9]+]]:tgpr, $cpsr = tADDi3 [[COPY]], 1, 14, $noreg
196 # CHECK-NEXT: tBcc %bb.2, 2, $cpsr
201 - { reg: '$r0', virtual-reg: '%1' }
204 successors: %bb.2(0x40000000), %bb.1(0x40000000)
208 %1:tgpr, $cpsr = tADDi8 %0, 10, 14, $noreg
209 tCMPr %1, %0, 14, $noreg, implicit-def $cpsr
215 tBX_RET 14, $noreg, implicit $r0
218 %2:tgpr, dead $cpsr = tMOVi8 0, 14, $noreg
220 tBX_RET 14, $noreg, implicit $r0
222 # CHECK-LABEL: name: test_addri8
223 # CHECK: [[COPY:%[0-9]+]]:tgpr = COPY $r0
224 # CHECK-NEXT: [[ADD:%[0-9]+]]:tgpr, $cpsr = tADDi8 [[COPY]], 10, 14, $noreg
225 # CHECK-NEXT: tBcc %bb.2, 2, $cpsr