This is an archive of the discontinued LLVM Phabricator instance.

[DAG] Add common vector constant folding helper function
ClosedPublic

Authored by RKSimon on Oct 12 2015, 11:24 AM.

Details

Summary

We have a number of functions that implement constant folding of vectors (unary and binary ops) in near identical manners (and the differences don't appear to be critical).

This patch introduces a common implementation (SelectionDAG::FoldConstantVectorArithmetic) and calls this in both the unary and binary op cases.

After this initial patch I intend to begin enabling vector constant folding for a wider number of opcodes in SelectionDAG::getNode().

Diff Detail

Repository
rL LLVM

Event Timeline

RKSimon updated this revision to Diff 37136.Oct 12 2015, 11:24 AM
RKSimon retitled this revision from to [DAG] Add common vector constant folding helper function.
RKSimon updated this object.
RKSimon added reviewers: qcolombet, hfinkel, spatel, andreadb.
RKSimon set the repository for this revision to rL LLVM.
RKSimon added a subscriber: llvm-commits.
qcolombet edited edge metadata.Oct 12 2015, 2:07 PM

Hi Simon,

This mostly LGTM, just a few fixes in the comments.

Thanks,
-Quentin

lib/CodeGen/SelectionDAG/DAGCombiner.cpp
13483

This change is unrelated.

lib/CodeGen/SelectionDAG/SelectionDAG.cpp
3345

The IsSameVectorSize is not checking the width of the vector type, just the number of lanes.

3389

The verb is missing.

RKSimon updated this revision to Diff 37184.Oct 12 2015, 2:58 PM
RKSimon edited edge metadata.
RKSimon marked 3 inline comments as done.

Thanks Quentin, updated.

qcolombet accepted this revision.Oct 12 2015, 3:40 PM
qcolombet edited edge metadata.

LGTM.

Thanks,
-Quentin

This revision is now accepted and ready to land.Oct 12 2015, 3:40 PM
This revision was automatically updated to reflect the committed changes.