Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1508)

Unified Diff: runtime/vm/constant_propagator.cc

Issue 2423843002: Add DoubleTestOp instruction (Closed)
Patch Set: Cleanup Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/constant_propagator.cc
diff --git a/runtime/vm/constant_propagator.cc b/runtime/vm/constant_propagator.cc
index 1f5290dd6664924fac0670b65978b29a0766d424..2cd73bc9bb5b3010f68b16702e164fb0e12cf392 100644
--- a/runtime/vm/constant_propagator.cc
+++ b/runtime/vm/constant_propagator.cc
@@ -1168,6 +1168,27 @@ void ConstantPropagator::VisitBinaryDoubleOp(
}
+void ConstantPropagator::VisitDoubleTestOp(DoubleTestOpInstr* instr) {
+ const Object& value = instr->value()->definition()->constant_value();
+ if (value.IsInteger()) {
+ SetValue(instr, Bool::False());
+ } else if (IsIntegerOrDouble(value)) {
+ switch (instr->op_kind()) {
+ case MethodRecognizer::kDoubleIsNaN:
+ SetValue(instr, Bool::Get(isnan(ToDouble(value))));
+ break;
+ case MethodRecognizer::kDoubleIsInfinite:
+ SetValue(instr, Bool::Get(isinf(ToDouble(value))));
+ break;
+ default:
+ UNREACHABLE();
+ }
+ } else {
+ SetValue(instr, non_constant_);
+ }
+}
+
+
void ConstantPropagator::VisitBinaryFloat32x4Op(
BinaryFloat32x4OpInstr* instr) {
const Object& left = instr->left()->definition()->constant_value();

Powered by Google App Engine
This is Rietveld 408576698