https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128432

--- Comment #2 from Michael Meissner <meissner at gcc dot gnu.org> ---
I've tried  using trunc and there are complications.

Normal vectors on the PowerPC are 128-bits, so we have V4SFmode, V8BFmode, and
V8HFmode.  On power9 we only have

The target hook TARGET_VECTORIZE_PREFERRED_SIMD_MODE returns V4SFmode for
SFmode, V8BFmode for BFmode (__bf16), and V8HFmode for HFmode (_Float16).

I added insn patterns for truncv8sfv8hf2 and truncv8sfv8bf2.  But these insns
don't match because the preferred simd mode is V4SFmode and it doesn't generate
V8SFmode insns.

For the past few days, I have added insns to support V8SFmode and V4DFmode.  On
the power10, I can use the vector pair load and vector pair store instructions.
 On power9, I break the loads and stores into 2 vector loads and 2 vector
stores.  In both cases, there are some restrictions on the address modes.

I have added define_insns_and_splits for most of the V8SFmode or V4DFmode
operations (at the moment, I'm not doing square root, reciprocal square
root/division via estimation insns and using Taylor's series).

I then added code in preferred simd to return V8SFmode or V4DFmode under an
option.  I also added options to control whether we use the paired memory
operation or to split the memory operation into 2 loads and 2 stores.

It does use vector pair when optimizing float and double.  However, it appears
using vector pair load/stores or even splitting the memory ops into separate
loads/stores, that the code generating V8SFmode or V4DFmode and splitting them
into V4SFmode or V2DFmode ops is slower than just using the normal 128 bit
vector operations.  I even tried playing around with unroll options, and the
normal vector operation with unroll 4 is still faster than vector pairs using
unroll 2, which surprised me.  There are some extra ops that seem to be
generated that I need to look into. 

But unless I use -Ofast instead of -O3, I don't see any vectorization of
_Float16 (i.e. HFmode, and not the mode used in vec_pack_trunc_v4sf).

Even if I use -Ofast, it will do some vectorization of HFmode.  However, it
does the same vectorization even if the vector pair stuff is not enabled.

I haven't tried going the other way, i.e. adding truncv4sfv4bf2 and
truncv4sfv4hbf2 and adding moves for V4HFmode and V4BFmode (i.e. 64-bit
variants).

Reply via email to