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; }