This is an archive of the discontinued LLVM Phabricator instance.

[DAGCombine] Truncate BUILD_VECTOR operators if necessary when constant folding vectors
ClosedPublic

Authored by sbaranga on Sep 8 2015, 8:42 AM.

Details

Summary

The BUILD_VECTOR node will truncate its operators to match the
type. We need to take this into account when constant folding -
we need to perform a truncation before constant folding the elements.
This is because the upper bits can change the result, depending on
the operation type (for example this is the case for min/max).

This change also adds a regression test.

Diff Detail

Event Timeline

sbaranga updated this revision to Diff 34221.Sep 8 2015, 8:42 AM
sbaranga retitled this revision from to [DAGCombine] Truncate BUILD_VECTOR operators if necessary when constant folding vectors.
sbaranga updated this object.
sbaranga added a subscriber: llvm-commits.
jmolloy added a subscriber: jmolloy.Sep 9 2015, 5:38 AM
jmolloy added inline comments.
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
13354

I'd prefer to see this as ANY_EXTEND, as that more precisely describes that the upper bits are known to be undefined.

But shouldn't this only happen if we're in the post-legalize stage?

sbaranga updated this revision to Diff 34341.Sep 9 2015, 8:31 AM

Use ANY_EXTEND instead of ZERO_EXTEND and only do so after legalization.

jmolloy accepted this revision.Sep 10 2015, 2:09 AM
jmolloy added a reviewer: jmolloy.

This now LGTM, Thanks.

This revision is now accepted and ready to land.Sep 10 2015, 2:09 AM
sbaranga closed this revision.Sep 10 2015, 3:35 AM

Thanks, committed in r247265.