diff options
author | Chris Lattner <sabre@nondot.org> | 2006-03-28 19:11:05 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-03-28 19:11:05 +0000 |
commit | b7163598f9e958029ce4338faa2d090db0f2bfc6 (patch) | |
tree | 14071ca8169c2caffb4d4f4cbf1fa6c6617542c3 /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | |
parent | ffec47ebff0a328736ac4648586d19591620c83a (diff) | |
download | bcm5719-llvm-b7163598f9e958029ce4338faa2d090db0f2bfc6.tar.gz bcm5719-llvm-b7163598f9e958029ce4338faa2d090db0f2bfc6.zip |
Don't crash on X^X if X is a vector. Instead, produce a vector of zeros.
llvm-svn: 27229
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 157b0a26b4e..424942b3e9b 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -1396,8 +1396,16 @@ SDOperand DAGCombiner::visitXOR(SDNode *N) { DAG.getConstant(N1C->getValue()^N01C->getValue(), VT)); } // fold (xor x, x) -> 0 - if (N0 == N1) - return DAG.getConstant(0, VT); + if (N0 == N1) { + if (!MVT::isVector(VT)) { + return DAG.getConstant(0, VT); + } else if (!AfterLegalize || TLI.isOperationLegal(ISD::BUILD_VECTOR, VT)) { + // Produce a vector of zeros. + SDOperand El = DAG.getConstant(0, MVT::getVectorBaseType(VT)); + std::vector<SDOperand> Ops(MVT::getVectorNumElements(VT), El); + return DAG.getNode(ISD::BUILD_VECTOR, VT, Ops); + } + } // fold (xor (zext x), (zext y)) -> (zext (xor x, y)) if (N0.getOpcode() == ISD::ZERO_EXTEND && N1.getOpcode() == ISD::ZERO_EXTEND && |