This is an archive of the discontinued LLVM Phabricator instance.

[X86][SSE] Attempt to break register dependencies during lowerBuildVector
ClosedPublic

Authored by RKSimon on Feb 8 2017, 10:15 AM.

Details

Summary

LowerBuildVectorv16i8/LowerBuildVectorv8i16 insert values into a UNDEF vector if the build vector doesn't contain any zero elements, resulting in register dependencies with a previous use of the register.

This patch attempts to break the register dependency by either always zeroing the vector before hand or (if we're inserting to the 0'th element) by using VZEXT_MOVL(SCALAR_TO_VECTOR(i32 AEXT(Elt))) which lowers to (V)MOVD and performs a similar function. Additionally (V)MOVD is a shorter instruction than PINSRB/PINSRW. We already do something similar for SSE41 PINSRD.

On pre-SSE41 LowerBuildVectorv16i8 we go a little further and use VZEXT_MOVL(SCALAR_TO_VECTOR(i32 ZEXT(Elt))) if the build vector contains zeros to avoid the vector zeroing at the cost of a scalar zero extension, which can probably be brought over to the other cases in a future patch in some cases (load folding etc.)

Diff Detail

Repository
rL LLVM

Event Timeline

RKSimon created this revision.Feb 8 2017, 10:15 AM
This revision is now accepted and ready to land.Feb 8 2017, 11:41 PM
This revision was automatically updated to reflect the committed changes.