[PATCH] D45173: [InstCombine] Recognize idioms for ctpop and ctlz
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 2 12:21:22 PDT 2018
efriedma added a comment.
Does this trigger on the compiler-rt implementation of __popcountsi2/__clzsi2? I guess it technically isn't a problem if it does, given the LLVM backend currently doesn't generate calls to them, but it might be worth adding a backend testcase to make sure we don't generate an infinite loop.
================
Comment at: lib/Transforms/AggressiveInstCombine/BitCountCombine.cpp:156
+ if (!match(&In, m_Sub(m_ConstantInt(BW), m_Intrinsic<Intrinsic::ctpop>())))
+ return nullptr;
+ // Get the argument of the ctpop.
----------------
You might want to match patterns which don't include the subtraction; it could easily get combined away before you get here (if someone computes "ctlz(n)-1", or "cltz(x)-ctlz(y)", etc.).
Repository:
rL LLVM
https://reviews.llvm.org/D45173
More information about the llvm-commits
mailing list