[llvm-dev] LoopIdiomRecognize is not recognizing the ctpop idiom
Alex Susu via llvm-dev
llvm-dev at lists.llvm.org
Sat Jun 2 04:24:39 PDT 2018
Hello.
Could you please tell me why am I not able to recognize (with LLVM built from the SVN
code in Apr 25, 2018) the LLVM IR intrinsic ctpop (described at
https://llvm.org/docs/LangRef.html#llvm-ctpop-intrinsic) in the following program:
int PopCnt_Simple(int x) {
int numBits = 0;
int i;
//for (i = 0; i < 32; i++) {
for (i = 0; x != 0; i++) {
if (x & 1)
numBits++;
x >>= 1;
}
return numBits;
}
I also did check the following code, getting inspired from the discussion at
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20121119/156300.html:
int popcount_Yang_i32(int a) {
int c = 0;
while (a) {
c++;
//... // both a & c would be used multiple times in or out of
//loop
a &= a - 1;
//...
}
return c;
}
Is there any good paper discussing this type of loop idiom recognitions? I found only
a vaguely related paper: "Automatic Recognition of Performance Idioms in Scientific
Applications", IPDPS 2011 (http://www.sdsc.edu/~allans/ipdps11.pdf).
Thank you very much,
Alex
More information about the llvm-dev
mailing list