[DAGCombiner] Use tryFoldToZero to simplify some code and make it work correctly between LegalTypes and LegalOperations.

The original code avoided creating a zero vector after type legalization, but if we're after type legalization the type we have is legal. The real hazard we need to avoid is creating a build vector after op legalization. tryFoldToZero takes care of checking for this.

llvm-svn: 346119
This commit is contained in:
Craig Topper 2018-11-05 05:53:06 +00:00
parent 8d64abddd1
commit 8f2f2a76b9
1 changed files with 2 additions and 8 deletions

View File

@ -3839,10 +3839,7 @@ SDValue DAGCombiner::SimplifyBinOpWithSameOpcodeHands(SDNode *N) {
// Don't try to fold this node if it requires introducing a
// build vector of all zeros that might be illegal at this stage.
if (N->getOpcode() == ISD::XOR && !ShOp.isUndef()) {
if (!LegalTypes)
ShOp = DAG.getConstant(0, SDLoc(N), VT);
else
ShOp = SDValue();
ShOp = tryFoldToZero(SDLoc(N), TLI, VT, DAG, LegalOperations);
}
// (AND (shuf (A, C), shuf (B, C))) -> shuf (AND (A, B), C)
@ -3860,10 +3857,7 @@ SDValue DAGCombiner::SimplifyBinOpWithSameOpcodeHands(SDNode *N) {
// build vector of all zeros that might be illegal at this stage.
ShOp = N0->getOperand(0);
if (N->getOpcode() == ISD::XOR && !ShOp.isUndef()) {
if (!LegalTypes)
ShOp = DAG.getConstant(0, SDLoc(N), VT);
else
ShOp = SDValue();
ShOp = tryFoldToZero(SDLoc(N), TLI, VT, DAG, LegalOperations);
}
// (AND (shuf (C, A), shuf (C, B))) -> shuf (C, AND (A, B))