Skip to content

Commit a0f4600

Browse files
committed
Rework be15dfa such that it works with GlobalISel which doesn't use EVT
Summary: be15dfa broke GlobalISel's usage of getSetCCInverse() which currently appears to be limited to our out-of-tree backend. GlobalISel doesn't use EVT's and isn't able to derive them from the information it has as it doesn't distinguish between integer and floating point types (that distinction is made by operations rather than values). Bring back the bool version of getSetCCInverse() in a way that doesn't break the intent of be15dfa but also allows GlobalISel to continue using it. Reviewers: spatel, bogner, arichardson Reviewed By: arichardson Subscribers: rovka, hiraditya, Petar.Avramovic, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D72309
1 parent 231875e commit a0f4600

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

llvm/include/llvm/CodeGen/ISDOpcodes.h

+10
Original file line numberDiff line numberDiff line change
@@ -1105,6 +1105,16 @@ namespace ISD {
11051105
/// SetCC operation.
11061106
CondCode getSetCCInverse(CondCode Operation, EVT Type);
11071107

1108+
namespace GlobalISel {
1109+
/// Return the operation corresponding to !(X op Y), where 'op' is a valid
1110+
/// SetCC operation. The U bit of the condition code has different meanings
1111+
/// between floating point and integer comparisons and LLT's don't provide
1112+
/// this distinction. As such we need to be told whether the comparison is
1113+
/// floating point or integer-like. Pointers should use integer-like
1114+
/// comparisons.
1115+
CondCode getSetCCInverse(CondCode Operation, bool isIntegerLike);
1116+
} // end namespace GlobalISel
1117+
11081118
/// Return the operation corresponding to (Y op X) when given the operation
11091119
/// for (X op Y).
11101120
CondCode getSetCCSwappedOperands(CondCode Operation);

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

+11-3
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,9 @@ ISD::CondCode ISD::getSetCCSwappedOperands(ISD::CondCode Operation) {
356356
(OldG << 2)); // New L bit.
357357
}
358358

359-
ISD::CondCode ISD::getSetCCInverse(ISD::CondCode Op, EVT Type) {
360-
bool IsInteger = Type.isInteger();
359+
static ISD::CondCode getSetCCInverseImpl(ISD::CondCode Op, bool isIntegerLike) {
361360
unsigned Operation = Op;
362-
if (IsInteger)
361+
if (isIntegerLike)
363362
Operation ^= 7; // Flip L, G, E bits, but not U.
364363
else
365364
Operation ^= 15; // Flip all of the condition bits.
@@ -370,6 +369,15 @@ ISD::CondCode ISD::getSetCCInverse(ISD::CondCode Op, EVT Type) {
370369
return ISD::CondCode(Operation);
371370
}
372371

372+
ISD::CondCode ISD::getSetCCInverse(ISD::CondCode Op, EVT Type) {
373+
return getSetCCInverseImpl(Op, Type.isInteger());
374+
}
375+
376+
ISD::CondCode ISD::GlobalISel::getSetCCInverse(ISD::CondCode Op,
377+
bool isIntegerLike) {
378+
return getSetCCInverseImpl(Op, isIntegerLike);
379+
}
380+
373381
/// For an integer comparison, return 1 if the comparison is a signed operation
374382
/// and 2 if the result is an unsigned comparison. Return zero if the operation
375383
/// does not depend on the sign of the input (setne and seteq).

0 commit comments

Comments
 (0)