/// CHECK-START: void SimdByte.shr2() loop_optimization (before) /// CHECK-DAG: ArrayGet loop:<<Loop:B\d+>> outer_loop:none /// CHECK-DAG: ArraySet loop:<<Loop>> outer_loop:none // // TODO: would need signess flip. /// CHECK-START: void SimdByte.shr2() loop_optimization (after) /// CHECK-NOT: VecUShr staticvoid shr2() { for (int i = 0; i < 128; i++)
a[i] >>>= 2;
}
// // Shift checks. //
staticvoid sar31() { for (int i = 0; i < 128; i++)
a[i] >>= 31;
}
staticvoid shr31() { for (int i = 0; i < 128; i++)
a[i] >>>= 31;
}
staticvoid shr32() { for (int i = 0; i < 128; i++)
a[i] >>>= 32; // 0, since & 31
}
staticvoid shr33() { for (int i = 0; i < 128; i++)
a[i] >>>= 33; // 1, since & 31
}
staticvoid shl9() { for (int i = 0; i < 128; i++)
a[i] <<= 9; // yields all-zeros
}
// // Loop bounds. //
staticvoid bounds() { for (int i = 1; i < 127; i++)
a[i] += 11;
}
// // Test Driver. //
publicstaticvoid main() { // Set up.
a = newbyte[128]; for (int i = 0; i < 128; i++) {
a[i] = (byte) i;
} // Arithmetic operations.
add(2); for (int i = 0; i < 128; i++) {
expectEquals((byte)(i + 2), a[i], "add");
}
sub(2); for (int i = 0; i < 128; i++) {
expectEquals(i, a[i], "sub");
}
mul(2); for (int i = 0; i < 128; i++) {
expectEquals((byte)(i + i), a[i], "mul");
}
div(2); for (int i = 0; i < 128; i++) {
expectEquals(((byte)(i + i)) >> 1, a[i], "div");
a[i] = (byte) i; // undo arithmetic wrap-around effects
}
neg(); for (int i = 0; i < 128; i++) {
expectEquals(-i, a[i], "neg");
} // Loop bounds.
bounds();
expectEquals(0, a[0], "bounds0"); for (int i = 1; i < 127; i++) {
expectEquals(11 - i, a[i], "bounds");
}
expectEquals(-127, a[127], "bounds127"); // Shifts. for (int i = 0; i < 128; i++) {
a[i] = (byte) 0xff;
}
shl4(); for (int i = 0; i < 128; i++) {
expectEquals((byte) 0xf0, a[i], "shl4");
}
sar2(); for (int i = 0; i < 128; i++) {
expectEquals((byte) 0xfc, a[i], "sar2");
}
shr2(); for (int i = 0; i < 128; i++) {
expectEquals((byte) 0xff, a[i], "shr2"); // sic!
}
sar31(); for (int i = 0; i < 128; i++) {
expectEquals((byte) 0xff, a[i], "sar31");
}
shr31(); for (int i = 0; i < 128; i++) {
expectEquals(0x01, a[i], "shr31");
a[i] = (byte) 0x12; // reset
}
shr32(); for (int i = 0; i < 128; i++) {
expectEquals((byte) 0x12, a[i], "shr32");
}
shr33(); for (int i = 0; i < 128; i++) {
expectEquals((byte) 0x09, a[i], "shr33");
}
shl9(); for (int i = 0; i < 128; i++) {
expectEquals((byte) 0x00, a[i], "shl9");
a[i] = (byte) 0xf0; // reset
}
not(); for (int i = 0; i < 128; i++) {
expectEquals((byte) 0x0f, a[i], "not");
} // Done.
System.out.println("SimdByte passed");
}
privatestaticvoid expectEquals(int expected, int result, String action) { if (expected != result) { thrownew Error("Expected: " + expected + ", found: " + result + " for " + action);
}
}
}
Messung V0.5 in Prozent
¤ 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.0.14Bemerkung:
(vorverarbeitet am 2026-06-29)
¤
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.