llvm-project/llvm/lib/Transforms
David Bolvansky 0c2692108c [InstCombine] Fold select with ctlz to cttz
Summary:
Handle pattern [0]:

int ctz(unsigned int a)
{
  int c = __clz(a & -a);
  return a ? 31 - c : c;
}

In reality, the compiler can generate much better code for cttz, so fold away this pattern.

https://godbolt.org/z/c5kPtV

 [0] https://community.arm.com/community-help/f/discussions/2114/count-trailing-zeros

Reviewers: spatel, nikic, lebedev.ri, dmgreen, hfinkel

Reviewed By: hfinkel

Subscribers: hfinkel, javed.absar, kristof.beyls, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D66308

llvm-svn: 370037
2019-08-27 10:22:40 +00:00
..
AggressiveInstCombine Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Coroutines [llvm] Migrate llvm::make_unique to std::make_unique 2019-08-15 15:54:37 +00:00
Hello Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
IPO [Attributor] Introduce an API to delete stuff 2019-08-27 04:57:54 +00:00
InstCombine [InstCombine] Fold select with ctlz to cttz 2019-08-27 10:22:40 +00:00
Instrumentation [hwasan] Fix test failure in r369721. 2019-08-26 21:44:55 +00:00
ObjCARC [ObjC][ARC] Delete ObjC runtime calls on global variables annotated 2019-06-14 22:06:32 +00:00
Scalar [LoopFusion] Fix -Wunused-function in -DLLVM_ENABLE_ASSERTIONS=off build 2019-08-24 02:50:42 +00:00
Utils [LoopUnroll] Handle certain PHIs in full unrolling properly 2019-08-26 09:29:53 +00:00
Vectorize Add a clarify comment for meaning of SafePointes [NFC] 2019-08-26 20:48:35 +00:00
CMakeLists.txt Another try to commit 323321 (aggressive instruction combine). 2018-01-25 12:06:32 +00:00
LLVMBuild.txt Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00