- instcombine (~(a < b)) into (a >= b)
authorChris Lattner <sabre@nondot.org>
Tue, 20 Aug 2002 18:24:26 +0000 (18:24 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 20 Aug 2002 18:24:26 +0000 (18:24 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3406 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp

index 71c2cc6e3f56fb8ffcf885b63e61f17071e4905b..30e143dec46ca3f43f0aa72f350e6909d205198a 100644 (file)
@@ -328,10 +328,18 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
     if (Op1C->isNullValue())
       return ReplaceInstUsesWith(I, Op0);
 
-    // xor (xor X, -1), -1 = not (not X) = X
-    if (Op1C->isAllOnesValue())
+    // Is this a "NOT" instruction?
+    if (Op1C->isAllOnesValue()) {
+      // xor (xor X, -1), -1 = not (not X) = X
       if (Value *X = dyn_castNotInst(Op0))
         return ReplaceInstUsesWith(I, X);
+
+      // xor (setcc A, B), true = not (setcc A, B) = setncc A, B
+      if (SetCondInst *SCI = dyn_cast<SetCondInst>(Op0))
+        if (SCI->use_size() == 1)
+          return new SetCondInst(SCI->getInverseCondition(),
+                                 SCI->getOperand(0), SCI->getOperand(1));
+    }
   }
 
   return Changed ? &I : 0;