[vectorIntrinsics] RFR: 8283709: Add x86 back-end implementation for bit BIT_COUNT operation [v6]

Xiaohong Gong xgong at openjdk.java.net
Wed Apr 6 01:15:02 UTC 2022


On Sun, 3 Apr 2022 12:49:23 GMT, Jatin Bhateja <jbhateja at openjdk.org> wrote:

>> OK, thanks!
>
>> > Yeah, so if the `ConvL2I` is supported to be auto-vectorized after then, the `PopCountL` is better to be auto-vectorized to "PopCountVL + VectorCastL2X" ? Do you have any plan on it? Thanks so much!
>> 
>> Agree to your proposal, once we have auto-vectorization for ConvL2I n place we can change the IR.
> 
> Here is an interim patch which type casts the result of PopCountVL into integer vector and thus prevent any special 
> handling in target specific backend implementations. But it seems more appropriate to generate correct IR snippet (PopCountL + ConvL2I) during scalar operation inline expansion and explicitly handle ConvL2I during auto-vectorization.  
> 
> 
> diff --git a/src/hotspot/share/opto/superword.cpp b/src/hotspot/share/opto/superword.cpp
> index 1bf4c7a3282..b3dd90d1867 100644
> --- a/src/hotspot/share/opto/superword.cpp
> +++ b/src/hotspot/share/opto/superword.cpp
> @@ -2549,11 +2549,21 @@ void SuperWord::output() {
>            vn = VectorNode::make(opc, in1, in2, vlen, velt_basic_type(n));
>            vlen_in_bytes = vn->as_Vector()->length_in_bytes();
>          }
> +      } else if (opc == Op_PopCountL) {
> +        // TODO: Succeed PopCountL by ConvL2I during initial graph construction 
> +        // once auto-vectorizer supports ConvL2I operation.
> +        assert(n->req() == 2, "only one input expected");
> +        Node* in = vector_opd(p, 1);
> +  	   BasicType bt = in->bottom_type()->is_vect()->element_basic_type();
> +         in = VectorNode::make(opc, in, NULL, vlen, bt);
> +         _igvn.register_new_node_with_optimizer(in);
> +	   vn = VectorCastNode::make(Op_VectorCastL2X, in, T_INT, vlen);
> +         vlen_in_bytes = vn->as_Vector()->length_in_bytes();
>        } else if (opc == Op_SqrtF || opc == Op_SqrtD ||
>                   opc == Op_AbsF || opc == Op_AbsD ||
>                   opc == Op_AbsI || opc == Op_AbsL ||
>                   opc == Op_NegF || opc == Op_NegD ||
> -                 opc == Op_PopCountI || opc == Op_PopCountL) {
> +                opc == Op_PopCountI) {
>          assert(n->req() == 2, "only one input expected");
>          Node* in = vector_opd(p, 1);
>          vn = VectorNode::make(opc, in, NULL, vlen, velt_basic_type(n));

Yeah, thanks for it. I will do it once PR https://github.com/openjdk/jdk/pull/7806 is merged. Thanks!

-------------

PR: https://git.openjdk.java.net/panama-vector/pull/185


More information about the panama-dev mailing list