llvm-project/llvm/test/Transforms/LoopIdiom
Craig Topper 25067f179f [LoopIdiomRecognize] Teach detectShiftUntilZeroIdiom to recognize loops where the counter is decrementing.
This adds support for loops like

unsigned clz(unsigned x) {
    unsigned w = sizeof (x) * CHAR_BIT;
    while (x) {
        w--;
        x >>= 1;
    }

    return w;
}

and

unsigned clz(unsigned x) {
    unsigned w = sizeof (x) * CHAR_BIT - 1;
    while (x >>= 1) {
        w--;
    }

    return w;
}

To support these we look for add x, -1 as well as add x, 1 that
we already matched. If the value was -1 we need to subtract from
the initial counter value instead of adding to it.

Fixes PR48404.

Differential Revision: https://reviews.llvm.org/D92745
2020-12-14 14:25:05 -08:00
..
AMDGPU
ARM
X86 [LoopIdiomRecognize] Teach detectShiftUntilZeroIdiom to recognize loops where the counter is decrementing. 2020-12-14 14:25:05 -08:00
basic-address-space.ll
basic.ll [InferAttrs] Add nocapture/writeonly to string/mem libcalls 2020-10-29 20:06:43 +01:00
crash.ll
ctpop-multiple-users-crash.ll
dbginfo-cost.ll
debug-line.ll
disable-options.ll [LoopIdiomRecognizePass] Options to disable part or the entire Loop Idiom Recognize Pass 2020-09-01 13:59:24 +00:00
expander-do-not-delete-reused-values.ll [LoopIdiom,LSR] Add additional tests for SCEVExpander cleanups. 2020-08-21 13:48:31 +01:00
int_sideeffect.ll
lir-heurs-multi-block-loop.ll
memcpy-debugify-remarks.ll
memcpy-vectors.ll [SVE] In LoopIdiomRecognize::isLegalStore bail out for scalable vectors 2020-09-14 11:28:31 +01:00
memset-debugify-remarks.ll
memset_noidiom.ll
non-canonical-loop.ll
non-integral-pointers.ll Fix a bug in memset formation with vectors of non-integral pointers 2020-10-01 16:11:11 -07:00
nontemporal_store.ll
phi-insertion.ll [LoopIdiom] Add additional test cases. 2020-07-23 13:53:26 +01:00
pr28196.ll
pr33114.ll
reuse-cast.ll [SCEVExpander] Avoid re-using existing casts if it means updating users. 2020-08-09 13:25:17 +01:00
scev-invalidation.ll
scev-invalidation_topmostloop.ll
struct-custom-dl.ll
struct.ll
struct_pattern.ll
unordered-atomic-memcpy-noarch.ll
unroll-custom-dl.ll
unroll.ll
unsafe.ll
unwind.ll