The InReg parameter attribute is valid on function results. The llvm-gcc-4.0
[oota-llvm.git] / lib / Analysis / ScalarEvolutionExpander.cpp
index c8c683cb3f62e7fe68c64791d962af75b045ac9b..3e590d68f55eadebe090935570f560dd9b5649ba 100644 (file)
@@ -72,6 +72,11 @@ Value *SCEVExpander::InsertCastOfTo(Instruction::CastOps opcode, Value *V,
 /// of work to avoid inserting an obviously redundant operation.
 Value *SCEVExpander::InsertBinop(Instruction::BinaryOps Opcode, Value *LHS,
                                  Value *RHS, Instruction *&InsertPt) {
+  // Fold a binop with constant operands.
+  if (Constant *CLHS = dyn_cast<Constant>(LHS))
+    if (Constant *CRHS = dyn_cast<Constant>(RHS))
+      return ConstantExpr::get(Opcode, CLHS, CRHS);
+
   // Do a quick scan to see if we have this binop nearby.  If so, reuse it.
   unsigned ScanLimit = 6;
   for (BasicBlock::iterator IP = InsertPt, E = InsertPt->getParent()->begin();