[PATCH] D73214: [MIPS GlobalISel] Select count leading zeros

Petar Avramovic via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 22 10:14:38 PST 2020


Petar.Avramovic created this revision.
Petar.Avramovic added reviewers: atanasyan, petarj.
Herald added subscribers: llvm-commits, volkan, jrtc27, hiraditya, arichardson, rovka, sdardis.
Herald added a project: LLVM.

llvm.ctlz.<type> intrinsic has additional i1 argument is_zero_undef,
it tells whether zero as the first argument produces a defined result.
MIPS clz instruction returns 32 for zero input. 
G_CTLZ is generated from llvm.ctlz.<type> (<type> <src>, i1 false)
intrinsics, clang generates these intrinsics from __builtin_clz and
__builtin_clzll.
G_CTLZ_ZERO_UNDEF can also be generated from llvm.ctlz with true as
second argument. It is also traditionally part of and many algorithms
that are now predicated on avoiding zero-value inputs.

Add narrow scalar for G_CTLZ (algorithm uses G_CTLZ_ZERO_UNDEF).
Lower G_CTLZ_ZERO_UNDEF and select G_CTLZ for MIPS32.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73214

Files:
  llvm/include/llvm/CodeGen/GlobalISel/LegalizerHelper.h
  llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
  llvm/lib/Target/Mips/MipsLegalizerInfo.cpp
  llvm/lib/Target/Mips/MipsRegisterBankInfo.cpp
  llvm/test/CodeGen/Mips/GlobalISel/instruction-select/ctlz.mir
  llvm/test/CodeGen/Mips/GlobalISel/legalizer/ctlz.mir
  llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/ctlz.ll
  llvm/test/CodeGen/Mips/GlobalISel/regbankselect/ctlz.mir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73214.239639.patch
Type: text/x-patch
Size: 9207 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200122/245c5693/attachment.bin>


More information about the llvm-commits mailing list