diff options
author | Chris Lattner <sabre@nondot.org> | 2010-01-05 07:04:23 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-01-05 07:04:23 +0000 |
commit | 248a84beb3c7f43c2bc394ff8b2ed472573f6e2b (patch) | |
tree | b586bad5f24f4218ec5662edb6195ee994b553bf | |
parent | dea34da6f8e88d52746c00e55dc0b32b93f8a2b1 (diff) | |
download | external_llvm-248a84beb3c7f43c2bc394ff8b2ed472573f6e2b.zip external_llvm-248a84beb3c7f43c2bc394ff8b2ed472573f6e2b.tar.gz external_llvm-248a84beb3c7f43c2bc394ff8b2ed472573f6e2b.tar.bz2 |
all the places we use hasOneUse() we know are instructions, so inline
and simplify.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92700 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Transforms/InstCombine/InstructionCombining.cpp | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/lib/Transforms/InstCombine/InstructionCombining.cpp b/lib/Transforms/InstCombine/InstructionCombining.cpp index ca311dd..ee037a8 100644 --- a/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -77,14 +77,8 @@ void InstCombiner::getAnalysisUsage(AnalysisUsage &AU) const { } -// isOnlyUse - Return true if this instruction will be deleted if we stop using -// it. -static bool isOnlyUse(Value *V) { - return V->hasOneUse() || isa<Constant>(V); -} - // getPromotedType - Return the specified type promoted as it would be to pass -// though a va_arg area... +// though a va_arg area. static const Type *getPromotedType(const Type *Ty) { if (const IntegerType* ITy = dyn_cast<IntegerType>(Ty)) { if (ITy->getBitWidth() < 32) @@ -152,6 +146,7 @@ bool InstCombiner::SimplifyCommutative(BinaryOperator &I) { Changed = !I.swapOperands(); if (!I.isAssociative()) return Changed; + Instruction::BinaryOps Opcode = I.getOpcode(); if (BinaryOperator *Op = dyn_cast<BinaryOperator>(I.getOperand(0))) if (Op->getOpcode() == Opcode && isa<Constant>(Op->getOperand(1))) { @@ -162,9 +157,11 @@ bool InstCombiner::SimplifyCommutative(BinaryOperator &I) { I.setOperand(0, Op->getOperand(0)); I.setOperand(1, Folded); return true; - } else if (BinaryOperator *Op1=dyn_cast<BinaryOperator>(I.getOperand(1))) + } + + if (BinaryOperator *Op1 = dyn_cast<BinaryOperator>(I.getOperand(1))) if (Op1->getOpcode() == Opcode && isa<Constant>(Op1->getOperand(1)) && - isOnlyUse(Op) && isOnlyUse(Op1)) { + Op->hasOneUse() && Op1->hasOneUse()) { Constant *C1 = cast<Constant>(Op->getOperand(1)); Constant *C2 = cast<Constant>(Op1->getOperand(1)); @@ -2555,7 +2552,7 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) { ConstantInt *C1 = 0; Value *X = 0; // (X & C1) | C2 --> (X | C2) & (C1|C2) if (match(Op0, m_And(m_Value(X), m_ConstantInt(C1))) && - isOnlyUse(Op0)) { + Op0->hasOneUse()) { Value *Or = Builder->CreateOr(X, RHS); Or->takeName(Op0); return BinaryOperator::CreateAnd(Or, @@ -2565,7 +2562,7 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) { // (X ^ C1) | C2 --> (X | C2) ^ (C1&~C2) if (match(Op0, m_Xor(m_Value(X), m_ConstantInt(C1))) && - isOnlyUse(Op0)) { + Op0->hasOneUse()) { Value *Or = Builder->CreateOr(X, RHS); Or->takeName(Op0); return BinaryOperator::CreateXor(Or, @@ -2665,7 +2662,7 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) { // Check to see if we have any common things being and'ed. If so, find the // terms for V1 & (V2|V3). - if (isOnlyUse(Op0) || isOnlyUse(Op1)) { + if (Op0->hasOneUse() || Op1->hasOneUse()) { V1 = 0; if (A == B) // (A & C)|(A & D) == A & (C|D) V1 = A, V2 = C, V3 = D; |