/// CHECK-START-ARM64: void Main.$opt$noinline$testAnd(long, long) disassembly (after) /// CHECK: and lsl /// CHECK: sxtb /// CHECK: and
staticvoid $opt$noinline$testAnd(long a, long b) {
assertLongEquals((a & $noinline$LongShl(b, 5)) | (a & $noinline$longToByte(b)),
(a & (b << 5)) | (a & (byte)b));
}
staticvoid $opt$noinline$testOr(int a, int b) {
assertIntEquals((a | $noinline$IntShr(b, 6)) | (a | $noinline$intToChar(b)),
(a | (b >> 6)) | (a | (char)b));
}
staticvoid $opt$noinline$testXor(long a, long b) {
assertLongEquals((a ^ $noinline$LongUshr(b, 7)) | (a ^ $noinline$longToInt(b)),
(a ^ (b >>> 7)) | (a ^ (int)b));
}
publicstaticvoid $opt$validateExtendByteInt1(int a, byte b) {
assertIntEquals(a + $noinline$byteToChar (b), a + (char)b); // Conversions byte->short and short->int are implicit; nothing to merge.
assertIntEquals(a + $noinline$byteToShort(b), a + (short)b);
}
publicstaticvoid $opt$validateExtendByteInt2(int a, byte b) { // The conversion to `int` has been optimized away, so there is nothing to merge.
assertIntEquals (a + $noinline$byteToInt (b), a + (int)b); // Use try-catch to prevent environment inputs elimination. try { // There is an environment use for `(long)b`, preventing the merge.
assertLongEquals(a + $noinline$byteToLong(b), a + (long)b);
} catch (Exception e) {}
}
publicstaticvoid $opt$validateExtendByteLong(long a, byte b) { // In each of the following tests, there will be a merge on the LHS.
// The first test has an explicit byte->char conversion on RHS, // followed by a conversion that is merged with the Add.
assertLongEquals(a + $noinline$byteToChar (b), a + (char)b); // Since conversions byte->short and byte->int are implicit, the RHS // for the two tests below is the same and one is eliminated by GVN. // The other is then merged to a shifter operand instruction.
assertLongEquals(a + $noinline$byteToShort(b), a + (short)b);
assertLongEquals(a + $noinline$byteToInt (b), a + (int)b);
}
publicstaticvoid $opt$validateExtendByte(long a, byte b) {
$opt$validateExtendByteInt1((int)a, b);
$opt$validateExtendByteInt2((int)a, b);
$opt$validateExtendByteLong(a, b);
}
publicstaticvoid $opt$validateExtendCharInt1(int a, char b) {
assertIntEquals(a + $noinline$charToByte (b), a + (byte)b);
assertIntEquals(a + $noinline$charToShort(b), a + (short)b);
}
publicstaticvoid $opt$validateExtendCharInt2(int a, char b) { // The conversion to `int` has been optimized away, so there is nothing to merge.
assertIntEquals (a + $noinline$charToInt (b), a + (int)b); // Use try-catch to prevent environment inputs elimination. try { // There is an environment use for `(long)b` and the implicit `(long)a`, preventing the merge.
assertLongEquals(a + $noinline$charToLong(b), a + (long)b);
} catch (Exception e) {}
}
publicstaticvoid $opt$validateExtendCharLong(long a, char b) { // The first two tests have a type conversion.
assertLongEquals(a + $noinline$charToByte (b), a + (byte)b);
assertLongEquals(a + $noinline$charToShort(b), a + (short)b); // On ARM64 this test does not because the conversion to `int` is optimized away.
assertLongEquals(a + $noinline$charToInt (b), a + (int)b);
}
publicstaticvoid $opt$validateExtendChar(long a, char b) {
$opt$validateExtendCharInt1((int)a, b);
$opt$validateExtendCharInt2((int)a, b);
$opt$validateExtendCharLong(a, b);
}
publicstaticvoid $opt$validateExtendShortInt1(int a, short b) {
assertIntEquals(a + $noinline$shortToByte (b), a + (byte)b);
assertIntEquals(a + $noinline$shortToChar (b), a + (char)b);
}
publicstaticvoid $opt$validateExtendShortInt2(int a, short b) { // The conversion to `int` has been optimized away, so there is nothing to merge.
assertIntEquals (a + $noinline$shortToInt (b), a + (int)b); // Use try-catch to prevent environment inputs elimination. try { // There is an environment use for `(long)b` and the implicit `(long)a`, preventing the merge.
assertLongEquals(a + $noinline$shortToLong (b), a + (long)b);
} catch (Exception e) {}
}
publicstaticvoid $opt$validateExtendShortLong(long a, short b) { // The first two tests have a type conversion.
assertLongEquals(a + $noinline$shortToByte(b), a + (byte)b);
assertLongEquals(a + $noinline$shortToChar(b), a + (char)b); // On ARM64 this test does not because the conversion to `int` is optimized away.
assertLongEquals(a + $noinline$shortToInt (b), a + (int)b);
}
publicstaticvoid $opt$validateExtendShort(long a, short b) {
$opt$validateExtendShortInt1((int)a, b);
$opt$validateExtendShortInt2((int)a, b);
$opt$validateExtendShortLong(a, b);
}
publicstaticvoid $opt$validateExtendInt(long a, int b) { // All tests have a conversion to `long`. The first three tests also have a // conversion from `int` to the specified type. For each test the conversion // to `long` is merged into the shifter operand.
assertLongEquals(a + $noinline$intToByte (b), a + (byte)b);
assertLongEquals(a + $noinline$intToChar (b), a + (char)b);
assertLongEquals(a + $noinline$intToShort(b), a + (short)b);
assertLongEquals(a + $noinline$intToLong (b), a + (long)b);
}
publicstaticvoid $opt$validateExtendLong(long a, long b) { // Each test has two conversions, from `long` and then back to `long`. The // conversions to `long` are merged.
assertLongEquals(a + $noinline$longToByte (b), a + (byte)b);
assertLongEquals(a + $noinline$longToChar (b), a + (char)b);
assertLongEquals(a + $noinline$longToShort(b), a + (short)b);
assertLongEquals(a + $noinline$longToInt (b), a + (int)b);
}
staticint $noinline$IntShl(int b, int c) { return b << c;
} staticint $noinline$IntShr(int b, int c) { return b >> c;
} staticint $noinline$IntUshr(int b, int c) { return b >>> c;
}
publicstaticvoid $opt$validateShiftInt(int a, int b) {
assertIntEquals(a + $noinline$IntShl(b, 1), a + (b << 1));
assertIntEquals(a + $noinline$IntShl(b, 6), a + (b << 6));
assertIntEquals(a + $noinline$IntShl(b, 7), a + (b << 7));
assertIntEquals(a + $noinline$IntShl(b, 8), a + (b << 8));
assertIntEquals(a + $noinline$IntShl(b, 14), a + (b << 14));
assertIntEquals(a + $noinline$IntShl(b, 15), a + (b << 15));
assertIntEquals(a + $noinline$IntShl(b, 16), a + (b << 16));
assertIntEquals(a + $noinline$IntShl(b, 30), a + (b << 30));
assertIntEquals(a + $noinline$IntShl(b, 31), a + (b << 31));
assertIntEquals(a + $noinline$IntShl(b, 32), a + (b << $opt$inline$IntConstant32()));
assertIntEquals(a + $noinline$IntShl(b, 62), a + (b << $opt$inline$IntConstant62()));
assertIntEquals(a + $noinline$IntShl(b, 63), a + (b << $opt$inline$IntConstant63()));
assertIntEquals(a - $noinline$IntShr(b, 1), a - (b >> 1));
assertIntEquals(a - $noinline$IntShr(b, 6), a - (b >> 6));
assertIntEquals(a - $noinline$IntShr(b, 7), a - (b >> 7));
assertIntEquals(a - $noinline$IntShr(b, 8), a - (b >> 8));
assertIntEquals(a - $noinline$IntShr(b, 14), a - (b >> 14));
assertIntEquals(a - $noinline$IntShr(b, 15), a - (b >> 15));
assertIntEquals(a - $noinline$IntShr(b, 16), a - (b >> 16));
assertIntEquals(a - $noinline$IntShr(b, 30), a - (b >> 30));
assertIntEquals(a - $noinline$IntShr(b, 31), a - (b >> 31));
assertIntEquals(a - $noinline$IntShr(b, 32), a - (b >> $opt$inline$IntConstant32()));
assertIntEquals(a - $noinline$IntShr(b, 62), a - (b >> $opt$inline$IntConstant62()));
assertIntEquals(a - $noinline$IntShr(b, 63), a - (b >> $opt$inline$IntConstant63()));
assertIntEquals(a ^ $noinline$IntUshr(b, 1), a ^ (b >>> 1));
assertIntEquals(a ^ $noinline$IntUshr(b, 6), a ^ (b >>> 6));
assertIntEquals(a ^ $noinline$IntUshr(b, 7), a ^ (b >>> 7));
assertIntEquals(a ^ $noinline$IntUshr(b, 8), a ^ (b >>> 8));
assertIntEquals(a ^ $noinline$IntUshr(b, 14), a ^ (b >>> 14));
assertIntEquals(a ^ $noinline$IntUshr(b, 15), a ^ (b >>> 15));
assertIntEquals(a ^ $noinline$IntUshr(b, 16), a ^ (b >>> 16));
assertIntEquals(a ^ $noinline$IntUshr(b, 30), a ^ (b >>> 30));
assertIntEquals(a ^ $noinline$IntUshr(b, 31), a ^ (b >>> 31));
assertIntEquals(a ^ $noinline$IntUshr(b, 32), a ^ (b >>> $opt$inline$IntConstant32()));
assertIntEquals(a ^ $noinline$IntUshr(b, 62), a ^ (b >>> $opt$inline$IntConstant62()));
assertIntEquals(a ^ $noinline$IntUshr(b, 63), a ^ (b >>> $opt$inline$IntConstant63()));
}
// Hiding constants outside the range [0, 32) used for int shifts from Jack. // (Jack extracts only the low 5 bits.) publicstaticint $opt$inline$IntConstant32() { return32; } publicstaticint $opt$inline$IntConstant62() { return62; } publicstaticint $opt$inline$IntConstant63() { return63; }
staticlong $noinline$LongShl(long b, long c) { return b << c;
} staticlong $noinline$LongShr(long b, long c) { return b >> c;
} staticlong $noinline$LongUshr(long b, long c) { return b >>> c;
}
publicstaticlong[] $opt$validateShiftLong(long a, long b) { long[] results = newlong[36];
results[0] = a + (b << 1);
results[1] = a + (b << 6);
results[2] = a + (b << 7);
results[3] = a + (b << 8);
results[4] = a + (b << 14);
results[5] = a + (b << 15);
results[6] = a + (b << 16);
results[7] = a + (b << 30);
results[8] = a + (b << 31);
results[9] = a + (b << 32);
results[10] = a + (b << 62);
results[11] = a + (b << 63);
results[12] = a - (b >> 1);
results[13] = a - (b >> 6);
results[14] = a - (b >> 7);
results[15] = a - (b >> 8);
results[16] = a - (b >> 14);
results[17] = a - (b >> 15);
results[18] = a - (b >> 16);
results[19] = a - (b >> 30);
results[20] = a - (b >> 31);
results[21] = a - (b >> 32);
results[22] = a - (b >> 62);
results[23] = a - (b >> 63);
results[24] = a ^ (b >>> 1);
results[25] = a ^ (b >>> 6);
results[26] = a ^ (b >>> 7);
results[27] = a ^ (b >>> 8);
results[28] = a ^ (b >>> 14);
results[29] = a ^ (b >>> 15);
results[30] = a ^ (b >>> 16);
results[31] = a ^ (b >>> 30);
results[32] = a ^ (b >>> 31);
results[33] = a ^ (b >>> 32);
results[34] = a ^ (b >>> 62);
results[35] = a ^ (b >>> 63);
return results;
}
publicstaticvoid $opt$validateShiftLongAsserts(long a, long b) { long[] results = $opt$validateShiftLong(a, b);
assertIntEquals(3 * 12, results.length);
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.27Angebot
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-10-11)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.