This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Improve Vector Demanded Bits Through Bitcasts
ClosedPublic

Authored by RKSimon on Sep 17 2015, 7:46 AM.

Details

Summary

Currently SimplifyDemandedVectorElts can only peek through bitcasts if the vectors have the same number of elements.

This patch fixes and enables some existing (disabled) code to support bitcasting to vectors with more/fewer elements. It currently only accepts cases when vectors alias cleanly (i.e. number of elements are an exact multiple of the other vector).

This was added to improve the demanded vector elements support for SSE vector shifts which require the __m128i (<2 x i64>) argument type to be bitcast to the vector type for the builtin shift. I've added extra tests for various additional bitcasts.

Diff Detail

Repository
rL LLVM

Event Timeline

RKSimon updated this revision to Diff 34995.Sep 17 2015, 7:46 AM
RKSimon retitled this revision from to [InstCombine] Improve Vector Demanded Bits Through Bitcasts.
RKSimon updated this object.
RKSimon added reviewers: majnemer, andreadb, spatel.
RKSimon set the repository for this revision to rL LLVM.
RKSimon added a subscriber: llvm-commits.
spatel added inline comments.Sep 25 2015, 8:17 AM
lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
1094

It would be better if this comment matched the code. Ie, "more elements" is just ">" which is a case we don't currently handle.

"If the number of elements in the result is a multiple of the number of elements in the source..." ?

Same change for the other comments below.

test/Transforms/InstCombine/x86-vector-shifts.ll
841

I see that the function attributes ("nounwind readnone uwtable") are endemic in this file; are any of those needed? If not, you could remove them all (as a separate commit either before or after this one).

RKSimon updated this revision to Diff 35820.Sep 27 2015, 4:32 AM

Updated based on Sanjay's feedback

spatel accepted this revision.Sep 27 2015, 1:25 PM
spatel edited edge metadata.

LGTM.

This revision is now accepted and ready to land.Sep 27 2015, 1:25 PM
This revision was automatically updated to reflect the committed changes.