<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I don't think use Pat<> buys anything here. The C++ lowering code is actually much more readable.<div><br></div><div>The patch looks fine to me. Please add ScalarTargetTransformInfo::PopcntHwSupport() to take advantage of the popcount loop idiom recognition support (See r168931). ARM crafty score should improve!</div><div><br></div><div>Evan</div><div><br><div><div><div>On Nov 30, 2012, at 11:37 PM, Pete Couperus <<a href="mailto:pjcoup@gmail.com">pjcoup@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">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><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>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>
_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits<br></blockquote></div><br></div></div></body></html>