This is an archive of the discontinued LLVM Phabricator instance.

[InstSimplify] look through vector select (shuffle) in min/max fold
ClosedPublic

Authored by spatel on Sep 29 2022, 7:15 AM.

Details

Summary

This is an extension of the existing min/max+select fold (which already has a very large number of variations) to allow a vector shuffle because that's what we have in the motivating example from issue #42100.

A couple of Alive2 checks of variants (I don't know how to generalize these in Alive):
https://alive2.llvm.org/ce/z/jUFAqT

And verify the PR42100 test:
https://alive2.llvm.org/ce/z/3EcASf

It's possible there is some generalization of the fold or a VectorCombine/SLP answer for the motivating test, but I haven't found a better/smaller solution yet.
We can also add even more variants here as follow-up patches. For example, we can have shuffle followed by min/max; we also don't have this canonicalization or the reverse:
https://alive2.llvm.org/ce/z/StHD9f

Diff Detail

Event Timeline

spatel created this revision.Sep 29 2022, 7:15 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 29 2022, 7:15 AM
spatel requested review of this revision.Sep 29 2022, 7:15 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 29 2022, 7:15 AM

one (very) pedantic minor

llvm/test/Transforms/InstSimplify/select-maxmin.ll
1945

precommit these descriptions?

spatel updated this revision to Diff 463933.Sep 29 2022, 9:19 AM

Rebased after pre-commit of tests (and remove TODO comments for the positive tests).

spatel marked an inline comment as done.Sep 29 2022, 9:20 AM
nikic accepted this revision.Sep 30 2022, 2:36 AM

LGTM

This revision is now accepted and ready to land.Sep 30 2022, 2:36 AM