From: Sanjay Patel Date: Wed, 23 Sep 2015 17:39:41 +0000 (+0000) Subject: [x86] move code for converting int logic to FP logic to a helper function; NFCI X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=46a7838d96ae63eab405eeff626c21c9fd53e752;p=oota-llvm.git [x86] move code for converting int logic to FP logic to a helper function; NFCI This is a follow-on to: http://reviews.llvm.org/rL248395 so we can add the call to the or/xor combines too. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@248399 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index a19ffcfbe54..4e2a0917665 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -24409,6 +24409,41 @@ static SDValue VectorZextCombine(SDNode *N, SelectionDAG &DAG, return DAG.getBitcast(N0.getValueType(), NewShuffle); } +/// If both input operands of a logic op are being cast from floating point +/// types, try to convert this into a floating point logic node to avoid +/// unnecessary moves from SSE to integer registers. +static SDValue convertIntLogicToFPLogic(SDNode *N, SelectionDAG &DAG, + const X86Subtarget *Subtarget) { + unsigned FPOpcode = ISD::DELETED_NODE; + if (N->getOpcode() == ISD::AND) + FPOpcode = X86ISD::FAND; + else if (N->getOpcode() == ISD::OR) + FPOpcode = X86ISD::FOR; + else if (N->getOpcode() == ISD::XOR) + FPOpcode = X86ISD::FXOR; + + assert(FPOpcode != ISD::DELETED_NODE && + "Unexpected input node for FP logic conversion"); + + EVT VT = N->getValueType(0); + SDValue N0 = N->getOperand(0); + SDValue N1 = N->getOperand(1); + SDLoc DL(N); + if (N0.getOpcode() == ISD::BITCAST && N1.getOpcode() == ISD::BITCAST && + ((Subtarget->hasSSE1() && VT == MVT::i32) || + (Subtarget->hasSSE2() && VT == MVT::i64))) { + SDValue N00 = N0.getOperand(0); + SDValue N10 = N1.getOperand(0); + EVT N00Type = N00.getValueType(); + EVT N10Type = N10.getValueType(); + if (N00Type.isFloatingPoint() && N10Type.isFloatingPoint()) { + SDValue FPLogic = DAG.getNode(FPOpcode, DL, N00Type, N00, N10); + return DAG.getBitcast(VT, FPLogic); + } + } + return SDValue(); +} + static SDValue PerformAndCombine(SDNode *N, SelectionDAG &DAG, TargetLowering::DAGCombinerInfo &DCI, const X86Subtarget *Subtarget) { @@ -24447,23 +24482,8 @@ static SDValue PerformAndCombine(SDNode *N, SelectionDAG &DAG, } } // BEXTR - // If both input operands are being cast from floating point types, - // try to convert this into a floating point logic node to avoid - // unnecessary moves from SSE to integer registers. - // FIXME: Split this into a helper function, so it can also be used with - // or/xor combining. - if (N0.getOpcode() == ISD::BITCAST && N1.getOpcode() == ISD::BITCAST && - ((Subtarget->hasSSE1() && VT == MVT::i32) || - (Subtarget->hasSSE2() && VT == MVT::i64))) { - SDValue N00 = N0.getOperand(0); - SDValue N10 = N1.getOperand(0); - EVT N00Type = N00.getValueType(); - EVT N10Type = N10.getValueType(); - if (N00Type.isFloatingPoint() && N10Type.isFloatingPoint()) { - SDValue FLogic = DAG.getNode(X86ISD::FAND, DL, N00Type, N00, N10); - return DAG.getBitcast(VT, FLogic); - } - } + if (SDValue FPLogic = convertIntLogicToFPLogic(N, DAG, Subtarget)) + return FPLogic; return SDValue(); }