Skip to content

Commit 648eff1

Browse files
committedJan 14, 2015
DAG Combiner: Fold SelectCC When Cond is UNDEF
In case folding a node end up with a NaN as operand for the select, the folding of the condition of the selectcc node returns "UNDEF". Differential Revision: http://reviews.llvm.org/D6889 llvm-svn: 225952
1 parent 7b068f6 commit 648eff1

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed
 

‎llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5100,13 +5100,16 @@ SDValue DAGCombiner::visitSELECT_CC(SDNode *N) {
51005100
return N2; // cond always true -> true val
51015101
else
51025102
return N3; // cond always false -> false val
5103-
}
5104-
5105-
// Fold to a simpler select_cc
5106-
if (SCC.getOpcode() == ISD::SETCC)
5103+
} else if (SCC->getOpcode() == ISD::UNDEF) {
5104+
// When the condition is UNDEF, just return the first operand. This is
5105+
// coherent the DAG creation, no setcc node is created in this case
5106+
return N2;
5107+
} else if (SCC.getOpcode() == ISD::SETCC) {
5108+
// Fold to a simpler select_cc
51075109
return DAG.getNode(ISD::SELECT_CC, SDLoc(N), N2.getValueType(),
51085110
SCC.getOperand(0), SCC.getOperand(1), N2, N3,
51095111
SCC.getOperand(2));
5112+
}
51105113
}
51115114

51125115
// If we can fold this based on the true/false value, do so.

0 commit comments

Comments
 (0)
Please sign in to comment.