Add new SetCondInst::getInverseCondition() method.
authorChris Lattner <sabre@nondot.org>
Tue, 20 Aug 2002 18:17:12 +0000 (18:17 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 20 Aug 2002 18:17:12 +0000 (18:17 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3405 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/iOperators.cpp

index d243dbc1fa4fca861ea3d69579a352265f57e32b..ba5aca13012ce212d4ca1a0e3ed0329aad6762b1 100644 (file)
@@ -122,3 +122,19 @@ SetCondInst::SetCondInst(BinaryOps opType, Value *S1, Value *S2,
   // Make sure it's a valid type...
   assert(getOpcodeName() != 0);
 }
+
+// getInverseCondition - Return the inverse of the current condition opcode.
+// For example seteq -> setne, setgt -> setle, setlt -> setge, etc...
+//
+Instruction::BinaryOps SetCondInst::getInverseCondition() const {
+  switch (getOpcode()) {
+  default:
+    assert(0 && "Unknown setcc opcode!");
+  case SetEQ: return SetNE;
+  case SetNE: return SetEQ;
+  case SetGT: return SetLE;
+  case SetLT: return SetGE;
+  case SetGE: return SetLT;
+  case SetLE: return SetGT;
+  }
+}