[PATCH] D72309: Rework be15dfa88fb1 such that it works with GlobalISel which doesn't use EVT

Daniel Sanders via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 6 18:24:43 PST 2020


dsanders created this revision.
dsanders added reviewers: spatel, bogner, arichardson.
Herald added subscribers: Petar.Avramovic, hiraditya, rovka.
Herald added a project: LLVM.

be15dfa88fb1 <https://reviews.llvm.org/rGbe15dfa88fb1ed94d12f374797f98ede6808f809> 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 be15dfa88fb1 <https://reviews.llvm.org/rGbe15dfa88fb1ed94d12f374797f98ede6808f809> but also allows GlobalISel to continue using it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72309

Files:
  llvm/include/llvm/CodeGen/ISDOpcodes.h
  llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -356,16 +356,12 @@
                        (OldG << 2));       // New L bit.
 }
 
-ISD::CondCode ISD::getSetCCInverse(ISD::CondCode Op, EVT Type) {
-  bool IsInteger = Type.isInteger();
-  if (IsInteger)
-    return getSetCCInverseInt(Op);
-  return getSetCCInverseFloat(Op);
-}
-
-ISD::CondCode ISD::getSetCCInverseInt(ISD::CondCode Op) {
+static ISD::CondCode getSetCCInverseImpl(ISD::CondCode Op, bool isInteger) {
   unsigned Operation = Op;
-  Operation ^= 7; // Flip L, G, E bits, but not U.
+  if (isInteger)
+    Operation ^= 7;   // Flip L, G, E bits, but not U.
+  else
+    Operation ^= 15;  // Flip all of the condition bits.
 
   if (Operation > ISD::SETTRUE2)
     Operation &= ~8;  // Don't let N and U bits get set.
@@ -373,14 +369,13 @@
   return ISD::CondCode(Operation);
 }
 
-ISD::CondCode ISD::getSetCCInverseFloat(ISD::CondCode Op) {
-  unsigned Operation = Op;
-  Operation ^= 15; // Flip all of the condition bits.
-
-  if (Operation > ISD::SETTRUE2)
-    Operation &= ~8;  // Don't let N and U bits get set.
+ISD::CondCode ISD::getSetCCInverse(ISD::CondCode Op, EVT Type) {
+  return getSetCCInverseImpl(Op, Type.isInteger());
+}
 
-  return ISD::CondCode(Operation);
+ISD::CondCode ISD::GlobalISel::getSetCCInverse(ISD::CondCode Op,
+                                               bool isInteger) {
+  return getSetCCInverseImpl(Op, isInteger);
 }
 
 /// For an integer comparison, return 1 if the comparison is a signed operation
Index: llvm/include/llvm/CodeGen/ISDOpcodes.h
===================================================================
--- llvm/include/llvm/CodeGen/ISDOpcodes.h
+++ llvm/include/llvm/CodeGen/ISDOpcodes.h
@@ -1099,13 +1099,11 @@
   /// SetCC operation.
   CondCode getSetCCInverse(CondCode Operation, EVT Type);
 
-  /// Return the operation corresponding to !(X op Y), where 'op' is a valid
-  /// SetCC operation.
-  CondCode getSetCCInverseInt(CondCode Operation);
-
-  /// Return the operation corresponding to !(X op Y), where 'op' is a valid
-  /// SetCC operation.
-  CondCode getSetCCInverseFloat(CondCode Operation);
+  namespace GlobalISel {
+    /// Return the operation corresponding to !(X op Y), where 'op' is a valid
+    /// SetCC operation.
+    CondCode getSetCCInverse(CondCode Operation, bool isInteger);
+  } // end namespace GlobalISel
 
   /// Return the operation corresponding to (Y op X) when given the operation
   /// for (X op Y).


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72309.236488.patch
Type: text/x-patch
Size: 2639 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200107/464e035d/attachment.bin>


More information about the llvm-commits mailing list