summaryrefslogtreecommitdiff
path: root/compiler/optimizing/nodes.cc
diff options
context:
space:
mode:
author Roland Levillain <rpl@google.com> 2014-09-18 15:25:07 +0100
committer Roland Levillain <rpl@google.com> 2014-09-18 15:25:07 +0100
commit556c3d193134f6461f3e1fe17c032b087c5931a0 (patch)
tree436660c7155d0864c37f8aeabbc0f52e889a0cc2 /compiler/optimizing/nodes.cc
parent6aa606c9284ac31961f4c5b20c3645ac78acfaad (diff)
Initiate a constant propagation pass in the optimizing compiler.
- Perform constant folding on int and long additions and subtractions in the optimizing compiler. - Apply constant folding to conditions and comparisons. Change-Id: Ic88783a3c975fda777c74c531e257fa777be42eb
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 7b5a78eb39..82827952ba 100644
--- a/compiler/optimizing/nodes.cc
+++ b/compiler/optimizing/nodes.cc
@@ -505,6 +505,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()) {