bool visitICmpInst(ICmpInst& inst) { // errs() << "got icmp instruction! " << inst << '\n'; bool changed = false; if (inst.getPredicate() == CmpInst::ICMP_EQ) { assert(inst.getNumOperands() == 2); if (inst.getOperand(1) == processing) { inst.swapOperands(); changed = true; any_changes = true; } assert(dyn_cast<Instruction>(inst.getOperand(0)) == processing); Value* other = inst.getOperand(1); if (isa<ConstantPointerNull>(other)) { if (VERBOSITY("opt") >= 2) { errs() << inst << '\n'; errs() << "replacing with false!\n"; } Value* new_value = ConstantInt::getFalse(other->getContext()); inst.replaceAllUsesWith(new_value); inst.eraseFromParent(); changed = true; any_changes = true; } } return changed; }