Skip to content

Commit 966a8bd

Browse files
committed
code
1 parent 9c0f9f8 commit 966a8bd

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13924,6 +13924,34 @@ SDValue DAGCombiner::visitSETCC(SDNode *N) {
1392413924
}
1392513925
}
1392613926
}
13927+
13928+
// (setcc (zext a), (zext b), setu??) -> (setcc a, b, setu??)
13929+
// (setcc (sext a), (sext b), sets??) -> (setcc a, b, sets??)
13930+
if ((ISD::isUnsignedIntSetCC(Cond) && N0.getOpcode() == ISD::ZERO_EXTEND &&
13931+
N1.getOpcode() == ISD::ZERO_EXTEND) ||
13932+
(ISD::isSignedIntSetCC(Cond) && N0.getOpcode() == ISD::SIGN_EXTEND &&
13933+
N1.getOpcode() == ISD::SIGN_EXTEND)) {
13934+
SDValue LHS = N0.getOperand(0), RHS = N1.getOperand(0);
13935+
EVT SmallVT =
13936+
LHS.getScalarValueSizeInBits() > RHS.getScalarValueSizeInBits()
13937+
? LHS.getValueType()
13938+
: RHS.getValueType();
13939+
if (!LegalOperations ||
13940+
(SmallVT.isSimple() &&
13941+
TLI.isCondCodeLegal(Cond, SmallVT.getSimpleVT()))) {
13942+
LHS = DAG.getExtOrTrunc(ISD::isSignedIntSetCC(Cond), LHS, SDLoc(LHS),
13943+
SmallVT);
13944+
RHS = DAG.getExtOrTrunc(ISD::isSignedIntSetCC(Cond), RHS, SDLoc(RHS),
13945+
SmallVT);
13946+
SDValue NewSetCC =
13947+
DAG.getSetCC(DL, getSetCCResultType(SmallVT), LHS, RHS, Cond);
13948+
// Promote to a legal type for setcc, then adjust back to VT (if before
13949+
// LegalOperations)
13950+
return DAG.getZExtOrTrunc(
13951+
TLI.promoteTargetBoolean(DAG, NewSetCC, N0.getValueType()), DL, VT);
13952+
}
13953+
}
13954+
1392713955
return SDValue();
1392813956
}
1392913957

0 commit comments

Comments
 (0)