1 # RUN: llc -mtriple arm-- -run-pass=legalizer %s -o - | FileCheck %s
2 # RUN: llc -mtriple thumb-- -mattr=+v6t2 -run-pass=legalizer %s -o - | FileCheck %s
4 define void @test_zext_s16_to_s32() { ret void }
5 define void @test_sext_s8_to_s32() { ret void }
6 define void @test_anyext_s1_to_s32() { ret void }
8 define void @test_zext_s8_to_s16() { ret void }
9 define void @test_sext_s1_to_s16() { ret void }
11 define void @test_anyext_s1_to_s8() { ret void }
13 define void @test_ext_combine() { ret void }
16 name: test_zext_s16_to_s32
17 # CHECK-LABEL: name: test_zext_s16_to_s32
19 # CHECK: legalized: true
20 regBankSelected: false
22 tracksRegLiveness: true
32 %1(s16) = G_LOAD %0 :: (load 2)
34 ; G_ZEXT with s16 is legal, so we should find it unchanged in the output
35 ; CHECK: {{%[0-9]+}}:_(s32) = G_ZEXT {{%[0-9]+}}
37 BX_RET 14, $noreg, implicit $r0
40 name: test_sext_s8_to_s32
41 # CHECK-LABEL: name: test_sext_s8_to_s32
43 # CHECK: legalized: true
44 regBankSelected: false
46 tracksRegLiveness: true
56 %1(s8) = G_LOAD %0(p0) :: (load 1)
58 ; G_SEXT with s8 is legal, so we should find it unchanged in the output
59 ; CHECK: {{%[0-9]+}}:_(s32) = G_SEXT {{%[0-9]+}}
61 BX_RET 14, $noreg, implicit $r0
64 name: test_anyext_s1_to_s32
65 # CHECK-LABEL: name: test_anyext_s1_to_s32
67 # CHECK: legalized: true
68 regBankSelected: false
70 tracksRegLiveness: true
80 %1(s1) = G_LOAD %0(p0) :: (load 1)
82 ; G_ANYEXT with s1 is legal, so we should find it unchanged in the output
83 ; CHECK: {{%[0-9]+}}:_(s32) = G_ANYEXT {{%[0-9]+}}
85 BX_RET 14, $noreg, implicit $r0
88 name: test_zext_s8_to_s16
89 # CHECK-LABEL: name: test_zext_s8_to_s16
91 # CHECK: legalized: true
92 regBankSelected: false
94 tracksRegLiveness: true
104 %1(s8) = G_LOAD %0(p0) :: (load 1)
106 ; G_ZEXT from s8 to s16 is legal, so we should find it unchanged in the output
107 ; CHECK: {{%[0-9]+}}:_(s16) = G_ZEXT {{%[0-9]+}}(s8)
108 G_STORE %2(s16), %0(p0) :: (store 2)
112 name: test_sext_s1_to_s16
113 # CHECK-LABEL: name: test_sext_s1_to_s16
115 # CHECK: legalized: true
116 regBankSelected: false
118 tracksRegLiveness: true
120 - { id: 0, class: _ }
121 - { id: 1, class: _ }
122 - { id: 2, class: _ }
128 %1(s1) = G_LOAD %0(p0) :: (load 1)
129 %2(s16) = G_SEXT %1(s1)
130 ; G_SEXT from s1 to s16 is legal, so we should find it unchanged in the output
131 ; CHECK: {{%[0-9]+}}:_(s16) = G_SEXT {{%[0-9]+}}(s1)
132 G_STORE %2(s16), %0(p0) :: (store 2)
136 name: test_anyext_s1_to_s8
137 # CHECK-LABEL: name: test_anyext_s1_to_s8
139 # CHECK: legalized: true
140 regBankSelected: false
142 tracksRegLiveness: true
144 - { id: 0, class: _ }
145 - { id: 1, class: _ }
146 - { id: 2, class: _ }
152 %1(s1) = G_LOAD %0(p0) :: (load 1)
154 ; G_ANYEXT from s1 to s8 is legal, so we should find it unchanged in the output
155 ; CHECK: {{%[0-9]+}}:_(s8) = G_ANYEXT {{%[0-9]+}}(s1)
156 G_STORE %2(s8), %0(p0) :: (store 1)
160 name: test_ext_combine
161 # CHECK-LABEL: name: test_ext_combine
163 # CHECK: legalized: true
164 regBankSelected: false
166 tracksRegLiveness: true
168 - { id: 0, class: _ }
169 - { id: 1, class: _ }
170 - { id: 2, class: _ }
171 - { id: 3, class: _ }
172 - { id: 4, class: _ }
173 - { id: 5, class: _ }
179 %1(s8) = G_LOAD %0(p0) :: (load 1)
180 ; CHECK: [[V8:%[0-9]+]]:_(s8) = G_LOAD
185 %4(s16) = G_OR %2, %3
186 ; G_OR is going to widen to 32 bits and the extensions/truncs should combine
187 ; with the already existing ones
188 ; CHECK: [[ZEXT:%[0-9]+]]:_(s32) = G_ZEXT [[V8]](s8)
189 ; CHECK: [[SEXT:%[0-9]+]]:_(s32) = G_SEXT [[V8]](s8)
190 ; CHECK: [[OR:%[0-9]+]]:_(s32) = G_OR [[ZEXT]], [[SEXT]]
191 ; CHECK: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 16
192 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY [[OR]]
193 ; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY]], [[BITS]](s32)
194 ; CHECK: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[BITS]](s32)
195 ; CHECK: $r0 = COPY [[ASHR]]
197 %5(s32) = G_SEXT %4(s16)
200 BX_RET 14, $noreg, implicit $r0