Skip to content

Commit

Permalink
8256267: Relax compiler/floatingpoint/NaNTest.java for x86_32 and low…
Browse files Browse the repository at this point in the history
…er -XX:+UseSSE

Backport-of: a14f02d
  • Loading branch information
shipilev committed Jul 11, 2021
1 parent 6d0945e commit 1960a05
Showing 1 changed file with 38 additions and 5 deletions.
43 changes: 38 additions & 5 deletions test/hotspot/jtreg/compiler/floatingpoint/NaNTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,23 @@
* @test
* @bug 8076373
* @summary Verify if signaling NaNs are preserved.
* @library /test/lib /
*
* @run main compiler.floatingpoint.NaNTest
* @build sun.hotspot.WhiteBox
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
* compiler.floatingpoint.NaNTest
*/

package compiler.floatingpoint;

import jdk.test.lib.Platform;
import jtreg.SkippedException;
import sun.hotspot.WhiteBox;

public class NaNTest {
static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();

static void testFloat() {
int originalValue = 0x7f800001;
int readBackValue = Float.floatToRawIntBits(Float.intBitsToFloat(originalValue));
Expand Down Expand Up @@ -63,11 +73,34 @@ static void testDouble() {
}

public static void main(String args[]) {
System.out.println("### NanTest started");
// Some platforms are known to strip signaling NaNs.
// The block below can be used to except them.
boolean expectStableFloats = true;
boolean expectStableDoubles = true;

// On x86_32 without relevant SSE-enabled stubs, we are entering
// native methods that use FPU instructions, and those strip the
// signaling NaNs.
if (Platform.isX86()) {
int sse = WHITE_BOX.getIntxVMFlag("UseSSE").intValue();
expectStableFloats = (sse >= 1);
expectStableDoubles = (sse >= 2);
}

if (expectStableFloats) {
testFloat();
} else {
System.out.println("Stable floats cannot be expected, skipping");
}

testFloat();
testDouble();
if (expectStableDoubles) {
testDouble();
} else {
System.out.println("Stable doubles cannot be expected, skipping");
}

System.out.println("### NanTest ended");
if (!expectStableFloats && !expectStableDoubles) {
throw new SkippedException("No tests were run.");
}
}
}

1 comment on commit 1960a05

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.