From 613bf61d37a725bc4fc5f78fa2c3ce089a9b560c Mon Sep 17 00:00:00 2001 From: duanfuchen Date: Wed, 19 Jul 2023 10:34:50 +0800 Subject: [PATCH] Bugfix for Float64 Divided zero. Remove Float64RightIsZeroCheck. Issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I7M88W?from=project-issue Change-Id: Ia1276d059839a9c5f2559ca42f5b92061030ea1c Signed-off-by: duanfuchen --- .../compiler/number_speculative_lowering.cpp | 1 - test/aottest/float64divzero/BUILD.gn | 18 +++++++++++++ test/aottest/float64divzero/expect_output.txt | 17 ++++++++++++ test/aottest/float64divzero/float64divzero.ts | 26 +++++++++++++++++++ 4 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 test/aottest/float64divzero/BUILD.gn create mode 100644 test/aottest/float64divzero/expect_output.txt create mode 100644 test/aottest/float64divzero/float64divzero.ts diff --git a/ecmascript/compiler/number_speculative_lowering.cpp b/ecmascript/compiler/number_speculative_lowering.cpp index 012cddff91..f907c8349b 100644 --- a/ecmascript/compiler/number_speculative_lowering.cpp +++ b/ecmascript/compiler/number_speculative_lowering.cpp @@ -326,7 +326,6 @@ void NumberSpeculativeLowering::VisitNumberDiv(GateRef gate) result = builder_.Int32DivWithCheck(left, right); acc_.SetMachineType(gate, MachineType::I32); } else { - builder_.Float64CheckRightIsZero(right); result = builder_.BinaryArithmetic(circuit_->Fdiv(), MachineType::F64, left, right); acc_.SetMachineType(gate, MachineType::F64); } diff --git a/test/aottest/float64divzero/BUILD.gn b/test/aottest/float64divzero/BUILD.gn new file mode 100644 index 0000000000..9a29811e14 --- /dev/null +++ b/test/aottest/float64divzero/BUILD.gn @@ -0,0 +1,18 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//arkcompiler/ets_runtime/test/test_helper.gni") + +host_aot_test_action("float64divzero") { + deps = [] +} diff --git a/test/aottest/float64divzero/expect_output.txt b/test/aottest/float64divzero/expect_output.txt new file mode 100644 index 0000000000..bc5d64c7b3 --- /dev/null +++ b/test/aottest/float64divzero/expect_output.txt @@ -0,0 +1,17 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +Infinity +NaN +Infinity +NaN diff --git a/test/aottest/float64divzero/float64divzero.ts b/test/aottest/float64divzero/float64divzero.ts new file mode 100644 index 0000000000..22fbe18b9e --- /dev/null +++ b/test/aottest/float64divzero/float64divzero.ts @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +//declare function print(str:string):string; +declare function print(str:any):number; + +var num0:number = 99 +var zero:number = 0.0 +var inf1:number = num0 / zero +print(inf1) +var nan1:number = zero / zero +print(nan1) +print(inf1/zero) +print(nan1/zero)