Check type for legality before forming a select from loads.
authorPete Cooper <peter_cooper@apple.com>
Tue, 12 Feb 2013 03:14:50 +0000 (03:14 +0000)
committerPete Cooper <peter_cooper@apple.com>
Tue, 12 Feb 2013 03:14:50 +0000 (03:14 +0000)
Sorry for the lack of a test case.  I tried writing one for i386 as i know selects are illegal on this target, but they are actually considered legal by isel and expanded later.

I can't see any targets to trigger this, but checking for the legality of a node before forming it is general goodness.

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

lib/CodeGen/SelectionDAG/DAGCombiner.cpp

index 472919c3e302105d3fb04e04f66add956a70ba37..5b831499825808454c7ea0a0dd7a2641f216ea5f 100644 (file)
@@ -9400,7 +9400,9 @@ bool DAGCombiner::SimplifySelectOps(SDNode *TheSelect, SDValue LHS,
         // src value info, don't do the transformation if the memory
         // locations are not in the default address space.
         LLD->getPointerInfo().getAddrSpace() != 0 ||
-        RLD->getPointerInfo().getAddrSpace() != 0)
+        RLD->getPointerInfo().getAddrSpace() != 0 ||
+        !TLI.isOperationLegalOrCustom(TheSelect->getOpcode(),
+                                      LLD->getBasePtr().getValueType()))
       return false;
 
     // Check that the select condition doesn't reach either load.  If so,