Skip to content

Commit 7a8fe0f

Browse files
authored
[SelectionDAG] Fixup type usage of CondCodeAction table (#116082)
Ensure that all uses of CondCodeAction table are checking the compared types, not the produced type. This is a prerequisite to landing #115035
1 parent 0dcb0ac commit 7a8fe0f

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

llvm/include/llvm/CodeGen/TargetLowering.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,13 +1618,14 @@ class TargetLoweringBase {
16181618
return Action;
16191619
}
16201620

1621-
/// Return true if the specified condition code is legal on this target.
1621+
/// Return true if the specified condition code is legal for a comparison of
1622+
/// the specified types on this target.
16221623
bool isCondCodeLegal(ISD::CondCode CC, MVT VT) const {
16231624
return getCondCodeAction(CC, VT) == Legal;
16241625
}
16251626

1626-
/// Return true if the specified condition code is legal or custom on this
1627-
/// target.
1627+
/// Return true if the specified condition code is legal or custom for a
1628+
/// comparison of the specified types on this target.
16281629
bool isCondCodeLegalOrCustom(ISD::CondCode CC, MVT VT) const {
16291630
return getCondCodeAction(CC, VT) == Legal ||
16301631
getCondCodeAction(CC, VT) == Custom;

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4975,7 +4975,7 @@ SDValue TargetLowering::SimplifySetCC(EVT VT, SDValue N0, SDValue N1,
49754975
APInt C = C1 - 1;
49764976
ISD::CondCode NewCC = (Cond == ISD::SETGE) ? ISD::SETGT : ISD::SETUGT;
49774977
if ((DCI.isBeforeLegalizeOps() ||
4978-
isCondCodeLegal(NewCC, VT.getSimpleVT())) &&
4978+
isCondCodeLegal(NewCC, OpVT.getSimpleVT())) &&
49794979
(!N1C->isOpaque() || (C.getBitWidth() <= 64 &&
49804980
isLegalICmpImmediate(C.getSExtValue())))) {
49814981
return DAG.getSetCC(dl, VT, N0,
@@ -4995,7 +4995,7 @@ SDValue TargetLowering::SimplifySetCC(EVT VT, SDValue N0, SDValue N1,
49954995
APInt C = C1 + 1;
49964996
ISD::CondCode NewCC = (Cond == ISD::SETLE) ? ISD::SETLT : ISD::SETULT;
49974997
if ((DCI.isBeforeLegalizeOps() ||
4998-
isCondCodeLegal(NewCC, VT.getSimpleVT())) &&
4998+
isCondCodeLegal(NewCC, OpVT.getSimpleVT())) &&
49994999
(!N1C->isOpaque() || (C.getBitWidth() <= 64 &&
50005000
isLegalICmpImmediate(C.getSExtValue())))) {
50015001
return DAG.getSetCC(dl, VT, N0,

0 commit comments

Comments
 (0)