Skip to content

Commit 54829ec

Browse files
committed
[ARM GlobalISel] Support G_CTLZ for Thumb2
Same as ARM mode but with different opcode. llvm-svn: 355191
1 parent ae5303d commit 54829ec

File tree

3 files changed

+34
-7
lines changed

3 files changed

+34
-7
lines changed

llvm/lib/Target/ARM/ARMLegalizerInfo.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,6 @@ ARMLegalizerInfo::ARMLegalizerInfo(const ARMSubtarget &ST) {
206206

207207
getActionDefinitionsBuilder({G_FREM, G_FPOW}).libcallFor({s32, s64});
208208

209-
if (ST.isThumb()) {
210-
// FIXME: merge with the code for non-Thumb.
211-
computeTables();
212-
verify(*ST.getInstrInfo());
213-
return;
214-
}
215-
216209
if (ST.hasV5TOps()) {
217210
getActionDefinitionsBuilder(G_CTLZ)
218211
.legalFor({s32, s32})

llvm/test/CodeGen/ARM/GlobalISel/arm-legalize-bitcounts.mir

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# RUN: llc -O0 -mtriple arm-linux-gnueabi -mattr=+v5t -run-pass=legalizer %s -o - | FileCheck %s -check-prefixes=CHECK,CLZ
2+
# RUN: llc -O0 -mtriple thumb-linux-gnueabi -mattr=+v6t2 -run-pass=legalizer %s -o - | FileCheck %s -check-prefixes=CHECK,CLZ
23
# RUN: llc -O0 -mtriple arm-linux-gnueabi -mattr=-v5t -run-pass=legalizer %s -o - | FileCheck %s -check-prefixes=CHECK,LIBCALLS
34
--- |
45
define void @test_ctlz_s32() { ret void }
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# RUN: llc -O0 -mtriple arm-- -mattr=+v6 -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s --check-prefixes=CHECK,ARM
2+
# RUN: llc -O0 -mtriple thumb-- -mattr=+v6t2 -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s --check-prefixes=CHECK,THUMB
3+
--- |
4+
define void @test_clz() { ret void }
5+
...
6+
---
7+
name: test_clz
8+
# CHECK-LABEL: name: test_clz
9+
legalized: true
10+
regBankSelected: true
11+
selected: false
12+
# CHECK: selected: true
13+
registers:
14+
- { id: 0, class: gprb }
15+
- { id: 1, class: gprb }
16+
body: |
17+
bb.0:
18+
liveins: $r0
19+
20+
%0(s32) = COPY $r0
21+
; ARM: [[VREGX:%[0-9]+]]:gpr = COPY $r0
22+
; THUMB: [[VREGX:%[0-9]+]]:rgpr = COPY $r0
23+
24+
%1(s32) = G_CTLZ %0(s32)
25+
; ARM: [[VREGR:%[0-9]+]]:gpr = CLZ [[VREGX]], 14, $noreg
26+
; THUMB: [[VREGR:%[0-9]+]]:rgpr = t2CLZ [[VREGX]], 14, $noreg
27+
28+
$r0 = COPY %1(s32)
29+
; CHECK: $r0 = COPY [[VREGR]]
30+
31+
BX_RET 14, $noreg, implicit $r0
32+
; CHECK: BX_RET 14, $noreg, implicit $r0
33+
...

0 commit comments

Comments
 (0)