Fix branches on FP compares

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25249 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2006-01-12 17:05:32 +00:00
parent d9d681d128
commit 4bb91024ac
4 changed files with 34 additions and 42 deletions

View File

@ -665,13 +665,7 @@ LowerOperation(SDOperand Op, SelectionDAG &DAG) {
SDOperand Cond = DAG.getNode(V8ISD::CMPICC, VTs, Ops).getValue(1); SDOperand Cond = DAG.getNode(V8ISD::CMPICC, VTs, Ops).getValue(1);
return DAG.getNode(V8ISD::BRICC, MVT::Other, Chain, Dest, CC, Cond); return DAG.getNode(V8ISD::BRICC, MVT::Other, Chain, Dest, CC, Cond);
} else { } else {
std::vector<MVT::ValueType> VTs; SDOperand Cond = DAG.getNode(V8ISD::CMPFCC, MVT::Flag, LHS, RHS);
VTs.push_back(MVT::i32);
VTs.push_back(MVT::Flag);
std::vector<SDOperand> Ops;
Ops.push_back(LHS);
Ops.push_back(RHS);
SDOperand Cond = DAG.getNode(V8ISD::CMPFCC, VTs, Ops).getValue(1);
return DAG.getNode(V8ISD::BRFCC, MVT::Other, Chain, Dest, CC, Cond); return DAG.getNode(V8ISD::BRFCC, MVT::Other, Chain, Dest, CC, Cond);
} }
} }
@ -682,18 +676,21 @@ LowerOperation(SDOperand Op, SelectionDAG &DAG) {
SDOperand TrueVal = Op.getOperand(2); SDOperand TrueVal = Op.getOperand(2);
SDOperand FalseVal = Op.getOperand(3); SDOperand FalseVal = Op.getOperand(3);
SDOperand CompareFlag;
unsigned Opc; unsigned Opc;
Opc = LHS.getValueType() == MVT::i32 ? V8ISD::CMPICC : V8ISD::CMPFCC; if (LHS.getValueType() == MVT::i32) {
std::vector<MVT::ValueType> VTs; std::vector<MVT::ValueType> VTs;
VTs.push_back(LHS.getValueType()); VTs.push_back(LHS.getValueType()); // subcc returns a value
VTs.push_back(MVT::Flag); VTs.push_back(MVT::Flag);
std::vector<SDOperand> Ops; std::vector<SDOperand> Ops;
Ops.push_back(LHS); Ops.push_back(LHS);
Ops.push_back(RHS); Ops.push_back(RHS);
SDOperand CompareFlag = DAG.getNode(Opc, VTs, Ops).getValue(1); CompareFlag = DAG.getNode(V8ISD::CMPICC, VTs, Ops).getValue(1);
Opc = V8ISD::SELECT_ICC;
Opc = LHS.getValueType() == MVT::i32 ? } else {
V8ISD::SELECT_ICC : V8ISD::SELECT_FCC; CompareFlag = DAG.getNode(V8ISD::CMPFCC, MVT::Flag, LHS, RHS);
Opc = V8ISD::SELECT_FCC;
}
return DAG.getNode(Opc, TrueVal.getValueType(), TrueVal, FalseVal, return DAG.getNode(Opc, TrueVal.getValueType(), TrueVal, FalseVal,
DAG.getConstant(CC, MVT::i32), CompareFlag); DAG.getConstant(CC, MVT::i32), CompareFlag);
} }

View File

@ -72,9 +72,8 @@ SDTypeProfile<1, 1, [SDTCisVT<0, f32>, SDTCisFP<1>]>;
def SDTV8ITOF : def SDTV8ITOF :
SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisVT<1, f32>]>; SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisVT<1, f32>]>;
def V8cmpicc : SDNode<"V8ISD::CMPICC", SDTIntBinOp, def V8cmpicc : SDNode<"V8ISD::CMPICC", SDTIntBinOp, [SDNPOutFlag]>;
[SDNPCommutative, SDNPOutFlag]>; def V8cmpfcc : SDNode<"V8ISD::CMPFCC", SDTV8cmpfcc, [SDNPOutFlag]>;
def V8cmpfcc : SDNode<"V8ISD::CMPFCC", SDTV8cmpfcc>;
def V8bricc : SDNode<"V8ISD::BRICC", SDTV8brcc, [SDNPHasChain]>; def V8bricc : SDNode<"V8ISD::BRICC", SDTV8brcc, [SDNPHasChain]>;
def V8brfcc : SDNode<"V8ISD::BRFCC", SDTV8brcc, [SDNPHasChain]>; def V8brfcc : SDNode<"V8ISD::BRFCC", SDTV8brcc, [SDNPHasChain]>;

