[VectorAPI] Expose direct move mask operation?

Paul Sandoz paul.sandoz at oracle.com
Tue Jan 31 16:34:01 UTC 2023


I suspect this kind of pattern can be optimized by C2, and might be different for architectures with and without mask registers.

Paul.

> On Jan 27, 2023, at 6:31 PM, Eric Liu <eric.c.liu at arm.com> wrote:
> 
> > With current API, it seems that if one want to get the lanes with highest bit set, one can use Vector::compare(LT, 0).
>  
> I assume the final goal is to gather the highest bits of each lane to an Integer value, while it’s going to be allocated to a general-purpose register on a certain hardware.
>  
> ```
> long imm = va.compare(LT, 0).toLong();
> ```
>  
>  
> > In the backend, this seems to be translated to something like vpcmpgtb followed by vpmovmskb. However, Gather the highest bit on x86 only need a movemask operation.
>  
> I’m not familiar with x86. I assume the input of vpmovmskb is a predicate register, while in your case the original input was a Vector object which should be allocated in vector register.
>  
>  
> - Eric
>  
> From: panama-dev <panama-dev-retn at openjdk.org> On Behalf Of Zhu, Yifan
> Sent: Saturday, January 7, 2023 8:01 AM
> To: panama-dev at openjdk.org
> Subject: [VectorAPI] Expose direct move mask operation?
>  
> Sorry if this was previously discussed. I am new to the list.
>  
> With current API, it seems that if one want to get the lanes with highest bit set, one can use Vector::compare(LT, 0). In the backend, this seems to be translated to something like vpcmpgtb followed by vpmovmskb. However, Gather the highest bit on x86 only need a movemask operation.
>  
> 	• I wonder if such operations can be optimized if the given constant is special (such as 0)
> 	• Or if we can finally have a gatherBits()​ operation. I know that movemask operations are not available on platforms like aarch64, but libraries like SIMDE has given some examples on how to emulate these operations on other platforms.
>  
> <image001.png>
> Schrodinger ZHU Yifan, Ph.D. Student
> Computer Science Department, University of Rochester
>  
> Personal Email: i at zhuyi.fan
> Work Email: yifanzhu at rochester.edu
> Website: https://www.cs.rochester.edu/~yzhu104/Main.html
> Github: SchrodingerZhu
> GPG Fingerprint: BA02CBEB8CB5D8181E9368304D2CC545A78DBCC3
>  
> <image003.png>



More information about the panama-dev mailing list