This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] reassociate splatted vector ops
ClosedPublic

Authored by spatel on Jan 30 2020, 6:31 AM.

Details

Summary

bo (splat X), (bo Y, OtherOp) --> bo (splat (bo X, Y)), OtherOp

This patch depends on the splat analysis enhancement in D73549. See the test with comment:

; Negative test - mismatched splat elements

...as the motivation for that first patch. If anyone sees a better way, I'm open to suggestions.

The motivating case for reassociating splatted ops is shown in PR42174:
https://bugs.llvm.org/show_bug.cgi?id=42174

In that example, a slight change in order-of-associative math results in a big difference in IR and codegen. This patch gets all of the unnecessary shuffles out of the way, but doesn't address the potential scalarization (see D50992 or D73480 for that).

Diff Detail

Event Timeline

spatel created this revision.Jan 30 2020, 6:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 30 2020, 6:31 AM
This revision is now accepted and ready to land.Jan 31 2020, 12:05 PM
This revision was automatically updated to reflect the committed changes.