summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/ScalarEvolutionExpander.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2007-06-15 19:21:55 +0000
committerDan Gohman <gohman@apple.com>2007-06-15 19:21:55 +0000
commit00cb117b079047b70ff4a46263f39635caacf51d (patch)
tree1d2d436428a9f5cbc93615dabe1c283798aca0f7 /llvm/lib/Analysis/ScalarEvolutionExpander.cpp
parentf852e339b6221a48faa198055f7833ace157c89d (diff)
downloadbcm5719-llvm-00cb117b079047b70ff4a46263f39635caacf51d.tar.gz
bcm5719-llvm-00cb117b079047b70ff4a46263f39635caacf51d.zip
Fold a binary operator with constant operands when expanding code for a SCEV.
llvm-svn: 37602
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolutionExpander.cpp')
-rw-r--r--llvm/lib/Analysis/ScalarEvolutionExpander.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp b/llvm/lib/Analysis/ScalarEvolutionExpander.cpp
index c8c683cb3f6..3e590d68f55 100644
--- a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp
+++ b/llvm/lib/Analysis/ScalarEvolutionExpander.cpp
@@ -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();
OpenPOWER on IntegriCloud