[llvm] r238632 - SelectionDAG: fix logic for promoting shift types
Fiona Glaser
escha at apple.com
Fri May 29 16:37:22 PDT 2015
Author: escha
Date: Fri May 29 18:37:22 2015
New Revision: 238632
URL: http://llvm.org/viewvc/llvm-project?rev=238632&view=rev
Log:
SelectionDAG: fix logic for promoting shift types
r238503 fixed the problem of too-small shift types by promoting them
during legalization, but the correct solution is to promote only the
operands that actually demand promotion.
This fixes a crash on an out-of-tree target caused by trying to
promote an operand that can't be promoted.
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp?rev=238632&r1=238631&r2=238632&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp Fri May 29 18:37:22 2015
@@ -602,11 +602,13 @@ SDValue DAGTypeLegalizer::PromoteIntRes_
}
SDValue DAGTypeLegalizer::PromoteIntRes_SHL(SDNode *N) {
- SDValue Res = GetPromotedInteger(N->getOperand(0));
- SDValue Amt = N->getOperand(1);
- if (!TLI.isTypeLegal(Amt.getValueType()))
- Amt = ZExtPromotedInteger(N->getOperand(1));
- return DAG.getNode(ISD::SHL, SDLoc(N), Res.getValueType(), Res, Amt);
+ SDValue LHS = N->getOperand(0);
+ SDValue RHS = N->getOperand(1);
+ if (getTypeAction(LHS.getValueType()) == TargetLowering::TypePromoteInteger)
+ LHS = GetPromotedInteger(LHS);
+ if (getTypeAction(RHS.getValueType()) == TargetLowering::TypePromoteInteger)
+ RHS = ZExtPromotedInteger(RHS);
+ return DAG.getNode(ISD::SHL, SDLoc(N), LHS.getValueType(), LHS, RHS);
}
SDValue DAGTypeLegalizer::PromoteIntRes_SIGN_EXTEND_INREG(SDNode *N) {
@@ -626,21 +628,25 @@ SDValue DAGTypeLegalizer::PromoteIntRes_
}
SDValue DAGTypeLegalizer::PromoteIntRes_SRA(SDNode *N) {
+ SDValue LHS = N->getOperand(0);
+ SDValue RHS = N->getOperand(1);
// The input value must be properly sign extended.
- SDValue Res = SExtPromotedInteger(N->getOperand(0));
- SDValue Amt = N->getOperand(1);
- if (!TLI.isTypeLegal(Amt.getValueType()))
- Amt = ZExtPromotedInteger(N->getOperand(1));
- return DAG.getNode(ISD::SRA, SDLoc(N), Res.getValueType(), Res, Amt);
+ if (getTypeAction(LHS.getValueType()) == TargetLowering::TypePromoteInteger)
+ LHS = SExtPromotedInteger(LHS);
+ if (getTypeAction(RHS.getValueType()) == TargetLowering::TypePromoteInteger)
+ RHS = ZExtPromotedInteger(RHS);
+ return DAG.getNode(ISD::SRA, SDLoc(N), LHS.getValueType(), LHS, RHS);
}
SDValue DAGTypeLegalizer::PromoteIntRes_SRL(SDNode *N) {
+ SDValue LHS = N->getOperand(0);
+ SDValue RHS = N->getOperand(1);
// The input value must be properly zero extended.
- SDValue Res = ZExtPromotedInteger(N->getOperand(0));
- SDValue Amt = N->getOperand(1);
- if (!TLI.isTypeLegal(Amt.getValueType()))
- Amt = ZExtPromotedInteger(N->getOperand(1));
- return DAG.getNode(ISD::SRL, SDLoc(N), Res.getValueType(), Res, Amt);
+ if (getTypeAction(LHS.getValueType()) == TargetLowering::TypePromoteInteger)
+ LHS = ZExtPromotedInteger(LHS);
+ if (getTypeAction(RHS.getValueType()) == TargetLowering::TypePromoteInteger)
+ RHS = ZExtPromotedInteger(RHS);
+ return DAG.getNode(ISD::SRL, SDLoc(N), LHS.getValueType(), LHS, RHS);
}
SDValue DAGTypeLegalizer::PromoteIntRes_TRUNCATE(SDNode *N) {
More information about the llvm-commits
mailing list