This is an archive of the discontinued LLVM Phabricator instance.

[SDAG] allow vector types for select->logic folds
ClosedPublic

Authored by spatel on Mar 1 2021, 1:45 PM.

Details

Summary

This prepares codegen for a change that will remove the identical folds from IR because they are not poison-safe. See D93065 / D97360 for details.

We already generically support scalar types, and there are various target-specific transforms that overlap the vector folds. For example, x86 recognizes the and patterns, but not or. We can end up with 1 extra instruction there, but I think that is still preferred over the blendv alternative that loads a constant vector.

Removing custom code can be a follow-up change.

Diff Detail

Event Timeline

spatel created this revision.Mar 1 2021, 1:45 PM
spatel requested review of this revision.Mar 1 2021, 1:45 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 1 2021, 1:45 PM
lebedev.ri accepted this revision.Mar 1 2021, 10:17 PM
lebedev.ri added a subscriber: lebedev.ri.

This looks good to me, thanks.

Should we also deal with the case when the constant contains an undef?
I guess it would be fine to do that in a follow-up.

This revision is now accepted and ready to land.Mar 1 2021, 10:17 PM
spatel added a comment.Mar 2 2021, 5:37 AM

This looks good to me, thanks.

Should we also deal with the case when the constant contains an undef?
I guess it would be fine to do that in a follow-up.

Yes, I can look at that. It requires some plumbing work: isNullOrNullSplat pipes an optional undef parameter to the underlying isConstOrConstSplat(), but One/AllOnes do not have that option.

This revision was automatically updated to reflect the committed changes.