From d4a9866520a75f59e24f101f84c3dbb1db22132c Mon Sep 17 00:00:00 2001 From: Alexander Aprelev Date: Mon, 4 Mar 2024 19:50:49 +0000 Subject: [PATCH] [vm] Fix representation for constant used for ShiftLeft binary op. The constant has to be boxed value, can't be unboxed. Fixes=dartbug.com/55003 TEST=regress_55003_test Change-Id: Ia4d61364f54f8a08a0fe621cc1b4fb5597b1836e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/355304 Commit-Queue: Alexander Aprelev Reviewed-by: Ryan Macnak --- runtime/tests/vm/dart/regress_55003_test.dart | 17 +++++++++++++++++ runtime/vm/compiler/backend/il.cc | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 runtime/tests/vm/dart/regress_55003_test.dart diff --git a/runtime/tests/vm/dart/regress_55003_test.dart b/runtime/tests/vm/dart/regress_55003_test.dart new file mode 100644 index 00000000000..3fe810ef6f8 --- /dev/null +++ b/runtime/tests/vm/dart/regress_55003_test.dart @@ -0,0 +1,17 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +int var64 = -1; +num var68 = 2; + +@pragma("vm:always-consider-inlining") +Set? foo0_1() { + return { + (8 <= (((var64 + -90) * 9223372034707292160) % var68)), + }; +} + +main() { + foo0_1(); +} diff --git a/runtime/vm/compiler/backend/il.cc b/runtime/vm/compiler/backend/il.cc index d3be1c5507d..59ca02cfcae 100644 --- a/runtime/vm/compiler/backend/il.cc +++ b/runtime/vm/compiler/backend/il.cc @@ -2443,7 +2443,7 @@ Definition* BinaryIntegerOpInstr::Canonicalize(FlowGraph* flow_graph) { } else if ((rhs > 0) && Utils::IsPowerOfTwo(rhs)) { const int64_t shift_amount = Utils::ShiftForPowerOfTwo(rhs); ConstantInstr* constant_shift_amount = flow_graph->GetConstant( - Smi::Handle(Smi::New(shift_amount)), representation()); + Smi::Handle(Smi::New(shift_amount)), kTagged); BinaryIntegerOpInstr* shift = BinaryIntegerOpInstr::Make( representation(), Token::kSHL, left()->CopyWithType(), new Value(constant_shift_amount), GetDeoptId(), can_overflow(),