Fix #9190
authorNadav Rotem <nadav.rotem@intel.com>
Fri, 11 Feb 2011 19:20:37 +0000 (19:20 +0000)
committerNadav Rotem <nadav.rotem@intel.com>
Fri, 11 Feb 2011 19:20:37 +0000 (19:20 +0000)
The bug happens when the DAGCombiner attempts to optimize one of the patterns
of the SUB opcode. It tries to create a zero of type v2i64. This type is legal
on 32bit machines, but the initializer of this vector (i64) is target dependent.
Currently, the initializer attempts to create an i64 zero constant, which fails.
Added a flag to tell the DAGCombiner to create a legal zero, if we require that
the pass would generate legal types.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125391 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/DAGCombiner.cpp

index dd7d56ab9d29f59afa2e4f01d959ba38f0eca323..1851e17187f73ab8c1fa9014097360c524fb6a54 100644 (file)
@@ -1533,7 +1533,7 @@ SDValue DAGCombiner::visitSUB(SDNode *N) {
 
   // fold (sub x, x) -> 0
   if (N0 == N1)
-    return DAG.getConstant(0, N->getValueType(0));
+    return DAG.getConstant(0, N->getValueType(0), LegalTypes);
   // fold (sub c1, c2) -> c1-c2
   if (N0C && N1C)
     return DAG.FoldConstantArithmetic(ISD::SUB, VT, N0C, N1C);