View File

@ -665,13 +665,7 @@ LowerOperation(SDOperand Op, SelectionDAG &DAG) {
SDOperand Cond = DAG.getNode(V8ISD::CMPICC, VTs, Ops).getValue(1); SDOperand Cond = DAG.getNode(V8ISD::CMPICC, VTs, Ops).getValue(1);
return DAG.getNode(V8ISD::BRICC, MVT::Other, Chain, Dest, CC, Cond); return DAG.getNode(V8ISD::BRICC, MVT::Other, Chain, Dest, CC, Cond);
} else { } else {
std::vector<MVT::ValueType> VTs; SDOperand Cond = DAG.getNode(V8ISD::CMPFCC, MVT::Flag, LHS, RHS);
VTs.push_back(MVT::i32);
VTs.push_back(MVT::Flag);
std::vector<SDOperand> Ops;
Ops.push_back(LHS);
Ops.push_back(RHS);
SDOperand Cond = DAG.getNode(V8ISD::CMPFCC, VTs, Ops).getValue(1);
return DAG.getNode(V8ISD::BRFCC, MVT::Other, Chain, Dest, CC, Cond); return DAG.getNode(V8ISD::BRFCC, MVT::Other, Chain, Dest, CC, Cond);
} }
} }
@ -682,18 +676,21 @@ LowerOperation(SDOperand Op, SelectionDAG &DAG) {
SDOperand TrueVal = Op.getOperand(2); SDOperand TrueVal = Op.getOperand(2);
SDOperand FalseVal = Op.getOperand(3); SDOperand FalseVal = Op.getOperand(3);
SDOperand CompareFlag;
unsigned Opc; unsigned Opc;
Opc = LHS.getValueType() == MVT::i32 ? V8ISD::CMPICC : V8ISD::CMPFCC; if (LHS.getValueType() == MVT::i32) {
std::vector<MVT::ValueType> VTs; std::vector<MVT::ValueType> VTs;
VTs.push_back(LHS.getValueType()); VTs.push_back(LHS.getValueType()); // subcc returns a value
VTs.push_back(MVT::Flag); VTs.push_back(MVT::Flag);
std::vector<SDOperand> Ops; std::vector<SDOperand> Ops;
Ops.push_back(LHS); Ops.push_back(LHS);
Ops.push_back(RHS); Ops.push_back(RHS);
SDOperand CompareFlag = DAG.getNode(Opc, VTs, Ops).getValue(1); CompareFlag = DAG.getNode(V8ISD::CMPICC, VTs, Ops).getValue(1);
Opc = V8ISD::SELECT_ICC;
Opc = LHS.getValueType() == MVT::i32 ? } else {
V8ISD::SELECT_ICC : V8ISD::SELECT_FCC; CompareFlag = DAG.getNode(V8ISD::CMPFCC, MVT::Flag, LHS, RHS);
Opc = V8ISD::SELECT_FCC;
}
return DAG.getNode(Opc, TrueVal.getValueType(), TrueVal, FalseVal, return DAG.getNode(Opc, TrueVal.getValueType(), TrueVal, FalseVal,
DAG.getConstant(CC, MVT::i32), CompareFlag); DAG.getConstant(CC, MVT::i32), CompareFlag);
} }

View File

@ -72,9 +72,8 @@ SDTypeProfile<1, 1, [SDTCisVT<0, f32>, SDTCisFP<1>]>;
def SDTV8ITOF : def SDTV8ITOF :
SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisVT<1, f32>]>; SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisVT<1, f32>]>;
def V8cmpicc : SDNode<"V8ISD::CMPICC", SDTIntBinOp, def V8cmpicc : SDNode<"V8ISD::CMPICC", SDTIntBinOp, [SDNPOutFlag]>;
[SDNPCommutative, SDNPOutFlag]>; def V8cmpfcc : SDNode<"V8ISD::CMPFCC", SDTV8cmpfcc, [SDNPOutFlag]>;
def V8cmpfcc : SDNode<"V8ISD::CMPFCC", SDTV8cmpfcc>;
def V8bricc : SDNode<"V8ISD::BRICC", SDTV8brcc, [SDNPHasChain]>; def V8bricc : SDNode<"V8ISD::BRICC", SDTV8brcc, [SDNPHasChain]>;
def V8brfcc : SDNode<"V8ISD::BRFCC", SDTV8brcc, [SDNPHasChain]>; def V8brfcc : SDNode<"V8ISD::BRFCC", SDTV8brcc, [SDNPHasChain]>;