address reviewer feedback 4

This commit is contained in:
Michael Reeves 2026-03-28 19:29:07 +11:00
parent 834a8f237b
commit 7de06f5a0b
2 changed files with 9 additions and 23 deletions

View File

@ -26,30 +26,19 @@
* @bug 8379327
* @summary Verify correctness for combined low/high 64-bit multiplication patterns.
* @library /test/lib /
* @run driver compiler.c2.TestMultiplyHighLowFusion
* @run driver ${test.main.class}
*/
package compiler.c2;
import compiler.lib.generators.Generator;
import compiler.lib.generators.Generators;
import compiler.lib.ir_framework.*;
import java.math.BigInteger;
public class TestMultiplyHighLowFusion {
private static final BigInteger MASK_64 = BigInteger.ONE.shiftLeft(64).subtract(BigInteger.ONE);
private static final long[] CORNER_CASES = {
0L,
1L,
-1L,
Long.MIN_VALUE,
Long.MAX_VALUE,
0x00000000FFFFFFFFL,
0xFFFFFFFF00000000L,
0x123456789ABCDEFL,
0xFEDCBA9876543210L
};
private static final java.util.Random RANDOM = new java.util.Random(0x8379327L);
private int warmupCount = 0;
private static final Generator<Long> LONG_GEN = Generators.G.longs();
public static void main(String[] args) {
TestFramework.run();
@ -89,14 +78,7 @@ public class TestMultiplyHighLowFusion {
@Run(test = {"doMath", "doMathSwapped", "doUnsignedMath", "doUnsignedMathSwapped"})
public void runTests() {
if (warmupCount < CORNER_CASES.length * CORNER_CASES.length) {
int aIdx = warmupCount / CORNER_CASES.length;
int bIdx = warmupCount % CORNER_CASES.length;
verifyPair(CORNER_CASES[aIdx], CORNER_CASES[bIdx]);
warmupCount++;
} else {
verifyPair(RANDOM.nextLong(), RANDOM.nextLong());
}
verifyPair(LONG_GEN.next(), LONG_GEN.next());
}
private void verifyPair(long a, long b) {

View File

@ -273,6 +273,10 @@ public final class Operations {
ops.add(Expression.make(BOOLEANS, "Boolean.logicalOr(", BOOLEANS, ", ", BOOLEANS, ")"));
ops.add(Expression.make(BOOLEANS, "Boolean.logicalXor(", BOOLEANS, ", ", BOOLEANS, ")"));
// ------------ Math -------------
ops.add(Expression.make(LONGS, "Math.multiplyHigh(", LONGS, ", ", LONGS, ")"));
ops.add(Expression.make(LONGS, "Math.unsignedMultiplyHigh(", LONGS, ", ", LONGS, ")"));
// TODO: Math and other classes.
// Note: Math.copySign is non-deterministic because of NaN having encoding with sign bit set and unset.