summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorEric Christopher <echristo@apple.com>2011-02-16 01:10:03 +0000
committerEric Christopher <echristo@apple.com>2011-02-16 01:10:03 +0000
commitef72141a75769e7d0111f417b91931a74ec2c1a3 (patch)
tree53c6c4369a696c9f7a6c67833dd9a86b6e9f1807 /llvm/lib/CodeGen
parent58d6556faedda6a80ad7f87fd8a5ae8034ead908 (diff)
downloadbcm5719-llvm-ef72141a75769e7d0111f417b91931a74ec2c1a3.tar.gz
bcm5719-llvm-ef72141a75769e7d0111f417b91931a74ec2c1a3.zip
The change for PR9190 wasn't quite right. We need to avoid making the
transformation if we can't legally create a build vector of the correct type. Check that we can make the transformation first, and add a TODO to refactor this code with similar cases. Fixes: PR9223 and rdar://9000350 llvm-svn: 125631
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index f452d6a8420..e213d722eb7 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -1532,8 +1532,18 @@ SDValue DAGCombiner::visitSUB(SDNode *N) {
}
// fold (sub x, x) -> 0
- if (N0 == N1)
- return DAG.getConstant(0, N->getValueType(0), LegalTypes);
+ // FIXME: Refactor this and xor and other similar operations together.
+ if (N0 == N1) {
+ if (!VT.isVector()) {
+ return DAG.getConstant(0, VT);
+ } else if (!LegalOperations || TLI.isOperationLegal(ISD::BUILD_VECTOR, VT)){
+ // Produce a vector of zeros.
+ SDValue El = DAG.getConstant(0, VT.getVectorElementType());
+ std::vector<SDValue> Ops(VT.getVectorNumElements(), El);
+ return DAG.getNode(ISD::BUILD_VECTOR, N->getDebugLoc(), VT,
+ &Ops[0], Ops.size());
+ }
+ }
// fold (sub c1, c2) -> c1-c2
if (N0C && N1C)
return DAG.FoldConstantArithmetic(ISD::SUB, VT, N0C, N1C);
OpenPOWER on IntegriCloud