[X86] Cleanup convertIntLogicToFPLogic a little. NFCI
-Use early returns to reduce indentation -Replace multipe ifs with a switch. -Replace an assert with an llvm_unreachable default in the switch. -Check that the FP type we're going to use for the X86ISD::FAND/FOR/FXOR is legal rather than checking that the integer type matches the width of a legal scalar fp type. This all runs after legalization so it shouldn't really matter, but making sure we're using a valid type in the X86ISD node is really whats important. llvm-svn: 362565
This commit is contained in:
parent
8ca5455764
commit
78fdce25a1
|
|
@ -37667,35 +37667,36 @@ static SDValue PromoteMaskArithmetic(SDNode *N, SelectionDAG &DAG,
|
||||||
/// unnecessary moves from SSE to integer registers.
|
/// unnecessary moves from SSE to integer registers.
|
||||||
static SDValue convertIntLogicToFPLogic(SDNode *N, SelectionDAG &DAG,
|
static SDValue convertIntLogicToFPLogic(SDNode *N, SelectionDAG &DAG,
|
||||||
const X86Subtarget &Subtarget) {
|
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);
|
EVT VT = N->getValueType(0);
|
||||||
SDValue N0 = N->getOperand(0);
|
SDValue N0 = N->getOperand(0);
|
||||||
SDValue N1 = N->getOperand(1);
|
SDValue N1 = N->getOperand(1);
|
||||||
SDLoc DL(N);
|
SDLoc DL(N);
|
||||||
if (N0.getOpcode() == ISD::BITCAST && N1.getOpcode() == ISD::BITCAST &&
|
|
||||||
((Subtarget.hasSSE1() && VT == MVT::i32) ||
|
if (N0.getOpcode() != ISD::BITCAST || N1.getOpcode() != ISD::BITCAST)
|
||||||
(Subtarget.hasSSE2() && VT == MVT::i64))) {
|
return SDValue();
|
||||||
|
|
||||||
SDValue N00 = N0.getOperand(0);
|
SDValue N00 = N0.getOperand(0);
|
||||||
SDValue N10 = N1.getOperand(0);
|
SDValue N10 = N1.getOperand(0);
|
||||||
EVT N00Type = N00.getValueType();
|
EVT N00Type = N00.getValueType();
|
||||||
EVT N10Type = N10.getValueType();
|
EVT N10Type = N10.getValueType();
|
||||||
if (N00Type.isFloatingPoint() && N10Type.isFloatingPoint()) {
|
|
||||||
|
// Ensure that both types are the same and are legal scalar fp types.
|
||||||
|
if (N00Type != N10Type ||
|
||||||
|
!((Subtarget.hasSSE1() && N00Type == MVT::f32) ||
|
||||||
|
(Subtarget.hasSSE2() && N00Type == MVT::f64)))
|
||||||
|
return SDValue();
|
||||||
|
|
||||||
|
unsigned FPOpcode;
|
||||||
|
switch (N->getOpcode()) {
|
||||||
|
default: llvm_unreachable("Unexpected input node for FP logic conversion");
|
||||||
|
case ISD::AND: FPOpcode = X86ISD::FAND; break;
|
||||||
|
case ISD::OR: FPOpcode = X86ISD::FOR; break;
|
||||||
|
case ISD::XOR: FPOpcode = X86ISD::FXOR; break;
|
||||||
|
}
|
||||||
|
|
||||||
SDValue FPLogic = DAG.getNode(FPOpcode, DL, N00Type, N00, N10);
|
SDValue FPLogic = DAG.getNode(FPOpcode, DL, N00Type, N00, N10);
|
||||||
return DAG.getBitcast(VT, FPLogic);
|
return DAG.getBitcast(VT, FPLogic);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return SDValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// If this is a zero/all-bits result that is bitwise-anded with a low bits
|
/// If this is a zero/all-bits result that is bitwise-anded with a low bits
|
||||||
/// mask. (Mask == 1 for the x86 lowering of a SETCC + ZEXT), replace the 'and'
|
/// mask. (Mask == 1 for the x86 lowering of a SETCC + ZEXT), replace the 'and'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue