[llvm-commits] [llvm] r119038 - in /llvm/trunk: include/llvm/Analysis/InstructionSimplify.h lib/Analysis/InstructionSimplify.cpp

Duncan Sands baldrick at free.fr
Sun Nov 14 03:23:23 PST 2010


Author: baldrick
Date: Sun Nov 14 05:23:23 2010
New Revision: 119038

URL: http://llvm.org/viewvc/llvm-project?rev=119038&view=rev
Log:
Strip trailing whitespace.

Modified:
    llvm/trunk/include/llvm/Analysis/InstructionSimplify.h
    llvm/trunk/lib/Analysis/InstructionSimplify.cpp

Modified: llvm/trunk/include/llvm/Analysis/InstructionSimplify.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/InstructionSimplify.h?rev=119038&r1=119037&r2=119038&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/InstructionSimplify.h (original)
+++ llvm/trunk/include/llvm/Analysis/InstructionSimplify.h Sun Nov 14 05:23:23 2010
@@ -25,7 +25,7 @@
   /// fold the result.  If not, this returns null.
   Value *SimplifyAddInst(Value *LHS, Value *RHS, bool isNSW, bool isNUW,
                          const TargetData *TD = 0);
-  
+
   /// SimplifyAndInst - Given operands for an And, see if we can
   /// fold the result.  If not, this returns null.
   Value *SimplifyAndInst(Value *LHS, Value *RHS,
@@ -35,17 +35,17 @@
   /// fold the result.  If not, this returns null.
   Value *SimplifyOrInst(Value *LHS, Value *RHS,
                         const TargetData *TD = 0);
-  
+
   /// SimplifyICmpInst - Given operands for an ICmpInst, see if we can
   /// fold the result.  If not, this returns null.
   Value *SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS,
                           const TargetData *TD = 0);
-  
+
   /// SimplifyFCmpInst - Given operands for an FCmpInst, see if we can
   /// fold the result.  If not, this returns null.
   Value *SimplifyFCmpInst(unsigned Predicate, Value *LHS, Value *RHS,
                           const TargetData *TD = 0);
-  
+
   /// SimplifySelectInst - Given operands for a SelectInst, see if we can fold
   /// the result.  If not, this returns null.
   Value *SimplifySelectInst(Value *Cond, Value *TrueVal, Value *FalseVal,
@@ -55,27 +55,27 @@
   /// fold the result.  If not, this returns null.
   Value *SimplifyGEPInst(Value * const *Ops, unsigned NumOps,
                          const TargetData *TD = 0);
-  
+
   //=== Helper functions for higher up the class hierarchy.
-  
-  
+
+
   /// SimplifyCmpInst - Given operands for a CmpInst, see if we can
   /// fold the result.  If not, this returns null.
   Value *SimplifyCmpInst(unsigned Predicate, Value *LHS, Value *RHS,
                          const TargetData *TD = 0);
-  
+
   /// SimplifyBinOp - Given operands for a BinaryOperator, see if we can
   /// fold the result.  If not, this returns null.
-  Value *SimplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS, 
+  Value *SimplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS,
                        const TargetData *TD = 0);
-  
+
   /// SimplifyInstruction - See if we can compute a simplified version of this
   /// instruction.  If not, this returns null.
   /// WARNING: If called on unreachable code, an instruction may be reported
   /// to simplify to itself.
   Value *SimplifyInstruction(Instruction *I, const TargetData *TD = 0);
-  
-  
+
+
   /// ReplaceAndSimplifyAllUses - Perform From->replaceAllUsesWith(To) and then
   /// delete the From instruction.  In addition to a basic RAUW, this does a
   /// recursive simplification of the updated instructions.  This catches

Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=119038&r1=119037&r2=119038&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original)
+++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Sun Nov 14 05:23:23 2010
@@ -194,21 +194,21 @@
       return ConstantFoldInstOperands(Instruction::Add, CLHS->getType(),
                                       Ops, 2, TD);
     }
-    
+
     // Canonicalize the constant to the RHS.
     std::swap(Op0, Op1);
   }
-  
+
   if (Constant *Op1C = dyn_cast<Constant>(Op1)) {
     // X + undef -> undef
     if (isa<UndefValue>(Op1C))
       return Op1C;
-    
+
     // X + 0 --> X
     if (Op1C->isNullValue())
       return Op0;
   }
-  
+
   // FIXME: Could pull several more out of instcombine.
   return 0;
 }
@@ -223,28 +223,28 @@
       return ConstantFoldInstOperands(Instruction::And, CLHS->getType(),
                                       Ops, 2, TD);
     }
-  
+
     // Canonicalize the constant to the RHS.
     std::swap(Op0, Op1);
   }
-  
+
   // X & undef -> 0
   if (isa<UndefValue>(Op1))
     return Constant::getNullValue(Op0->getType());
-  
+
   // X & X = X
   if (Op0 == Op1)
     return Op0;
