//===- Reassociate.cpp - Reassociate binary expressions -------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
//
// This pass reassociates commutative expressions in an order that is designed
// to promote better constant propagation, GCSE, LICM, PRE...
// for PHI nodes, we cannot have infinite recursion here, because there
// cannot be loops in the value graph that do not go through PHI nodes.
//
- if (I->getOpcode() == Instruction::PHINode ||
+ if (I->getOpcode() == Instruction::PHI ||
I->getOpcode() == Instruction::Alloca ||
I->getOpcode() == Instruction::Malloc || isa<TerminatorInst>(I) ||
I->mayWriteToMemory()) // Cannot move inst if it writes to memory!
// only expression using it...
//
if (BinaryOperator *LHSI = dyn_cast<BinaryOperator>(LHS))
- if (LHSI->getOpcode() == I->getOpcode() && LHSI->use_size() == 1) {
+ if (LHSI->getOpcode() == I->getOpcode() && LHSI->hasOneUse()) {
// If the rank of our current RHS is less than the rank of the LHS's LHS,
// then we reassociate the two instructions...
// we introduce tons of unnecessary negation instructions...
//
if (Instruction *I = dyn_cast<Instruction>(V))
- if (I->getOpcode() == Instruction::Add && I->use_size() == 1) {
+ if (I->getOpcode() == Instruction::Add && I->hasOneUse()) {
Value *RHS = NegateValue(I->getOperand(1), BI);
Value *LHS = NegateValue(I->getOperand(0), BI);
Instruction *RHSI = dyn_cast<Instruction>(I->getOperand(1));
if (LHSI && (int)LHSI->getOpcode() == I->getOpcode() &&
RHSI && (int)RHSI->getOpcode() == I->getOpcode() &&
- RHSI->use_size() == 1) {
+ RHSI->hasOneUse()) {
// Insert a new temporary instruction... (A+B)+C
BinaryOperator *Tmp = BinaryOperator::create(I->getOpcode(), LHSI,
RHSI->getOperand(0),