mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
[DAGCombiner] Merge together duplicate checks for folding fold (select C, 1, X) -> (or C, X) and folding (select C, X, 0) -> (and C, X). Also be consistent about checking that both the condition and the result type are i1. NFC
I guess previously we just assumed if the result type was i1, then the condition type must also be i1? llvm-svn: 291548
This commit is contained in:
parent
0aa5cdf162
commit
a03446e0cd
@ -5361,8 +5361,9 @@ SDValue DAGCombiner::visitSELECT(SDNode *N) {
|
||||
// fold (select false, X, Y) -> Y
|
||||
return !N0C->isNullValue() ? N1 : N2;
|
||||
}
|
||||
// fold (select C, 1, X) -> (or C, X)
|
||||
if (VT == MVT::i1 && isOneConstant(N1))
|
||||
// fold (select X, X, Y) -> (or X, Y)
|
||||
// fold (select X, 1, Y) -> (or C, Y)
|
||||
if (VT == VT0 && VT == MVT::i1 && (N0 == N1 || isOneConstant(N1)))
|
||||
return DAG.getNode(ISD::OR, SDLoc(N), VT, N0, N2);
|
||||
|
||||
if (SDValue V = foldSelectOfConstants(N))
|
||||
@ -5380,16 +5381,9 @@ SDValue DAGCombiner::visitSELECT(SDNode *N) {
|
||||
AddToWorklist(NOTNode.getNode());
|
||||
return DAG.getNode(ISD::OR, SDLoc(N), VT, NOTNode, N1);
|
||||
}
|
||||
// fold (select C, X, 0) -> (and C, X)
|
||||
if (VT == MVT::i1 && isNullConstant(N2))
|
||||
return DAG.getNode(ISD::AND, SDLoc(N), VT, N0, N1);
|
||||
// fold (select X, X, Y) -> (or X, Y)
|
||||
// fold (select X, 1, Y) -> (or X, Y)
|
||||
if (VT == MVT::i1 && (N0 == N1 || isOneConstant(N1)))
|
||||
return DAG.getNode(ISD::OR, SDLoc(N), VT, N0, N2);
|
||||
// fold (select X, Y, X) -> (and X, Y)
|
||||
// fold (select X, Y, 0) -> (and X, Y)
|
||||
if (VT == MVT::i1 && (N0 == N2 || isNullConstant(N2)))
|
||||
if (VT == VT0 && VT == MVT::i1 && (N0 == N2 || isNullConstant(N2)))
|
||||
return DAG.getNode(ISD::AND, SDLoc(N), VT, N0, N1);
|
||||
|
||||
// If we can fold this based on the true/false value, do so.
|
||||
|
Loading…
Reference in New Issue
Block a user