[PATCH] D48354: [LoopIdiomRecognize] Support for loops that use LSHR instruction added.
Olga Moldovanova via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 20 02:57:00 PDT 2018
ovmold created this revision.
ovmold added a reviewer: craig.topper.
ovmold added a project: clang.
Herald added a subscriber: cfe-commits.
In the 'detectCTLZIdiom' function support for loops that use LSHR instruction instead of ASHR has been added.
The problem is that for the following piece of code no '@llvm.ctlz' instruction has been generated in the resulting test.ll file when compiling as "clang -S -O3 -march=core-avx2 -emit-llvm test.c". The reason for this is that the LSHR instruction is used instead of ASHR in the LLVM IR when we get into the 'detectCTLZIdiom' function.
int lzcnt(int x) {
int count = 0;
while (x > 0) {
count++;
x = x >> 1;
}
return count;
}
int main() {
int x;
scanf("%d", &x);
int y = lzcnt(x);
printf("count = %d\n", y);
return 0;
}
=
Repository:
rC Clang
https://reviews.llvm.org/D48354
Files:
lib/Transforms/Scalar/LoopIdiomRecognize.cpp
test/Transforms/LoopIdiom/X86/ctlz.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48354.152039.patch
Type: text/x-patch
Size: 9032 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180620/fdc9312b/attachment.bin>
More information about the cfe-commits
mailing list