[llvm-commits] CVS: llvm/lib/Analysis/ScalarEvolutionExpander.cpp

Dan Gohman djg at cray.com
Fri Jun 15 12:22:17 PDT 2007



Changes in directory llvm/lib/Analysis:

ScalarEvolutionExpander.cpp updated: 1.18 -> 1.19
---
Log message:

Fold a binary operator with constant operands when expanding code for a SCEV.


---
Diffs of the changes:  (+5 -0)

 ScalarEvolutionExpander.cpp |    5 +++++
 1 files changed, 5 insertions(+)


Index: llvm/lib/Analysis/ScalarEvolutionExpander.cpp
diff -u llvm/lib/Analysis/ScalarEvolutionExpander.cpp:1.18 llvm/lib/Analysis/ScalarEvolutionExpander.cpp:1.19
--- llvm/lib/Analysis/ScalarEvolutionExpander.cpp:1.18	Fri Jun 15 09:38:12 2007
+++ llvm/lib/Analysis/ScalarEvolutionExpander.cpp	Fri Jun 15 14:21:55 2007
@@ -72,6 +72,11 @@
 /// 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();






More information about the llvm-commits mailing list