From: Simon Pilgrim Date: Tue, 25 Apr 2017 16:16:03 +0000 (+0000) Subject: [DAGCombiner] Refactor to make it easy to add support for vectors in a future patch... X-Git-Tag: llvmorg-5.0.0-rc1~6732 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8264ed7075142d2ba34a65076070458e7aefeb7c;p=platform%2Fupstream%2Fllvm.git [DAGCombiner] Refactor to make it easy to add support for vectors in a future patch. NFCI. llvm-svn: 301320 --- diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index c67bca4d..1251ae6 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -4203,16 +4203,16 @@ SDValue DAGCombiner::visitOR(SDNode *N) { // Canonicalize (or (and X, c1), c2) -> (and (or X, c2), c1|c2) // iff (c1 & c2) != 0. - if (N1C && N0.getOpcode() == ISD::AND && N0.getNode()->hasOneUse() && - isa(N0.getOperand(1))) { - ConstantSDNode *C1 = cast(N0.getOperand(1)); - if (C1->getAPIntValue().intersects(N1C->getAPIntValue())) { - if (SDValue COR = DAG.FoldConstantArithmetic(ISD::OR, SDLoc(N1), VT, - N1C, C1)) - return DAG.getNode( - ISD::AND, SDLoc(N), VT, - DAG.getNode(ISD::OR, SDLoc(N0), VT, N0.getOperand(0), N1), COR); - return SDValue(); + if (N1C && N0.getOpcode() == ISD::AND && N0.getNode()->hasOneUse()) { + if (ConstantSDNode *C1 = dyn_cast(N0.getOperand(1))) { + if (C1->getAPIntValue().intersects(N1C->getAPIntValue())) { + if (SDValue COR = + DAG.FoldConstantArithmetic(ISD::OR, SDLoc(N1), VT, N1C, C1)) + return DAG.getNode( + ISD::AND, SDLoc(N), VT, + DAG.getNode(ISD::OR, SDLoc(N0), VT, N0.getOperand(0), N1), COR); + return SDValue(); + } } }