From 8f2f2a76b9e954fe352319ac7cc00211c85c702c Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Mon, 5 Nov 2018 05:53:06 +0000 Subject: [PATCH] [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 --- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 395d855..fc0e8ef 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -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)) -- 2.7.4