More AVX Advice Needed

I'm working on some of the AVX insert/extract instructions. They're
stupid. They do not operate on ymm registers, meaning we have to
use VINSERTF128/VEXTRACTF128 and then do the real operation.

Anyway, I'm looking at how INSERTPS and friends work and noticed that
there are special SelectionDAG nodes for them and corresponding TableGen
dag operators (X86insrtps, for example).

What's the reason for using special dag operators as opposed to intrinsics?

                            -Dave

INSERTPS isn't an intrinsic because there's a standard way to
represent the operation, and we try to avoid adding intrinsics when
possible.

-Eli

I don't get it. How is X86insrtps "standard?" It looks just like an
intrinsic to me.

                                    -Dave

X86insrtps is roughly equivalent to the LLVM IR instruction
insertelement, so there's no need for an IR intrinsic.
X86ISD::INSERTPS is an extra instruction for ISel; it's used inside
the custom lowering for INSERT_VECTOR_ELT and VECTOR_SHUFFLE.

-Eli

Yes, that's how I found out about it. :slight_smile:

Why not just use ISD::INSERT_VECTOR_ELT?

And what's the difference between vector_extract and extractelt in
TargetSelectionDAG.td? Ditto vector_insert vs. insertelt.

                               -Dave

insertelt/extractelt are pickier about types. They check that the element type is appropriate for the vector type. It is good to use the more restrictive type constraints, but there are cases where that doesn't work (e.g., due to widening for type legalization).