llvm.org GIT mirror llvm / ef4fd35
trunc to bool no longer compares against zero git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35712 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 12 years ago
1 changed file(s) with 5 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
846846 static bool IsOnlyUsedInEqualsZeroComparison(Instruction *I) {
847847 for (Value::use_iterator UI = I->use_begin(), E = I->use_end();
848848 UI != E; ++UI) {
849 Instruction *User = cast(*UI);
850 if (ICmpInst *IC = dyn_cast(User)) {
851 if ((IC->getPredicate() == ICmpInst::ICMP_NE ||
852 IC->getPredicate() == ICmpInst::ICMP_EQ) &&
853 isa(IC->getOperand(1)) &&
854 cast(IC->getOperand(1))->isNullValue())
855 continue;
856 } else if (CastInst *CI = dyn_cast(User))
857 if (CI->getType() == Type::Int1Ty)
858 continue;
849 if (ICmpInst *IC = dyn_cast(*UI))
850 if (IC->isEquality())
851 if (Constant *C = dyn_cast(IC->getOperand(1)))
852 if (C->isNullValue())
853 continue;
859854 // Unknown instruction.
860855 return false;
861856 }