This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] Combine concat_vectors(trunc(scalar), undef) -> scalar_to_vector(scalar)
ClosedPublic

Authored by ab on Apr 7 2015, 4:52 PM.

Details

Summary

We already do:

concat_vectors(scalar, undef) -> scalar_to_vector(scalar)

When the scalar is legal. When it's not, but is a truncated legal scalar, we can also do:

concat_vectors(trunc(scalar), undef) -> scalar_to_vector(scalar)

Which is equivalent, since the upper lanes are undef anyway.

To achieve that, we need to teach the original combine to look at multiple UNDEF operands, not just 1. I can't think of a case where than happens in isolation, so let's consider it part of this combine.

Diff Detail

Event Timeline

ab updated this revision to Diff 23380.Apr 7 2015, 4:52 PM
ab retitled this revision from to [CodeGen] Combine concat_vectors(trunc(scalar), undef) -> scalar_to_vector(scalar).
ab updated this object.
ab edited the test plan for this revision. (Show Details)
ab added reviewers: spatel, qcolombet.
ab added a subscriber: Unknown Object (MLST).
chandlerc accepted this revision.Apr 8 2015, 7:40 PM
chandlerc added a reviewer: chandlerc.
chandlerc added a subscriber: chandlerc.

Minor fixes below. LGTM with those fixes. Thanks!

lib/CodeGen/SelectionDAG/DAGCombiner.cpp
11517–11519

Inline this into the std::all_of?

11520–11522

Why the boolean variable? I'd just put the std::all_of in the if...

nit: I prefer std::next to adding one to the begin.

This revision is now accepted and ready to land.Apr 8 2015, 7:40 PM
This revision was automatically updated to reflect the committed changes.