aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2008-02-16 10:29:26 +0000
committerDuncan Sands <baldrick@free.fr>2008-02-16 10:29:26 +0000
commit051bb7b07504be9f848f7cce802e62ed24980bc5 (patch)
tree770b82437edddc8878dfa98b0a296371fad579da
parent17bcde9f9b18e1076a9f20d1dcd3b4a8e9985352 (diff)
downloadexternal_llvm-051bb7b07504be9f848f7cce802e62ed24980bc5.zip
external_llvm-051bb7b07504be9f848f7cce802e62ed24980bc5.tar.gz
external_llvm-051bb7b07504be9f848f7cce802e62ed24980bc5.tar.bz2
Teach LegalizeTypes how to expand the operands of
br_cc. This fixes 5 "make check" failures. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47212 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/SelectionDAG/LegalizeTypes.h9
-rw-r--r--lib/CodeGen/SelectionDAG/LegalizeTypesExpand.cpp20
2 files changed, 25 insertions, 4 deletions
diff --git a/lib/CodeGen/SelectionDAG/LegalizeTypes.h b/lib/CodeGen/SelectionDAG/LegalizeTypes.h
index 47985c7..acae44b 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeTypes.h
+++ b/lib/CodeGen/SelectionDAG/LegalizeTypes.h
@@ -238,14 +238,15 @@ private:
// Operand Expansion.
bool ExpandOperand(SDNode *N, unsigned OperandNo);
- SDOperand ExpandOperand_TRUNCATE(SDNode *N);
SDOperand ExpandOperand_BIT_CONVERT(SDNode *N);
- SDOperand ExpandOperand_UINT_TO_FP(SDOperand Source, MVT::ValueType DestTy);
- SDOperand ExpandOperand_SINT_TO_FP(SDOperand Source, MVT::ValueType DestTy);
+ SDOperand ExpandOperand_BR_CC(SDNode *N);
SDOperand ExpandOperand_EXTRACT_ELEMENT(SDNode *N);
SDOperand ExpandOperand_SETCC(SDNode *N);
+ SDOperand ExpandOperand_SINT_TO_FP(SDOperand Source, MVT::ValueType DestTy);
SDOperand ExpandOperand_STORE(StoreSDNode *N, unsigned OpNo);
-
+ SDOperand ExpandOperand_TRUNCATE(SDNode *N);
+ SDOperand ExpandOperand_UINT_TO_FP(SDOperand Source, MVT::ValueType DestTy);
+
void ExpandSetCCOperands(SDOperand &NewLHS, SDOperand &NewRHS,
ISD::CondCode &CCCode);
diff --git a/lib/CodeGen/SelectionDAG/LegalizeTypesExpand.cpp b/lib/CodeGen/SelectionDAG/LegalizeTypesExpand.cpp
index 136ae68..b440e7a 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeTypesExpand.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeTypesExpand.cpp
@@ -850,6 +850,8 @@ bool DAGTypeLegalizer::ExpandOperand(SDNode *N, unsigned OpNo) {
Res = ExpandOperand_UINT_TO_FP(N->getOperand(0), N->getValueType(0));
break;
case ISD::EXTRACT_ELEMENT: Res = ExpandOperand_EXTRACT_ELEMENT(N); break;
+
+ case ISD::BR_CC: Res = ExpandOperand_BR_CC(N); break;
case ISD::SETCC: Res = ExpandOperand_SETCC(N); break;
case ISD::STORE:
@@ -976,6 +978,24 @@ SDOperand DAGTypeLegalizer::ExpandOperand_EXTRACT_ELEMENT(SDNode *N) {
return cast<ConstantSDNode>(N->getOperand(1))->getValue() ? Hi : Lo;
}
+SDOperand DAGTypeLegalizer::ExpandOperand_BR_CC(SDNode *N) {
+ SDOperand NewLHS = N->getOperand(2), NewRHS = N->getOperand(3);
+ ISD::CondCode CCCode = cast<CondCodeSDNode>(N->getOperand(1))->get();
+ ExpandSetCCOperands(NewLHS, NewRHS, CCCode);
+
+ // If ExpandSetCCOperands returned a scalar, we need to compare the result
+ // against zero to select between true and false values.
+ if (NewRHS.Val == 0) {
+ NewRHS = DAG.getConstant(0, NewLHS.getValueType());
+ CCCode = ISD::SETNE;
+ }
+
+ // Update N to have the operands specified.
+ return DAG.UpdateNodeOperands(SDOperand(N, 0), N->getOperand(0),
+ DAG.getCondCode(CCCode), NewLHS, NewRHS,
+ N->getOperand(4));
+}
+
SDOperand DAGTypeLegalizer::ExpandOperand_SETCC(SDNode *N) {
SDOperand NewLHS = N->getOperand(0), NewRHS = N->getOperand(1);
ISD::CondCode CCCode = cast<CondCodeSDNode>(N->getOperand(2))->get();