[llvm-dev] CTPOP and zeroes

Friedman, Eli via llvm-dev llvm-dev at lists.llvm.org
Thu Jan 18 11:01:57 PST 2018


On 1/18/2018 12:57 AM, ORiordan, Martin via llvm-dev wrote:
> Quick question.  The 'ISD::CTPOP' node allows a target to lower the counting of ones in a word to a single instruction.  Our target also has an instruction for counting the zeroes in a word.  Does CTPOP support counting of zeroes as well as ones instead of doing either "CTPOP(INVERT(operand))" or "N-bits - CTPOP(operand)"?

There is no target-independent ISD opcode for the operation you're 
describing (as far as I know, no in-tree target has an instruction like 
that).  I would suggest handling this using pattern-matching in your 
backend, e.g. "def : Pat<(i32 (ctpop (not i32:$a))), (INVCTPOP R:$a)>;".

-Eli

-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project



More information about the llvm-dev mailing list