-  
+
   // X & <0,0> = <0,0>
   if (isa<ConstantAggregateZero>(Op1))
     return Op1;
-  
+
   // X & <-1,-1> = X
   if (ConstantVector *CP = dyn_cast<ConstantVector>(Op1))
     if (CP->isAllOnesValue())
       return Op0;
-  
+
   if (ConstantInt *Op1CI = dyn_cast<ConstantInt>(Op1)) {
     // X & 0 = 0
     if (Op1CI->isZero())
@@ -253,23 +253,23 @@
     if (Op1CI->isAllOnesValue())
       return Op0;
   }
-  
+
   // A & ~A  =  ~A & A  =  0
   Value *A, *B;
   if ((match(Op0, m_Not(m_Value(A))) && A == Op1) ||
       (match(Op1, m_Not(m_Value(A))) && A == Op0))
     return Constant::getNullValue(Op0->getType());
-  
+
   // (A | ?) & A = A
   if (match(Op0, m_Or(m_Value(A), m_Value(B))) &&
       (A == Op1 || B == Op1))
     return Op1;
-  
+
   // A & (A | ?) = A
   if (match(Op1, m_Or(m_Value(A), m_Value(B))) &&
       (A == Op0 || B == Op0))
     return Op0;
-  
+
   // (A & B) & A -> A & B
   if (match(Op0, m_And(m_Value(A), m_Value(B))) &&
       (A == Op1 || B == Op1))
@@ -311,15 +311,15 @@
       return ConstantFoldInstOperands(Instruction::Or, CLHS->getType(),
                                       Ops, 2, TD);
     }
-    
+
     // Canonicalize the constant to the RHS.
     std::swap(Op0, Op1);
   }
-  
+
   // X | undef -> -1
   if (isa<UndefValue>(Op1))
     return Constant::getAllOnesValue(Op0->getType());
-  
+
   // X | X = X
   if (Op0 == Op1)
     return Op0;
@@ -327,12 +327,12 @@
   // X | <0,0> = X
   if (isa<ConstantAggregateZero>(Op1))
     return Op0;
-  
+
   // X | <-1,-1> = <-1,-1>
   if (ConstantVector *CP = dyn_cast<ConstantVector>(Op1))
-    if (CP->isAllOnesValue())            
+    if (CP->isAllOnesValue())
       return Op1;
-  
+
   if (ConstantInt *Op1CI = dyn_cast<ConstantInt>(Op1)) {
     // X | 0 = X
     if (Op1CI->isZero())
@@ -341,23 +341,23 @@
     if (Op1CI->isAllOnesValue())
       return Op1CI;
   }
-  
+
   // A | ~A  =  ~A | A  =  -1
   Value *A, *B;
   if ((match(Op0, m_Not(m_Value(A))) && A == Op1) ||
       (match(Op1, m_Not(m_Value(A))) && A == Op0))
     return Constant::getAllOnesValue(Op0->getType());
-  
+
   // (A & ?) | A = A
   if (match(Op0, m_And(m_Value(A), m_Value(B))) &&
       (A == Op1 || B == Op1))
     return Op1;
-  
+
   // A | (A & ?) = A
   if (match(Op1, m_And(m_Value(A), m_Value(B))) &&
       (A == Op0 || B == Op0))
     return Op0;
-  
+
   // (A | B) | A -> A | B
   if (match(Op0, m_Or(m_Value(A), m_Value(B))) &&
       (A == Op1 || B == Op1))
