Snap for 11504324 from 4390175e92fd063914719de8de982795eced4d79 to 24Q2-release
Change-Id: If76ab2411db77fdbcca80c643b1283408d6336e6
diff --git a/compiler/optimizing/instruction_simplifier.cc b/compiler/optimizing/instruction_simplifier.cc
index d39e9ad..ae778b4 100644
--- a/compiler/optimizing/instruction_simplifier.cc
+++ b/compiler/optimizing/instruction_simplifier.cc
@@ -621,8 +621,7 @@
size_t rdist = Int64FromConstant(ushr->GetRight()->AsConstant());
size_t ldist = Int64FromConstant(shl->GetRight()->AsConstant());
if (((ldist + rdist) & (reg_bits - 1)) == 0) {
- ReplaceRotateWithRor(op, ushr, shl);
- return true;
+ return ReplaceRotateWithRor(op, ushr, shl);
}
return false;
}
@@ -643,6 +642,10 @@
// OP dst, dst, tmp
// with
// Ror dst, x, d
+//
+// Requires `d` to be non-zero for the HAdd and HXor case. If `d` is 0 the shifts and rotate are
+// no-ops and the `OP` is never executed. This is fine for HOr since the result is the same, but the
+// result is different for HAdd and HXor.
bool InstructionSimplifierVisitor::TryReplaceWithRotateRegisterNegPattern(HBinaryOperation* op,
HUShr* ushr,
HShl* shl) {
@@ -650,11 +653,20 @@
DCHECK(ushr->GetRight()->IsNeg() || shl->GetRight()->IsNeg());
bool neg_is_left = shl->GetRight()->IsNeg();
HNeg* neg = neg_is_left ? shl->GetRight()->AsNeg() : ushr->GetRight()->AsNeg();
- // And the shift distance being negated is the distance being shifted the other way.
- if (neg->InputAt(0) == (neg_is_left ? ushr->GetRight() : shl->GetRight())) {
- ReplaceRotateWithRor(op, ushr, shl);
+ HInstruction* value = neg->InputAt(0);
+
+ // The shift distance being negated is the distance being shifted the other way.
+ if (value != (neg_is_left ? ushr->GetRight() : shl->GetRight())) {
+ return false;
}
- return false;
+
+ const bool needs_non_zero_value = !op->IsOr();
+ if (needs_non_zero_value) {
+ if (!value->IsConstant() || value->AsConstant()->IsArithmeticZero()) {
+ return false;
+ }
+ }
+ return ReplaceRotateWithRor(op, ushr, shl);
}
// Try replacing code looking like (x >>> d OP x << (#bits - d)):
diff --git a/test/557-checker-instruct-simplifier-ror/src/Main.java b/test/557-checker-instruct-simplifier-ror/src/Main.java
index 5d4bb7a..667b35f 100644
--- a/test/557-checker-instruct-simplifier-ror/src/Main.java
+++ b/test/557-checker-instruct-simplifier-ror/src/Main.java
@@ -503,6 +503,7 @@
}
// (j << distance) + (j >>> -distance)
+ // We can't perform the optimization as distance might be `0`, resulting in the wrong value.
/// CHECK-START: long Main.rol_long_reg_v_negv_add(long, int) instruction_simplifier (before)
/// CHECK: <<ArgValue:j\d+>> ParameterValue
@@ -516,19 +517,17 @@
/// CHECK-START: long Main.rol_long_reg_v_negv_add(long, int) instruction_simplifier (after)
/// CHECK: <<ArgValue:j\d+>> ParameterValue
/// CHECK: <<ArgDistance:i\d+>> ParameterValue
- /// CHECK: <<Neg:i\d+>> Neg [<<ArgDistance>>]
- /// CHECK: <<Ror:j\d+>> Ror [<<ArgValue>>,<<Neg>>]
- /// CHECK: Return [<<Ror>>]
-
- /// CHECK-START: long Main.rol_long_reg_v_negv_add(long, int) instruction_simplifier (after)
- /// CHECK-NOT: Add
- /// CHECK-NOT: Shl
- /// CHECK-NOT: UShr
+ /// CHECK-DAG: <<Neg:i\d+>> Neg [<<ArgDistance>>]
+ /// CHECK-DAG: <<UShr:j\d+>> UShr [<<ArgValue>>,<<Neg>>]
+ /// CHECK-DAG: <<Shl:j\d+>> Shl [<<ArgValue>>,<<ArgDistance>>]
+ /// CHECK: <<Add:j\d+>> Add [<<Shl>>,<<UShr>>]
+ /// CHECK: Return [<<Add>>]
public static long rol_long_reg_v_negv_add(long value, int distance) {
return (value << distance) + (value >>> -distance);
}
// (j << distance) ^ (j >>> -distance)
+ // We can't perform the optimization as distance might be `0`, resulting in the wrong value.
/// CHECK-START: long Main.rol_long_reg_v_negv_xor(long, int) instruction_simplifier (before)
/// CHECK: <<ArgValue:j\d+>> ParameterValue
@@ -542,18 +541,60 @@
/// CHECK-START: long Main.rol_long_reg_v_negv_xor(long, int) instruction_simplifier (after)
/// CHECK: <<ArgValue:j\d+>> ParameterValue
/// CHECK: <<ArgDistance:i\d+>> ParameterValue
- /// CHECK: <<Neg:i\d+>> Neg [<<ArgDistance>>]
- /// CHECK: <<Ror:j\d+>> Ror [<<ArgValue>>,<<Neg>>]
- /// CHECK: Return [<<Ror>>]
+ /// CHECK-DAG: <<Neg:i\d+>> Neg [<<ArgDistance>>]
+ /// CHECK-DAG: <<UShr:j\d+>> UShr [<<ArgValue>>,<<Neg>>]
+ /// CHECK-DAG: <<Shl:j\d+>> Shl [<<ArgValue>>,<<ArgDistance>>]
+ /// CHECK: <<Xor:j\d+>> Xor [<<Shl>>,<<UShr>>]
+ /// CHECK: Return [<<Xor>>]
- /// CHECK-START: long Main.rol_long_reg_v_negv_xor(long, int) instruction_simplifier (after)
- /// CHECK-NOT: Xor
- /// CHECK-NOT: Shl
- /// CHECK-NOT: UShr
public static long rol_long_reg_v_negv_xor(long value, int distance) {
return (value << distance) ^ (value >>> -distance);
}
+ /// CHECK-START: void Main.$noinline$testDontOptimizeAddIntoRotate_Int() disassembly (after)
+ /// CHECK-NOT: Ror
+ public static void $noinline$testDontOptimizeAddIntoRotate_Int() {
+ int distance = returnFalse() ? 1 : 0;
+ int value = -512667375;
+ int expected_result = 2 * value;
+ int result = (value >>> distance) + (value << -distance);
+ assertIntEquals(expected_result, result);
+ }
+
+ /// CHECK-START: void Main.$noinline$testDontOptimizeAddIntoRotate_Long() disassembly (after)
+ /// CHECK-NOT: Ror
+ public static void $noinline$testDontOptimizeAddIntoRotate_Long() {
+ int distance = returnFalse() ? 1 : 0;
+ long value = -512667375L;
+ long expected_result = 2L * value;
+ long result = (value >>> distance) + (value << -distance);
+ assertLongEquals(expected_result, result);
+ }
+
+ /// CHECK-START: void Main.$noinline$testDontOptimizeXorIntoRotate_Int() disassembly (after)
+ /// CHECK-NOT: Ror
+ public static void $noinline$testDontOptimizeXorIntoRotate_Int() {
+ int distance = returnFalse() ? 1 : 0;
+ int value = -512667375;
+ int expected_result = 0;
+ int result = (value >>> distance) ^ (value << -distance);
+ assertIntEquals(expected_result, result);
+ }
+
+ /// CHECK-START: void Main.$noinline$testDontOptimizeXorIntoRotate_Long() disassembly (after)
+ /// CHECK-NOT: Ror
+ public static void $noinline$testDontOptimizeXorIntoRotate_Long() {
+ int distance = returnFalse() ? 1 : 0;
+ long value = -512667375L;
+ long expected_result = 0;
+ long result = (value >>> distance) ^ (value << -distance);
+ assertLongEquals(expected_result, result);
+ }
+
+ static boolean returnFalse() {
+ return false;
+ }
+
public static void main(String[] args) {
assertIntEquals(2, ror_int_constant_c_c(8));
assertIntEquals(2, ror_int_constant_c_c_0(8));
@@ -581,5 +622,11 @@
assertLongEquals(32L, rol_long_reg_v_negv_add(8L, 2));
assertLongEquals(32L, rol_long_reg_v_negv_xor(8L, 2));
+
+ $noinline$testDontOptimizeAddIntoRotate_Int();
+ $noinline$testDontOptimizeAddIntoRotate_Long();
+
+ $noinline$testDontOptimizeXorIntoRotate_Int();
+ $noinline$testDontOptimizeXorIntoRotate_Long();
}
}
diff --git a/test/run-test b/test/run-test
index de676a0..17d5227 100755
--- a/test/run-test
+++ b/test/run-test
@@ -113,14 +113,14 @@
tmp_dir = f"{TMPDIR}/{test_dir}"
checker = f"{progdir}/../tools/checker/checker.py"
- ON_VM = os.environ.get("ART_TEST_ON_VM")
- SSH_USER = os.environ.get("ART_TEST_SSH_USER")
- SSH_HOST = os.environ.get("ART_TEST_SSH_HOST")
- SSH_PORT = os.environ.get("ART_TEST_SSH_PORT")
- SSH_CMD = os.environ.get("ART_SSH_CMD")
- SCP_CMD = os.environ.get("ART_SCP_CMD")
- CHROOT = os.environ.get("ART_TEST_CHROOT")
- CHROOT_CMD = os.environ.get("ART_CHROOT_CMD")
+ ON_VM = env.ART_TEST_ON_VM
+ SSH_USER = env.ART_TEST_SSH_USER
+ SSH_HOST = env.ART_TEST_SSH_HOST
+ SSH_PORT = env.ART_TEST_SSH_PORT
+ SSH_CMD = env.ART_SSH_CMD
+ SCP_CMD = env.ART_SCP_CMD
+ CHROOT = env.ART_TEST_CHROOT
+ CHROOT_CMD = env.ART_CHROOT_CMD
def fail(message: str, caller:Optional[FrameInfo]=None):
caller = caller or getframeinfo(currentframe().f_back) # type: ignore
diff --git a/test/testrunner/env.py b/test/testrunner/env.py
index 200de4a..8313756 100644
--- a/test/testrunner/env.py
+++ b/test/testrunner/env.py
@@ -148,4 +148,17 @@
ART_TEST_RUN_ON_ARM_FVP = _getEnvBoolean('ART_TEST_RUN_ON_ARM_FVP', False)
ART_TEST_ON_VM = _env.get('ART_TEST_ON_VM')
-ART_SSH_CMD = _env.get('ART_SSH_CMD')
+
+ART_TEST_SSH_PORT = _env.get('ART_TEST_SSH_PORT', 10001)
+ART_TEST_SSH_USER = _env.get('ART_TEST_SSH_USER', 'ubuntu')
+ART_TEST_SSH_HOST = _env.get('ART_TEST_SSH_HOST', 'localhost')
+ART_SSH_CMD = _env.get('ART_SSH_CMD', f"ssh -q -i ~/.ssh/ubuntu -p {ART_TEST_SSH_PORT} "
+ f"-o StrictHostKeyChecking=no "
+ f"{ART_TEST_SSH_USER}@{ART_TEST_SSH_HOST}")
+ART_SCP_CMD = _env.get('ART_SCP_CMD', f"scp -i ~/.ssh/ubuntu -P {ART_TEST_SSH_PORT} "
+ f"-o StrictHostKeyChecking=no -p -r")
+ART_CHROOT_CMD = _env.get('ART_CHROOT_CMD', "unshare --user --map-root-user chroot art-test-chroot")
+if ART_TEST_ON_VM:
+ ART_TEST_CHROOT = _env.get('ART_TEST_CHROOT', f"/home/{ART_TEST_SSH_USER}/art-test-chroot")
+else:
+ ART_TEST_CHROOT = _env.get('ART_TEST_CHROOT', "/data/local/art-test-chroot")
diff --git a/tools/luci/config/generated/cr-buildbucket.cfg b/tools/luci/config/generated/cr-buildbucket.cfg
index 1e207d5..c6cdc02 100644
--- a/tools/luci/config/generated/cr-buildbucket.cfg
+++ b/tools/luci/config/generated/cr-buildbucket.cfg
@@ -23,11 +23,13 @@
name: "art"
cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
cipd_version: "refs/heads/main"
+ properties_j: "bitness:32"
properties_j: "builder_group:\"client.art\""
properties_j: "concurrent_collector:true"
properties_j: "debug:true"
properties_j: "device:\"angler-armv7\""
properties_j: "generational_cc:true"
+ properties_j: "product:\"arm_krait\""
}
execution_timeout_secs: 108000
expiration_secs: 61200
@@ -51,11 +53,13 @@
name: "art"
cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
cipd_version: "refs/heads/main"
+ properties_j: "bitness:32"
properties_j: "builder_group:\"client.art\""
properties_j: "concurrent_collector:true"
properties_j: "debug:false"
properties_j: "device:\"angler-armv7\""
properties_j: "generational_cc:true"
+ properties_j: "product:\"arm_krait\""
}
execution_timeout_secs: 108000
expiration_secs: 61200
@@ -80,11 +84,13 @@
name: "art"
cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
cipd_version: "refs/heads/main"
+ properties_j: "bitness:32"
properties_j: "builder_group:\"client.art\""
properties_j: "concurrent_collector:false"
properties_j: "debug:true"
properties_j: "device:\"angler-armv7\""
properties_j: "generational_cc:false"
+ properties_j: "product:\"arm_krait\""
}
execution_timeout_secs: 108000
expiration_secs: 61200
@@ -108,11 +114,13 @@
name: "art"
cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
cipd_version: "refs/heads/main"
+ properties_j: "bitness:64"
properties_j: "builder_group:\"client.art\""
properties_j: "concurrent_collector:true"
properties_j: "debug:true"
properties_j: "device:\"angler-armv8\""
properties_j: "generational_cc:true"
+ properties_j: "product:\"armv8\""
}
execution_timeout_secs: 108000
expiration_secs: 61200
@@ -136,11 +144,13 @@
name: "art"
cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
cipd_version: "refs/heads/main"
+ properties_j: "bitness:64"
properties_j: "builder_group:\"client.art\""
properties_j: "concurrent_collector:true"
properties_j: "debug:false"
properties_j: "device:\"angler-armv8\""
properties_j: "generational_cc:true"
+ properties_j: "product:\"armv8\""
}
execution_timeout_secs: 108000
expiration_secs: 61200
@@ -165,11 +175,13 @@
name: "art"
cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
cipd_version: "refs/heads/main"
+ properties_j: "bitness:64"
properties_j: "builder_group:\"client.art\""
properties_j: "concurrent_collector:false"
properties_j: "debug:true"
properties_j: "device:\"angler-armv8\""
properties_j: "generational_cc:false"
+ properties_j: "product:\"armv8\""
}
execution_timeout_secs: 108000
expiration_secs: 61200
@@ -193,12 +205,14 @@
name: "art"
cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
cipd_version: "refs/heads/main"
+ properties_j: "bitness:32"
properties_j: "builder_group:\"client.art\""
properties_j: "concurrent_collector:true"
properties_j: "debug:false"
properties_j: "device:\"bullhead-armv7\""
properties_j: "gcstress:true"
properties_j: "generational_cc:true"
+ properties_j: "product:\"arm_krait\""
}
execution_timeout_secs: 108000
expiration_secs: 61200
@@ -222,12 +236,14 @@
name: "art"
cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
cipd_version: "refs/heads/main"
+ properties_j: "bitness:64"
properties_j: "builder_group:\"client.art\""
properties_j: "concurrent_collector:true"
properties_j: "debug:true"
properties_j: "device:\"bullhead-armv8\""
properties_j: "gcstress:true"
properties_j: "generational_cc:true"
+ properties_j: "product:\"armv8\""
}
execution_timeout_secs: 108000
expiration_secs: 61200
@@ -251,12 +267,14 @@
name: "art"
cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
cipd_version: "refs/heads/main"
+ properties_j: "bitness:64"
properties_j: "builder_group:\"client.art\""
properties_j: "concurrent_collector:true"
properties_j: "debug:false"
properties_j: "device:\"bullhead-armv8\""
properties_j: "gcstress:true"
properties_j: "generational_cc:true"
+ properties_j: "product:\"armv8\""
}
execution_timeout_secs: 108000
expiration_secs: 61200
@@ -593,6 +611,7 @@
name: "art"
cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
cipd_version: "refs/heads/main"
+ properties_j: "bitness:64"
properties_j: "builder_group:\"client.art\""
properties_j: "concurrent_collector:true"
properties_j: "debug:false"
@@ -622,6 +641,7 @@
name: "art"
cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
cipd_version: "refs/heads/main"
+ properties_j: "bitness:64"
properties_j: "builder_group:\"client.art\""
properties_j: "concurrent_collector:true"
properties_j: "debug:false"
@@ -651,6 +671,7 @@
name: "art"
cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
cipd_version: "refs/heads/main"
+ properties_j: "bitness:64"
properties_j: "build_only:true"
properties_j: "builder_group:\"client.art\""
properties_j: "concurrent_collector:true"
@@ -681,12 +702,14 @@
name: "art"
cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
cipd_version: "refs/heads/main"
+ properties_j: "bitness:32"
properties_j: "builder_group:\"client.art\""
properties_j: "concurrent_collector:true"
properties_j: "debug:true"
properties_j: "device:\"walleye-armv7\""
properties_j: "generational_cc:true"
properties_j: "heap_poisoning:true"
+ properties_j: "product:\"arm_krait\""
}
execution_timeout_secs: 108000
expiration_secs: 61200
@@ -710,12 +733,14 @@
name: "art"
cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
cipd_version: "refs/heads/main"
+ properties_j: "bitness:64"
properties_j: "builder_group:\"client.art\""
properties_j: "concurrent_collector:true"
properties_j: "debug:true"
properties_j: "device:\"walleye-armv8\""
properties_j: "generational_cc:true"
properties_j: "heap_poisoning:true"
+ properties_j: "product:\"armv8\""
}
execution_timeout_secs: 108000
expiration_secs: 61200
@@ -739,12 +764,14 @@
name: "art"
cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
cipd_version: "refs/heads/main"
+ properties_j: "bitness:64"
properties_j: "builder_group:\"client.art\""
properties_j: "concurrent_collector:true"
properties_j: "debug:false"
properties_j: "device:\"walleye-armv8\""
properties_j: "generational_cc:true"
properties_j: "heap_poisoning:true"
+ properties_j: "product:\"armv8\""
}
execution_timeout_secs: 108000
expiration_secs: 61200
diff --git a/tools/luci/config/main.star b/tools/luci/config/main.star
index aa5dcd5..0320ce6 100755
--- a/tools/luci/config/main.star
+++ b/tools/luci/config/main.star
@@ -217,8 +217,10 @@
short_name="dbg",
dimensions=target_dims,
properties={
+ "bitness": 32,
"device": "angler-armv7",
"debug": True,
+ "product": "arm_krait",
}
)
ci_builder(
@@ -227,10 +229,12 @@
short_name="ngen",
dimensions=userfault_gc_target_dims,
properties={
+ "bitness": 32,
"device": "angler-armv7",
"debug": True,
"concurrent_collector": False,
"generational_cc": False,
+ "product": "arm_krait",
}
)
ci_builder(
@@ -239,8 +243,10 @@
short_name="ndbg",
dimensions=target_dims,
properties={
+ "bitness": 32,
"device": "angler-armv7",
"debug": False,
+ "product": "arm_krait",
}
)
ci_builder(
@@ -249,8 +255,10 @@
short_name="dbg",
dimensions=target_dims,
properties={
+ "bitness": 64,
"device": "angler-armv8",
"debug": True,
+ "product": "armv8",
}
)
ci_builder(
@@ -259,10 +267,12 @@
short_name="ngen",
dimensions=userfault_gc_target_dims,
properties={
+ "bitness": 64,
"device": "angler-armv8",
"debug": True,
"concurrent_collector": False,
"generational_cc": False,
+ "product": "armv8",
}
)
ci_builder(
@@ -271,8 +281,10 @@
short_name="ndbg",
dimensions=target_dims,
properties={
+ "bitness": 64,
"device": "angler-armv8",
"debug": False,
+ "product": "armv8",
}
)
ci_builder(
@@ -281,9 +293,11 @@
short_name="dbg",
dimensions=target_dims,
properties={
+ "bitness": 32,
"device": "bullhead-armv7",
"debug": False,
"gcstress": True,
+ "product": "arm_krait",
}
)
ci_builder(
@@ -292,9 +306,11 @@
short_name="dbg",
dimensions=target_dims,
properties={
+ "bitness": 64,
"device": "bullhead-armv8",
"debug": True,
"gcstress": True,
+ "product": "armv8",
}
)
ci_builder(
@@ -303,9 +319,11 @@
short_name="ndbg",
dimensions=target_dims,
properties={
+ "bitness": 64,
"device": "bullhead-armv8",
"debug": False,
"gcstress": True,
+ "product": "armv8",
}
)
ci_builder(
@@ -314,9 +332,11 @@
short_name="dbg",
dimensions=target_dims,
properties={
+ "bitness": 32,
"device": "walleye-armv7",
"debug": True,
"heap_poisoning": True,
+ "product": "arm_krait",
}
)
ci_builder(
@@ -325,9 +345,11 @@
short_name="dbg",
dimensions=target_dims,
properties={
+ "bitness": 64,
"device": "walleye-armv8",
"debug": True,
"heap_poisoning": True,
+ "product": "armv8",
}
)
ci_builder(
@@ -336,9 +358,11 @@
short_name="ndbg",
dimensions=target_dims,
properties={
+ "bitness": 64,
"device": "walleye-armv8",
"debug": False,
"heap_poisoning": True,
+ "product": "armv8",
}
)
@@ -471,6 +495,7 @@
dimensions=host_dims,
is_fyi=True,
properties={
+ "bitness": 64,
"debug": False,
"device": "qemu-armv8",
"on_virtual_machine": True,
@@ -483,6 +508,7 @@
dimensions=host_dims,
is_fyi=True,
properties={
+ "bitness": 64,
"debug": False,
"device": "qemu-riscv64",
"on_virtual_machine": True,
@@ -494,6 +520,7 @@
short_name="bo",
dimensions=host_dims,
properties={
+ "bitness": 64,
"build_only": True,
"debug": False,
"device": "qemu-riscv64",