diff -wu include/llvm/Analysis/ConstantFolding.h include/llvm/Analysis/ConstantFolding.h --- include/llvm/Analysis/ConstantFolding.h (working copy) +++ include/llvm/Analysis/ConstantFolding.h (working copy) @@ -31,13 +31,11 @@ /// Constant *ConstantFoldInstruction(Instruction *I, const TargetData *TD = 0); -/// SimplifyInstruction - Behaves just as ConstantFoldInstruction if the -/// Instruction has all Constant operands. -/// Otherwise attempt to do simplifications that don't necesarely result in -/// a Constant result, but is simpler than the Instruction I +/// SimplifyInstruction - Attempt to do simplifications that don't necessarily +/// results in a Constant result, but is simpler than the Instruction I /// (such as returning X for add X, 0). -/// In case of BinOps, it can also return an identical instruction that is -/// before the current one, in the same Basic Block. +/// It first tries to constant fold using ConstantFoldInstruction, and only if +/// that failed attempts to apply the simplifications. Value *SimplifyInstruction(Instruction *I, const TargetData *TD = 0); /// ConstantFoldConstantExpression - Attempt to fold the constant expression diff -wu include/llvm/Support/ConstantFolder.h include/llvm/Support/ConstantFolder.h --- include/llvm/Support/ConstantFolder.h (working copy) +++ include/llvm/Support/ConstantFolder.h (working copy) @@ -37,9 +37,6 @@ unsigned maxUses = 8; // Maximum number of uses to inspect // Loop over all uses of operand to find an identical binop, with // same operands. - // There should be less uses than instructions in a BB, so this should be - // faster than iterating over all instructions in BB, and we limit the - // number of uses to inspect. for (Value::use_iterator i = LRHS->use_begin(), e = LRHS->use_end(); i != e && maxUses; ++i, --maxUses) { Instruction *UI = dyn_cast(i); diff -wu include/llvm/Support/IRBuilder.h include/llvm/Support/IRBuilder.h --- include/llvm/Support/IRBuilder.h (working copy) +++ include/llvm/Support/IRBuilder.h (working copy) @@ -38,9 +38,9 @@ /// final instruction output. This defaults to on. The second template argument /// specifies a class to use for creating constants. This defaults to creating /// minimally folded constants. -/// If you specify reuseOps, it will try to reuse binops already inserted. Only +/// If you specify reuseOps, it will try to reuse Binops already inserted. Only /// use this if you don't mutate/RAUW instructions after creating them. -/// If you move the insertion point backwards reuseOps will temporarely be +/// If you move the insertion point backwards reuseOps will temporarily be /// disabled until you move it to the end of the BB again. template class IRBuilder { @@ -48,7 +48,7 @@ BasicBlock::iterator InsertPt; T Folder; - // Returns the BB to search for an instruction to reuse, + // Returns the BB in which to search for an instruction to reuse, // or NULL if this is not desired. const BasicBlock *getReuse() const { diff -wu include/llvm/Support/TargetFolder.h include/llvm/Support/TargetFolder.h --- include/llvm/Support/TargetFolder.h (working copy) +++ include/llvm/Support/TargetFolder.h (working copy) @@ -44,7 +44,7 @@ // Binary Operators //===--------------------------------------------------------------------===// - inline Value *CreateBinOp(Instruction::BinaryOps Opc, Value *LHS, Value *RHS, + Value *CreateBinOp(Instruction::BinaryOps Opc, Value *LHS, Value *RHS, const BasicBlock *BB) const { Constant *LC = dyn_cast(LHS); Constant *RC = dyn_cast(RHS); @@ -58,7 +58,7 @@ // Unary Operators //===--------------------------------------------------------------------===// - inline Value *CreateNeg(Value *V, const BasicBlock *BB) const { + Value *CreateNeg(Value *V, const BasicBlock *BB) const { if (Constant *C = dyn_cast(V)) return Fold(ConstantExpr::getNeg(C)); if (BB) { @@ -69,7 +69,7 @@ return 0; } - inline Value *CreateNot(Value *V, const BasicBlock *BB) const { + Value *CreateNot(Value *V, const BasicBlock *BB) const { if (Constant *C = dyn_cast(V)) return Fold(ConstantExpr::getNot(C)); if (BB) {