summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHal Finkel <hfinkel@anl.gov>2013-05-15 21:37:27 +0000
committerHal Finkel <hfinkel@anl.gov>2013-05-15 21:37:27 +0000
commit1f6a7f53d8188b099e20b87648e272855fc59bf6 (patch)
treee38bb254c98ca1315dfa41b0686bab71d508950e
parentc6e238c676c5a46e7953381f120cdbc6ce23b50b (diff)
downloadbcm5719-llvm-1f6a7f53d8188b099e20b87648e272855fc59bf6.tar.gz
bcm5719-llvm-1f6a7f53d8188b099e20b87648e272855fc59bf6.zip
Fix legalization of SETCC with promoted integer intrinsics
If the input operands to SETCC are promoted, we need to make sure that we either use the promoted form of both operands (or neither); a mixture is not allowed. This can happen, for example, if a target has a custom promoted i1-returning intrinsic (where i1 is not a legal type). In this case, we need to use the promoted form of both operands. This change only augments the behavior of the existing logic in the case where the input types (which may or may not have already been legalized) disagree, and should not affect existing target code because this case would otherwise cause an assert in the SETCC operand promotion code. This will be covered by (essentially all of the) tests for the new PPCCTRLoops infrastructure. llvm-svn: 181926
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
index cd2f060ce0f..0ecc89fe5ed 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
@@ -521,9 +521,20 @@ SDValue DAGTypeLegalizer::PromoteIntRes_SETCC(SDNode *N) {
assert(SVT.isVector() == N->getOperand(0).getValueType().isVector() &&
"Vector compare must return a vector result!");
+ SDValue LHS = N->getOperand(0);
+ SDValue RHS = N->getOperand(1);
+ if (LHS.getValueType() != RHS.getValueType()) {
+ if (getTypeAction(LHS.getValueType()) == TargetLowering::TypePromoteInteger &&
+ !LHS.getValueType().isVector())
+ LHS = GetPromotedInteger(LHS);
+ if (getTypeAction(RHS.getValueType()) == TargetLowering::TypePromoteInteger &&
+ !RHS.getValueType().isVector())
+ RHS = GetPromotedInteger(RHS);
+ }
+
// Get the SETCC result using the canonical SETCC type.
- SDValue SetCC = DAG.getNode(N->getOpcode(), dl, SVT, N->getOperand(0),
- N->getOperand(1), N->getOperand(2));
+ SDValue SetCC = DAG.getNode(N->getOpcode(), dl, SVT, LHS, RHS,
+ N->getOperand(2));
assert(NVT.bitsLE(SVT) && "Integer type overpromoted?");
// Convert to the expected type.
OpenPOWER on IntegriCloud