diff options
author | Craig Topper <craig.topper@sifive.com> | 2020-12-14 13:51:00 -0800 |
---|---|---|
committer | Craig Topper <craig.topper@sifive.com> | 2020-12-14 14:25:05 -0800 |
commit | 25067f179f33ba1b764ac7a7d83385c8fd73801f (patch) | |
tree | a7c633b1cc9309c124fb7cc6fbe10032c7bcbb5f /clang/lib/Lex/ModuleMap.cpp | |
parent | b3ee7f1f312dd41a0ac883d78b71c14d96e78939 (diff) | |
download | llvm-25067f179f33ba1b764ac7a7d83385c8fd73801f.zip llvm-25067f179f33ba1b764ac7a7d83385c8fd73801f.tar.gz llvm-25067f179f33ba1b764ac7a7d83385c8fd73801f.tar.bz2 |
[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
Diffstat (limited to 'clang/lib/Lex/ModuleMap.cpp')
0 files changed, 0 insertions, 0 deletions