[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Chris Lattner lattner at cs.uiuc.edu
Tue Mar 28 14:19:59 PST 2006



Changes in directory llvm/lib/CodeGen/SelectionDAG:

DAGCombiner.cpp updated: 1.132 -> 1.133
---
Log message:

When building a VVECTOR_SHUFFLE node from extract_element operations, make
sure to build it as SHUFFLE(X, undef, mask), not SHUFFLE(X, X, mask).

The later is not canonical form, and prevents the PPC splat pattern from 
matching.  For a particular splat, we go from generating this:

	li r10, lo16(LCPI1_0)
	lis r11, ha16(LCPI1_0)
	lvx v3, r11, r10
	vperm v3, v2, v2, v3

to generating:

	vspltw v3, v2, 3



---
Diffs of the changes:  (+11 -1)

 DAGCombiner.cpp |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletion(-)


Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.132 llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.133
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.132	Tue Mar 28 16:11:53 2006
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp	Tue Mar 28 16:19:47 2006
@@ -2419,7 +2419,17 @@
     // Return the new VVECTOR_SHUFFLE node.
     std::vector<SDOperand> Ops;
     Ops.push_back(VecIn1);
-    Ops.push_back(VecIn2.Val ? VecIn2 : VecIn1); // Use V1 twice if no V2.
+    if (VecIn2.Val) {
+      Ops.push_back(VecIn2);
+    } else {
+       // Use an undef vbuild_vector as input for the second operand.
+      std::vector<SDOperand> UnOps(NumInScalars,
+                                   DAG.getNode(ISD::UNDEF, 
+                                           cast<VTSDNode>(EltType)->getVT()));
+      UnOps.push_back(NumElts);
+      UnOps.push_back(EltType);
+      Ops.push_back(DAG.getNode(ISD::VBUILD_VECTOR, MVT::Vector, UnOps));
+    }
     Ops.push_back(DAG.getNode(ISD::VBUILD_VECTOR,MVT::Vector, BuildVecIndices));
     Ops.push_back(NumElts);
     Ops.push_back(EltType);






More information about the llvm-commits mailing list