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-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=21b590cebcb1d48d211971c78edb32cfb67abf0a;p=llvm [DAGCombiner] Refactor to make it easy to add support for vectors in a future patch. NFCI. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301320 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index c67bca4da85..1251ae6262b 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/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(); + } } }