diff --git a/llvm/include/llvm/CodeGen/ISDOpcodes.h b/llvm/include/llvm/CodeGen/ISDOpcodes.h --- a/llvm/include/llvm/CodeGen/ISDOpcodes.h +++ b/llvm/include/llvm/CodeGen/ISDOpcodes.h @@ -1099,6 +1099,16 @@ /// SetCC operation. CondCode getSetCCInverse(CondCode Operation, EVT Type); + namespace GlobalISel { + /// Return the operation corresponding to !(X op Y), where 'op' is a valid + /// SetCC operation. The U bit of the condition code has different meanings + /// between floating point and integer comparisons and LLT's don't provide + /// this distinction. As such we need to be told whether the comparison is + /// floating point or integer-like. Pointers should use integer-like + /// comparisons. + CondCode getSetCCInverse(CondCode Operation, bool isIntegerLike); + } // end namespace GlobalISel + /// Return the operation corresponding to (Y op X) when given the operation /// for (X op Y). CondCode getSetCCSwappedOperands(CondCode Operation); diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -356,10 +356,9 @@ (OldG << 2)); // New L bit. } -ISD::CondCode ISD::getSetCCInverse(ISD::CondCode Op, EVT Type) { - bool IsInteger = Type.isInteger(); +static ISD::CondCode getSetCCInverseImpl(ISD::CondCode Op, bool isIntegerLike) { unsigned Operation = Op; - if (IsInteger) + if (isIntegerLike) Operation ^= 7; // Flip L, G, E bits, but not U. else Operation ^= 15; // Flip all of the condition bits. @@ -370,6 +369,15 @@ return ISD::CondCode(Operation); } +ISD::CondCode ISD::getSetCCInverse(ISD::CondCode Op, EVT Type) { + return getSetCCInverseImpl(Op, Type.isInteger()); +} + +ISD::CondCode ISD::GlobalISel::getSetCCInverse(ISD::CondCode Op, + bool isIntegerLike) { + return getSetCCInverseImpl(Op, isIntegerLike); +} + /// For an integer comparison, return 1 if the comparison is a signed operation /// and 2 if the result is an unsigned comparison. Return zero if the operation /// does not depend on the sign of the input (setne and seteq).