This is an archive of the discontinued LLVM Phabricator instance.

[X86] Fold (shift undef, X)->0 for vector shifts by immediate.
ClosedPublic

Authored by craig.topper on May 26 2021, 11:22 AM.

Details

Summary

We could previously do this by accident through the later
call to getTargetConstantBitsFromNode I think, but that only worked
if N0 had a single use. This patch makes it explicit for undef and
doesn't have a use count check.

I think this is needed to move the (shl X, 1)->(add X, X)
fold to isel for PR50468. We need to be sure X won't be IMPLICIT_DEF
which might prevent the same vreg from being used for both operands.

Diff Detail

Event Timeline

craig.topper created this revision.May 26 2021, 11:22 AM
craig.topper requested review of this revision.May 26 2021, 11:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 26 2021, 11:22 AM
RKSimon accepted this revision.May 27 2021, 2:41 AM

LGTM

llvm/test/CodeGen/X86/vec_shift5.ll
193

precommit - and maybe include a shift-by-one instruction ?

This revision is now accepted and ready to land.May 27 2021, 2:41 AM
This revision was landed with ongoing or failed builds.May 27 2021, 9:32 AM
This revision was automatically updated to reflect the committed changes.