Skip to content

Commit

Permalink
[DPWBS-1361] Adding Instruction Selection support for G_CTLZ and the …
Browse files Browse the repository at this point in the history
…corresponding test case.
  • Loading branch information
Zoltan Toth authored and konstantinschwarz committed Mar 3, 2020
1 parent 6122714 commit 3f811d7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions llvm/lib/Target/TriCore/TriCoreGISelPattern.td
Expand Up @@ -113,6 +113,10 @@ def : SimpleBinOpPat<and, AND_ddd>;
def : SimpleBinOpPat<or, OR_ddd>;
def : SimpleBinOpPat<xor, XOR_ddd>;

// 2.1.9 Count Leading Zeros, Ones and Signs

def : Pat<(i32 (ctlz i32:$src)), (i32 (CLZ_dd DataRegs:$src))>;

// 2.1.10 Shift.

def : SimpleBinOpPat<shl, SH_ddd>;
Expand Down
23 changes: 23 additions & 0 deletions llvm/test/CodeGen/TriCore/GlobalIsel/select-ctlz.mir
@@ -0,0 +1,23 @@
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -O0 -mtriple=tricore -global-isel -run-pass=instruction-select \
# RUN: -verify-machineinstrs %s -o - | FileCheck %s

---
name: test_ctlz_s32
legalized: true
regBankSelected: true

registers:
- { id: 0, class: dataregbank }
- { id: 1, class: dataregbank }

body: |
bb.0:
; CHECK-LABEL: name: test_ctlz_s32
; CHECK: [[COPY:%[0-9]+]]:dataregs = COPY $d4
; CHECK: [[CLZ_dd:%[0-9]+]]:dataregs = CLZ_dd [[COPY]]
; CHECK: $d4 = COPY [[CLZ_dd]]
%0(s32) = COPY $d4
%1(s32) = G_CTLZ %0
$d4 = COPY %1(s32)
...

0 comments on commit 3f811d7

Please sign in to comment.