Thanks very much Eli, that is a good approach. I assumed that this is the
canonicalized form, but if not, I am sure I can add a simple pass to
canonicalize other probable patterns to ensure a match.
All the best,
MartinO
-----Original Message-----
From: Friedman, Eli [mailto:efriedma at codeaurora.org]
Sent: Thursday, January 18, 2018 7:02 PM
To: ORiordan, Martin <martin.oriordan at intel.com>; llvm-dev <llvm-dev
at lists.llvm.org>
Subject: Re: [llvm-dev] CTPOP and zeroes
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
--------------------------------------------------------------
Intel Research and Development Ireland Limited
Registered in Ireland
Registered Office: Collinstown Industrial Park, Leixlip, County Kildare
Registered Number: 308263
This e-mail and any attachments may contain confidential material for the sole
use of the intended recipient(s). Any review or distribution by others is
strictly prohibited. If you are not the intended recipient, please contact the
sender and delete all copies.