Skip to content

Commit 6350de7

Browse files
committed
[DAGCombine] Fix unchecked calls to DAGCombiner::*ExtPromoteOperand
Other calls to DAGCombiner::*PromoteOperand check the result, but here it could cause an assertion in getNode. Falling back to any extend in this case instead of failing outright seems correct to me. No test case because: The failure was triggered by an out of tree backend. In order to trigger it, a backend would need to overload TargetLowering::IsDesirableToPromoteOp to return true for a type for which ISD::SIGN_EXTEND_INREG is marked illegal. In tree, only X86 overloads and sometimes returns true for MVT::i16 yet it marks setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::i16 , Legal);. Patch by Jacob Young! Differential Revision: https://reviews.llvm.org/D33633 llvm-svn: 304723
1 parent 807b708 commit 6350de7

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,13 +1028,13 @@ SDValue DAGCombiner::PromoteOperand(SDValue Op, EVT PVT, bool &Replace) {
10281028
switch (Opc) {
10291029
default: break;
10301030
case ISD::AssertSext:
1031-
return DAG.getNode(ISD::AssertSext, DL, PVT,
1032-
SExtPromoteOperand(Op.getOperand(0), PVT),
1033-
Op.getOperand(1));
1031+
if (SDValue Op0 = SExtPromoteOperand(Op.getOperand(0), PVT))
1032+
return DAG.getNode(ISD::AssertSext, DL, PVT, Op0, Op.getOperand(1));
1033+
break;
10341034
case ISD::AssertZext:
1035-
return DAG.getNode(ISD::AssertZext, DL, PVT,
1036-
ZExtPromoteOperand(Op.getOperand(0), PVT),
1037-
Op.getOperand(1));
1035+
if (SDValue Op0 = ZExtPromoteOperand(Op.getOperand(0), PVT))
1036+
return DAG.getNode(ISD::AssertZext, DL, PVT, Op0, Op.getOperand(1));
1037+
break;
10381038
case ISD::Constant: {
10391039
unsigned ExtOpc =
10401040
Op.getValueType().isByteSized() ? ISD::SIGN_EXTEND : ISD::ZERO_EXTEND;

0 commit comments

Comments
 (0)