@@ -399,7 +399,7 @@
                                const TargetData *TD, unsigned MaxRecurse) {
   CmpInst::Predicate Pred = (CmpInst::Predicate)Predicate;
   assert(CmpInst::isIntPredicate(Pred) && "Not an integer compare!");
-  
+
   if (Constant *CLHS = dyn_cast<Constant>(LHS)) {
     if (Constant *CRHS = dyn_cast<Constant>(RHS))
       return ConstantFoldCompareInstOperands(Pred, CLHS, CRHS, TD);
@@ -408,24 +408,24 @@
     std::swap(LHS, RHS);
     Pred = CmpInst::getSwappedPredicate(Pred);
   }
-  
+
   // ITy - This is the return type of the compare we're considering.
   const Type *ITy = GetCompareTy(LHS);
-  
+
   // icmp X, X -> true/false
   // X icmp undef -> true/false.  For example, icmp ugt %X, undef -> false
   // because X could be 0.
   if (LHS == RHS || isa<UndefValue>(RHS))
     return ConstantInt::get(ITy, CmpInst::isTrueWhenEqual(Pred));
-  
+
   // icmp <global/alloca*/null>, <global/alloca*/null> - Global/Stack value
   // addresses never equal each other!  We already know that Op0 != Op1.
-  if ((isa<GlobalValue>(LHS) || isa<AllocaInst>(LHS) || 
+  if ((isa<GlobalValue>(LHS) || isa<AllocaInst>(LHS) ||
        isa<ConstantPointerNull>(LHS)) &&
-      (isa<GlobalValue>(RHS) || isa<AllocaInst>(RHS) || 
+      (isa<GlobalValue>(RHS) || isa<AllocaInst>(RHS) ||
        isa<ConstantPointerNull>(RHS)))
     return ConstantInt::get(ITy, CmpInst::isFalseWhenEqual(Pred));
-  
+
   // See if we are doing a comparison with a constant.
   if (ConstantInt *CI = dyn_cast<ConstantInt>(RHS)) {
     // If we have an icmp le or icmp ge instruction, turn it into the
@@ -482,12 +482,12 @@
   if (Constant *CLHS = dyn_cast<Constant>(LHS)) {
     if (Constant *CRHS = dyn_cast<Constant>(RHS))
       return ConstantFoldCompareInstOperands(Pred, CLHS, CRHS, TD);
-   
+
     // If we have a constant, make sure it is on the RHS.
     std::swap(LHS, RHS);
     Pred = CmpInst::getSwappedPredicate(Pred);
   }
-  
+
   // Fold trivial predicates.
   if (Pred == FCmpInst::FCMP_FALSE)
     return ConstantInt::get(GetCompareTy(LHS), 0);
@@ -504,7 +504,7 @@
     if (CmpInst::isFalseWhenEqual(Pred))
       return ConstantInt::get(GetCompareTy(LHS), 0);
   }
-  
+
   // Handle fcmp with constant RHS
   if (Constant *RHSC = dyn_cast<Constant>(RHS)) {
     // If the constant is a nan, see if we can fold the comparison based on it.
@@ -545,7 +545,7 @@
       }
     }
   }
-  
+
   // If the comparison is with the result of a select instruction, check whether
   // comparing with either branch of the select always yields the same value.
   if (MaxRecurse && (isa<SelectInst>(LHS) || isa<SelectInst>(RHS)))
@@ -574,11 +574,11 @@
   // select false, X, Y -> Y
   if (ConstantInt *CB = dyn_cast<ConstantInt>(CondVal))
     return CB->getZExtValue() ? TrueVal : FalseVal;
-  
+
   // select C, X, X -> X
   if (TrueVal == FalseVal)
     return TrueVal;
-  
+
   if (isa<UndefValue>(TrueVal))   // select C, undef, X -> X
     return FalseVal;
   if (isa<UndefValue>(FalseVal))   // select C, X, undef -> X
@@ -588,7 +588,7 @@
       return TrueVal;
     return FalseVal;
   }
-  
+
   return 0;
 }
 
@@ -610,12 +610,12 @@
     if (ConstantInt *C = dyn_cast<ConstantInt>(Ops[1]))
       if (C->isZero())
         return Ops[0];
-  
+
   // Check to see if this is constant foldable.
   for (unsigned i = 0; i != NumOps; ++i)
     if (!isa<Constant>(Ops[i]))
       return 0;
-  
+
   return ConstantExpr::getGetElementPtr(cast<Constant>(Ops[0]),
                                         (Constant *const*)Ops+1, NumOps-1);
 }
@@ -653,7 +653,7 @@
   }
 }
 
-Value *llvm::SimplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS, 
+Value *llvm::SimplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS,
                            const TargetData *TD) {
   return ::SimplifyBinOp(Opcode, LHS, RHS, TD, MaxRecursionDepth);
 }
@@ -711,13 +711,13 @@
 void llvm::ReplaceAndSimplifyAllUses(Instruction *From, Value *To,
                                      const TargetData *TD) {
   assert(From != To && "ReplaceAndSimplifyAllUses(X,X) is not valid!");
-  
+
   // FromHandle/ToHandle - This keeps a WeakVH on the from/to values so that
   // we can know if it gets deleted out from under us or replaced in a
   // recursive simplification.
   WeakVH FromHandle(From);
   WeakVH ToHandle(To);
-  
+
   while (!From->use_empty()) {
     // Update the instruction to use the new value.
     Use &TheUse = From->use_begin().getUse();
@@ -732,27 +732,26 @@
       // Sanity check to make sure 'User' doesn't dangle across
       // SimplifyInstruction.
       AssertingVH<> UserHandle(User);
-    
+
       SimplifiedVal = SimplifyInstruction(User, TD);
       if (SimplifiedVal == 0) continue;
     }
-    
+
     // Recursively simplify this user to the new value.
     ReplaceAndSimplifyAllUses(User, SimplifiedVal, TD);
     From = dyn_cast_or_null<Instruction>((Value*)FromHandle);
     To = ToHandle;
-      
+
     assert(ToHandle && "To value deleted by recursive simplification?");
-      
+
     // If the recursive simplification ended up revisiting and deleting
     // 'From' then we're done.
     if (From == 0)
       return;
   }
-  
+
   // If 'From' has value handles referring to it, do a real RAUW to update them.
   From->replaceAllUsesWith(To);
-  
+
   From->eraseFromParent();
 }
-





More information about the llvm-commits mailing list