From 902e2b097b2da7dccd6cb197b1c727e030a2bba3 Mon Sep 17 00:00:00 2001 From: Daco Harkes Date: Thu, 13 Feb 2020 10:25:07 +0000 Subject: [PATCH] Revert "[vm] Arm Assembler simplify code for SubImmediateSetFlags" This reverts commit be38459b989d84d474a3d267406215c503cef423. Reason for revert: Comments in other pieces of the code state that kMinInt should be able to flow into SubImmediateSetFlags. Original change's description: > [vm] Arm Assembler simplify code for SubImmediateSetFlags > > See https://dart-review.googlesource.com/c/sdk/+/124136/9/runtime/vm/compiler/assembler/assembler_arm.cc#3203 > > Change-Id: I8d2a1bb781f22d6aae0e02eacf042a203a44790d > Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm-try,vm-ffi-android-product-arm-try,vm-ffi-android-release-arm-try,vm-kernel-linux-release-simarm-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-bare-linux-release-simarm-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-linux-release-simarm-try,vm-kernel-precomp-linux-release-simarm_x64-try > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134333 > Commit-Queue: Daco Harkes > Reviewed-by: Martin Kustermann TBR=kustermann@google.com,dacoharkes@google.com # Not skipping CQ checks because original CL landed > 1 day ago. Change-Id: Idb6ec6e55256c3a4894179a844d118a41378a074 Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm-try, vm-ffi-android-product-arm-try, vm-ffi-android-release-arm-try, vm-kernel-linux-release-simarm-try, vm-kernel-precomp-android-release-arm_x64-try, vm-kernel-precomp-bare-linux-release-simarm-try, vm-kernel-precomp-linux-debug-simarm_x64-try, vm-kernel-precomp-linux-release-simarm-try, vm-kernel-precomp-linux-release-simarm_x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135645 Reviewed-by: Daco Harkes Commit-Queue: Daco Harkes --- .../vm/compiler/assembler/assembler_arm.cc | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/runtime/vm/compiler/assembler/assembler_arm.cc b/runtime/vm/compiler/assembler/assembler_arm.cc index 961706aef50..573ed3bac89 100644 --- a/runtime/vm/compiler/assembler/assembler_arm.cc +++ b/runtime/vm/compiler/assembler/assembler_arm.cc @@ -3164,7 +3164,6 @@ void Assembler::SubImmediate(Register rd, Register rn, int32_t value, Condition cond) { - ASSERT(value != kMinInt32); // Cannot be negated. AddImmediate(rd, rn, -value, cond); } @@ -3172,8 +3171,27 @@ void Assembler::SubImmediateSetFlags(Register rd, Register rn, int32_t value, Condition cond) { - ASSERT(value != kMinInt32); // Cannot be negated. - AddImmediateSetFlags(rd, rn, -value, cond); + Operand o; + if (Operand::CanHold(value, &o)) { + // Handles value == kMinInt32. + subs(rd, rn, o, cond); + } else if (Operand::CanHold(-value, &o)) { + ASSERT(value != kMinInt32); // Would cause erroneous overflow detection. + adds(rd, rn, o, cond); + } else { + ASSERT(rn != IP); + if (Operand::CanHold(~value, &o)) { + mvn(IP, o, cond); + subs(rd, rn, Operand(IP), cond); + } else if (Operand::CanHold(~(-value), &o)) { + ASSERT(value != kMinInt32); // Would cause erroneous overflow detection. + mvn(IP, o, cond); + adds(rd, rn, Operand(IP), cond); + } else { + LoadDecodableImmediate(IP, value, cond); + subs(rd, rn, Operand(IP), cond); + } + } } void Assembler::AndImmediate(Register rd,