Don't crash on X^X if X is a vector. Instead, produce a vector of zeros.
authorChris Lattner <sabre@nondot.org>
Tue, 28 Mar 2006 19:11:05 +0000 (19:11 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 28 Mar 2006 19:11:05 +0000 (19:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27229 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/DAGCombiner.cpp

index 157b0a26b4eca494ad36db826328f0f4404e7375..424942b3e9b7fbdf8a267336be47f9edf6ce9361 100644 (file)
@@ -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 &&