Hi Anton,<br><br>I don't think this will work cleanly using Pat<>. The custom lowering uses a bitcast, which gives me an unrecoverable error for using bitconvert in an output pattern, or a non-fatal (?) Type inference contradiction error.<br>
<br>Assuming there was some way around this, the unoptimized pattern for the v4i16 case looks something like:<br>def : Pat<(v4i16 (ctpop DPR:$Dm)),<br> (v4i16 (EXTRACT_SUBREG<br> (v8i16 (VMOVLuv8i16<br>
(v8i8 (VUZPd8<br> (v8i8 (IMPLICIT_DEF)),<br> (v8i8 (VADDv8i8<br> (v8i8 (VREV16d8<br> (v8i8 (VCNTd (v8i8 DPR:$Dm)))<br> )),<br>
(v8i8 (VCNTd (v8i8 DPR:$Dm)))<br> )),<br> (v8i8 (VADDv8i8<br> (v8i8 (VREV16d8<br> (v8i8 (VCNTd (v8i8 DPR:$Dm)))<br> )),<br>
(v8i8 (VCNTd (v8i8 DPR:$Dm)))<br> ))<br> ))<br> )), dsub_0<br> ))>;<br><br>This actually builds with the Type inference errors, and gives the right assembly.<br>
As is, I think this is more clearly expressed in the code.<br>So, unless there are ways to deal with these issues in tablegen that I haven't thought of, it needs to be lowered in the code.<br>Was fun to try though :). Any other comments?<br>
<br>Pete<br><br><br><div class="gmail_quote">On Fri, Nov 30, 2012 at 6:05 AM, Pete Couperus <span dir="ltr"><<a href="mailto:pjcoup@gmail.com" target="_blank">pjcoup@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Anton,<br><br>Thanks for taking a look. I had trouble with complex patterns for other similar items, but I'll take another look at this case if that actually sounds feasible.<br>Looking at LowerCTTZ, using Pat<> would be the same for cttz, although its lowering is much simpler, correct? Is there guidelines for when to use Pat<> and when to lay it out in the code?<br>
Thanks again for taking a look!<span class="HOEnZb"><font color="#888888"><br><br>Pete</font></span><div class="HOEnZb"><div class="h5"><br><br><br><br><div class="gmail_quote">On Thu, Nov 29, 2012 at 9:53 PM, Anton Korobeynikov <span dir="ltr"><<a href="mailto:anton@korobeynikov.info" target="_blank">anton@korobeynikov.info</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Pete,<br>
<div><div><br>
> The population count intrinsic (ctpop) is supported on ARM/NEON for v8i8 and<br>
> v16i8 types via NEON's vcnt instruction.<br>
> This patch leverages vcnt and other NEON instructions to custom lower ctpop<br>
> for v2i32/v4i32 and v4i16/v8i16 types.<br>
> As you'll see, a fair chunk of this patch is comments describing the<br>
> lowering, which I am happy to adjust to people's liking.<br>
> Please review!<br>
> Thanks!<br>
</div></div>Can't you use Pat<> magic in .td file to expand ctpop into series of<br>
nodes? It seems exactly what's your lowering does...<br>
<br>
--<br>
With best regards, Anton Korobeynikov<br>
Faculty of Mathematics and Mechanics, Saint Petersburg State University<br>
</blockquote></div><br>
</div></div></blockquote></div><br>