This is an archive of the discontinued LLVM Phabricator instance.

[DAG] SimplifyDemandedBits - fold AND(INSERT_SUBVECTOR(C,X,I),M) -> INSERT_SUBVECTOR(AND(C,M),X,I)
ClosedPublic

Authored by RKSimon on Jul 7 2022, 6:55 AM.

Details

Summary

If all the demanded bits of the AND mask covering the inserted subvector 'X' are known to be one, then the mask isn't affecting the subvector at all.

In which case, if the base vector 'C' is undef/constant, then move the AND mask up to just fold it directly.

Addresses some of the regressions from D129150, particularly the cases where we're attempting to zero the upper elements of a widened vector.

Diff Detail

Event Timeline

RKSimon created this revision.Jul 7 2022, 6:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 7 2022, 6:55 AM
RKSimon requested review of this revision.Jul 7 2022, 6:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 7 2022, 6:55 AM
RKSimon updated this revision to Diff 442937.Jul 7 2022, 8:51 AM

fix comment

deadalnix accepted this revision.Jul 8 2022, 5:34 AM

This seems like a good transform. I have a bit of a concern, but it doesn't seems to materialize any problem in the test suite so, while worth keeping in mind, it doesn't look like it is worth blocking this for.

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
1366

This sound like a reasonable transform, however, that might push an and in the middle of an INSERT_SUBVECTOR chain. Won't that be a problem?

This revision is now accepted and ready to land.Jul 8 2022, 5:34 AM
RKSimon added inline comments.Jul 8 2022, 7:47 AM
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
1366

no chain - the base vector is checked to be undef / constant

deadalnix added inline comments.Jul 8 2022, 7:58 AM
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
1366

Obviously! Go for it.

This revision was landed with ongoing or failed builds.Jul 8 2022, 8:08 AM
This revision was automatically updated to reflect the committed changes.