This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Added vector demanded bits support for SSE4A EXTRQ/INSERTQ instructions
ClosedPublic

Authored by RKSimon on Sep 7 2015, 3:30 PM.

Details

Summary

The SSE4A instructions EXTRQ/INSERTQ only use the lower 64-bits (or less) for many of their input vector operands and all of them have undefined upper 64-bits results.

Diff Detail

Repository
rL LLVM

Event Timeline

RKSimon updated this revision to Diff 34170.Sep 7 2015, 3:30 PM
RKSimon retitled this revision from to [InstCombine] Added vector demanded bits support for SSE4A EXTRQ/INSERTQ instructions.
RKSimon updated this object.
RKSimon added reviewers: andreadb, spatel.
RKSimon set the repository for this revision to rL LLVM.
RKSimon added a subscriber: llvm-commits.
spatel added inline comments.Sep 14 2015, 3:33 PM
lib/Transforms/InstCombine/InstCombineCalls.cpp
934–935 ↗(On Diff #34170)

Use 'auto *' for pointers? Same comment for the other autos below.

972–986 ↗(On Diff #34170)

Isn't this identical to the extrqi case? If yes, combine cases and eliminate the duplicated code. Could also just add a 3-4 line helper function that can be used for all of the cases?

I'll get this updated - thanks for looking at this, I know SSE4A isn't the most exciting of instructions to deal with!!

lib/Transforms/InstCombine/InstCombineCalls.cpp
934–935 ↗(On Diff #34170)

No problem.

972–986 ↗(On Diff #34170)

I'll look into creating a helper (this is one of the most common patterns in this entire file....). I'm intending to add support for decoding EXTRQI to shuffles soon so wish to keep the actual cases separate.

majnemer added inline comments.
lib/Transforms/InstCombine/InstCombineCalls.cpp
936–937 ↗(On Diff #34170)

I think it'd be more concise to use Op->getType()->getVectorNumElements()

RKSimon updated this revision to Diff 35000.Sep 17 2015, 8:16 AM

Updated - thanks for the comments. If you chaps are happy with the SimplifyDemandedVectorEltsLow helper I can convert other cases to use it in future commits.

spatel accepted this revision.Sep 17 2015, 9:12 AM
spatel edited edge metadata.

Updated - thanks for the comments. If you chaps are happy with the SimplifyDemandedVectorEltsLow helper I can convert other cases to use it in future commits.

Can we hoist the getVectorNumElements() and associated assert into the helper as well? If yes, please do. And certainly now that we have a helper, let's use it to reduce the code bloat wherever possible.

LGTM.

This revision is now accepted and ready to land.Sep 17 2015, 9:12 AM
This revision was automatically updated to reflect the committed changes.

Can we hoist the getVectorNumElements() and associated assert into the helper as well? If yes, please do. And certainly now that we have a helper, let's use it to reduce the code bloat wherever possible.

Thanks Sanjay, I'll look at hoisting the getVectorNumElements() when I update the other functions to use the helper - probably over the weekend.