This is an archive of the discontinued LLVM Phabricator instance.

[X86][AVX512] Avoid bitcasts between scalar and vXi1 bool vectors
ClosedPublic

Authored by RKSimon on Jun 10 2020, 4:46 AM.

Details

Summary

AVX512 mask types are often bitcasted to scalar integers for various ops before being bitcast back to be used as a predicate. In many cases we can avoid these KMASK<->GPR transfers and perform equivalent operations on the mask unit.

If the destination mask type is legal, and we can confirm that the scalar op originally came from a mask/vector/float/double type then we should try to avoid the scalar entirely.

This avoids some codegen issues noticed while working on PTEST/MOVMSK improvements.

Partially fixes PR32547 - we don't create a KUNPCK yet, but OR(X,KSHIFTL(Y)) will be handled in a separate patch.

Diff Detail

Event Timeline

RKSimon created this revision.Jun 10 2020, 4:46 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 10 2020, 4:46 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
craig.topper added inline comments.Jun 10 2020, 10:10 AM
llvm/lib/Target/X86/X86ISelLowering.cpp
37953

Why does a SHL become KSHIFTR?

llvm/test/CodeGen/X86/vector-shuffle-v1.ll
893

Isn't k1 zero after this kshiftr? The two kshiftrs back to back add up to 16. So there are no bits left.

RKSimon marked an inline comment as done.Jun 10 2020, 2:13 PM
RKSimon added inline comments.
llvm/lib/Target/X86/X86ISelLowering.cpp
37953

It should be KSHIFTL, sorry about that

RKSimon updated this revision to Diff 269966.Jun 10 2020, 2:14 PM

Fix SHL->KSHIFTL conversion

craig.topper accepted this revision.Jun 10 2020, 2:36 PM

LGTM Fix the description to say KSHIFTL in "OR(X,KSHIFTR(Y)" if you're going to include that in the commit message.

This revision is now accepted and ready to land.Jun 10 2020, 2:36 PM
RKSimon edited the summary of this revision. (Show Details)Jun 11 2020, 2:07 AM
This revision was automatically updated to reflect the committed changes.