[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Chris Lattner
lattner at cs.uiuc.edu
Fri Mar 31 14:16:56 PST 2006
Changes in directory llvm/lib/CodeGen/SelectionDAG:
DAGCombiner.cpp updated: 1.135 -> 1.136
---
Log message:
Delete identity shuffles, implementing CodeGen/Generic/vector-identity-shuffle.ll
---
Diffs of the changes: (+56 -2)
DAGCombiner.cpp | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 56 insertions(+), 2 deletions(-)
Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.135 llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.136
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.135 Fri Mar 31 12:10:41 2006
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Fri Mar 31 16:16:43 2006
@@ -214,6 +214,7 @@
SDOperand visitVINSERT_VECTOR_ELT(SDNode *N);
SDOperand visitVBUILD_VECTOR(SDNode *N);
SDOperand visitVECTOR_SHUFFLE(SDNode *N);
+ SDOperand visitVVECTOR_SHUFFLE(SDNode *N);
SDOperand ReassociateOps(unsigned Opc, SDOperand LHS, SDOperand RHS);
@@ -652,6 +653,7 @@
case ISD::VINSERT_VECTOR_ELT: return visitVINSERT_VECTOR_ELT(N);
case ISD::VBUILD_VECTOR: return visitVBUILD_VECTOR(N);
case ISD::VECTOR_SHUFFLE: return visitVECTOR_SHUFFLE(N);
+ case ISD::VVECTOR_SHUFFLE: return visitVVECTOR_SHUFFLE(N);
}
return SDOperand();
}
@@ -2464,13 +2466,36 @@
}
SDOperand DAGCombiner::visitVECTOR_SHUFFLE(SDNode *N) {
+ SDOperand ShufMask = N->getOperand(2);
+ unsigned NumElts = ShufMask.getNumOperands();
+
+ // If the shuffle mask is an identity operation on the LHS, return the LHS.
+ bool isIdentity = true;
+ for (unsigned i = 0; i != NumElts; ++i) {
+ if (ShufMask.getOperand(i).getOpcode() != ISD::UNDEF &&
+ cast<ConstantSDNode>(ShufMask.getOperand(i))->getValue() != i) {
+ isIdentity = false;
+ break;
+ }
+ }
+ if (isIdentity) return N->getOperand(0);
+
+ // If the shuffle mask is an identity operation on the RHS, return the RHS.
+ isIdentity = true;
+ for (unsigned i = 0; i != NumElts; ++i) {
+ if (ShufMask.getOperand(i).getOpcode() != ISD::UNDEF &&
+ cast<ConstantSDNode>(ShufMask.getOperand(i))->getValue() != i+NumElts) {
+ isIdentity = false;
+ break;
+ }
+ }
+ if (isIdentity) return N->getOperand(1);
+
// If the LHS and the RHS are the same node, turn the RHS into an undef.
if (N->getOperand(0) == N->getOperand(1)) {
// Check the SHUFFLE mask, mapping any inputs from the 2nd operand into the
// first operand.
std::vector<SDOperand> MappedOps;
- SDOperand ShufMask = N->getOperand(2);
- unsigned NumElts = ShufMask.getNumOperands();
for (unsigned i = 0, e = ShufMask.getNumOperands(); i != e; ++i) {
if (cast<ConstantSDNode>(ShufMask.getOperand(i))->getValue() >= NumElts) {
unsigned NewIdx =
@@ -2491,6 +2516,35 @@
return SDOperand();
}
+SDOperand DAGCombiner::visitVVECTOR_SHUFFLE(SDNode *N) {
+ SDOperand ShufMask = N->getOperand(2);
+ unsigned NumElts = ShufMask.getNumOperands()-2;
+
+ // If the shuffle mask is an identity operation on the LHS, return the LHS.
+ bool isIdentity = true;
+ for (unsigned i = 0; i != NumElts; ++i) {
+ if (ShufMask.getOperand(i).getOpcode() != ISD::UNDEF &&
+ cast<ConstantSDNode>(ShufMask.getOperand(i))->getValue() != i) {
+ isIdentity = false;
+ break;
+ }
+ }
+ if (isIdentity) return N->getOperand(0);
+
+ // If the shuffle mask is an identity operation on the RHS, return the RHS.
+ isIdentity = true;
+ for (unsigned i = 0; i != NumElts; ++i) {
+ if (ShufMask.getOperand(i).getOpcode() != ISD::UNDEF &&
+ cast<ConstantSDNode>(ShufMask.getOperand(i))->getValue() != i+NumElts) {
+ isIdentity = false;
+ break;
+ }
+ }
+ if (isIdentity) return N->getOperand(1);
+
+ return SDOperand();
+}
+
SDOperand DAGCombiner::SimplifySelect(SDOperand N0, SDOperand N1, SDOperand N2){
assert(N0.getOpcode() ==ISD::SETCC && "First argument must be a SetCC node!");
More information about the llvm-commits
mailing list