summaryrefslogtreecommitdiff
path: root/compiler/optimizing/nodes.cc
diff options
context:
space:
mode:
author Roland Levillain <rpl@google.com> 2014-09-18 16:07:18 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2014-09-18 16:07:19 +0000
commit53562d9a8fb210cf33a694f5e81f3d13ce3a8c48 (patch)
tree135561e5b98f0d5b9357acc707c13255e39a3332 /compiler/optimizing/nodes.cc
parentf67bda68a579a8ac79f9d8f889e0233a8f94da55 (diff)
parent556c3d193134f6461f3e1fe17c032b087c5931a0 (diff)
Merge "Initiate a constant propagation pass in the optimizing compiler."
Diffstat (limited to 'compiler/optimizing/nodes.cc')
-rw-r--r--compiler/optimizing/nodes.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc
index 06a55e8ed6..376d1af3ef 100644
--- a/compiler/optimizing/nodes.cc
+++ b/compiler/optimizing/nodes.cc
@@ -510,6 +510,18 @@ void HGraphVisitor::VisitBasicBlock(HBasicBlock* block) {
}
}
+HConstant* HBinaryOperation::TryStaticEvaluation(ArenaAllocator* allocator) const {
+ if (GetLeft()->IsIntConstant() && GetRight()->IsIntConstant()) {
+ int32_t value = Evaluate(GetLeft()->AsIntConstant()->GetValue(),
+ GetRight()->AsIntConstant()->GetValue());
+ return new(allocator) HIntConstant(value);
+ } else if (GetLeft()->IsLongConstant() && GetRight()->IsLongConstant()) {
+ int64_t value = Evaluate(GetLeft()->AsLongConstant()->GetValue(),
+ GetRight()->AsLongConstant()->GetValue());
+ return new(allocator) HLongConstant(value);
+ }
+ return nullptr;
+}
bool HCondition::NeedsMaterialization() const {
if (!HasOnlyOneUse()) {