This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] canonicalize trunc + insert as bitcast + shuffle, part 2
ClosedPublic

Authored by spatel on Nov 28 2022, 3:34 PM.

Details

Summary

This enhances the base fold from part 1 to allow mapping a right-shift to an insert index.

Example of translating a middle chunk of the scalar to vector for either endian:
https://alive2.llvm.org/ce/z/fRXCOZ

This only allows creating an identity shuffle (with optional shortening/lengthening) because that is considered the safe baseline for any target (can be inverted if needed). If we tried this fold with target-specific costs/legality, then we could do the transform more generally.

Diff Detail

Event Timeline

spatel created this revision.Nov 28 2022, 3:34 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 28 2022, 3:34 PM
spatel requested review of this revision.Nov 28 2022, 3:34 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 28 2022, 3:34 PM
spatel updated this revision to Diff 479014.Nov 30 2022, 10:28 AM

Rebased on top of part 1 ( a4c466766db7 ).

RKSimon accepted this revision.Dec 1 2022, 6:27 AM

LGTM

llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
1553

Make it clear that we only allow an 'identity' shuffle mask here

This revision is now accepted and ready to land.Dec 1 2022, 6:27 AM
lebedev.ri accepted this revision.Dec 1 2022, 11:01 AM
spatel marked an inline comment as done.Dec 1 2022, 11:16 AM
This revision was landed with ongoing or failed builds.Dec 1 2022, 11:47 AM
This revision was automatically updated to reflect the committed changes.