[PATCH] D73215: [MIPS GlobalISel] Select count trailing 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.cttz.<type> intrinsic has additional i1 argument is_zero_undef,
it tells whether zero as the first argument produces a defined result.
G_CTTZ is generated from llvm.cttz.<type> (<type> <src>, i1 false)
intrinsics, clang generates these intrinsics from __builtin_ctz and
__builtin_ctzll.
G_CTTZ_ZERO_UNDEF comes from llvm.cttz.<type> (<type> <src>, i1 true).
Clang generates such intrinsics as parts of expansion of __builtin_ffs
and __builtin_ffsll. It is also traditionally part of and many 
algorithms that are now predicated on avoiding zero-value inputs.

Add narrow scalar (algorithm uses G_CTTZ_ZERO_UNDEF) for G_CTTZ.
Lower G_CTTZ and G_CTTZ_ZERO_UNDEF for MIPS32.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73215

Files:
  llvm/include/llvm/CodeGen/GlobalISel/LegalizerHelper.h
  llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
  llvm/lib/Target/Mips/MipsLegalizerInfo.cpp
  llvm/test/CodeGen/Mips/GlobalISel/legalizer/cttz.mir
  llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/cttz.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73215.239640.patch
Type: text/x-patch
Size: 15103 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200122/63a50450/attachment.bin>


More information about the llvm-commits mailing list