OSDN Git Service

[LoopIdiomRecognize] Support for converting loops that use LSHR to CTLZ.
authorCraig Topper <craig.topper@intel.com>
Sun, 8 Jul 2018 01:45:47 +0000 (01:45 +0000)
committerCraig Topper <craig.topper@intel.com>
Sun, 8 Jul 2018 01:45:47 +0000 (01:45 +0000)
commit7d6057ca556e0e82b3f646022b09ad620e3be874
treeafd33200c85cb57222b3984f1dd7740619c0eea4
parent5c9e6ab590d844ec45f70baedeca4f4f6c1afa7e
[LoopIdiomRecognize] Support for converting loops that use LSHR to CTLZ.

In the 'detectCTLZIdiom' function support for loops that use LSHR instruction instead of ASHR has been added.

This supports creating ctlz from the following code.

int lzcnt(int x) {
     int count = 0;
     while (x > 0)  {
          count++;
          x = x >> 1;
     }
    return count;
}

Patch by Olga Moldovanova

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336509 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/LoopIdiomRecognize.cpp
test/Transforms/LoopIdiom/X86/ctlz.ll