trunc to bool no longer compares against zero
authorChris Lattner <sabre@nondot.org>
Sat, 7 Apr 2007 01:03:46 +0000 (01:03 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 7 Apr 2007 01:03:46 +0000 (01:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35712 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/IPO/SimplifyLibCalls.cpp

index f1552eeb8c2b3a3e7475f41c743af0e9dc52e330..96b5f3d77b5d72102954e4a63ebb1f3802ac6a92 100644 (file)
@@ -847,16 +847,11 @@ struct VISIBILITY_HIDDEN StrLenOptimization : public LibCallOptimization {
 static bool IsOnlyUsedInEqualsZeroComparison(Instruction *I) {
   for (Value::use_iterator UI = I->use_begin(), E = I->use_end();
        UI != E; ++UI) {
-    Instruction *User = cast<Instruction>(*UI);
-    if (ICmpInst *IC = dyn_cast<ICmpInst>(User)) {
-      if ((IC->getPredicate() == ICmpInst::ICMP_NE ||
-           IC->getPredicate() == ICmpInst::ICMP_EQ) &&
-          isa<Constant>(IC->getOperand(1)) &&
-          cast<Constant>(IC->getOperand(1))->isNullValue())
-        continue;
-    } else if (CastInst *CI = dyn_cast<CastInst>(User))
-      if (CI->getType() == Type::Int1Ty)
-        continue;
+    if (ICmpInst *IC = dyn_cast<ICmpInst>(*UI))
+      if (IC->isEquality())
+        if (Constant *C = dyn_cast<Constant>(IC->getOperand(1)))
+          if (C->isNullValue())
+            continue;
     // Unknown instruction.
     return false;
   }