Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8262025: [lworld] C2 should optimize acmp of the same inline type #343

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -2176,6 +2176,12 @@ void Parse::do_acmp(BoolTest::mask btest, Node* left, Node* right) {
return;
}

// Check for equality before potentially allocating
if (left == right) {
do_if(btest, makecon(TypeInt::CC_EQ));
return;
}

// Allocate inline type operands and re-execute on deoptimization
if (left->is_InlineType()) {
PreserveReexecuteState preexecs(this);
@@ -3645,4 +3645,70 @@ public void test134_verifier(boolean warmup) {
// Expected
}
}

// Test that acmp of the same inline object is removed
@Test(failOn = ALLOC + LOAD + STORE + NULL_CHECK_TRAP + TRAP)
public static boolean test135() {
MyValue1 val = MyValue1.createWithFieldsInline(rI, rL);
return val == val;
}

@DontCompile
public void test135_verifier(boolean warmup) {
Asserts.assertTrue(test135());
}

// Same as test135 but with .ref
@Test(failOn = ALLOC + LOAD + STORE + NULL_CHECK_TRAP + TRAP)
public static boolean test136(boolean b) {
MyValue1.ref val = MyValue1.createWithFieldsInline(rI, rL);
if (b) {
val = null;
}
return val == val;
}

@DontCompile
public void test136_verifier(boolean warmup) {
Asserts.assertTrue(test136(false));
Asserts.assertTrue(test136(true));
}

static final primitive class SimpleInlineType {
final int x;
public SimpleInlineType(int x) {
this.x = x;
}
}

// Test that acmp of different inline objects with same content is removed
@Test(failOn = ALLOC + LOAD + STORE + NULL_CHECK_TRAP + TRAP)
public static boolean test137(int i) {
SimpleInlineType val1 = new SimpleInlineType(i);
SimpleInlineType val2 = new SimpleInlineType(i);
return val1 == val2;
}

@DontCompile
public void test137_verifier(boolean warmup) {
Asserts.assertTrue(test137(rI));
}

// Same as test137 but with .ref
@Test(failOn = ALLOC + LOAD + STORE + NULL_CHECK_TRAP + TRAP)
public static boolean test138(int i, boolean b) {
SimpleInlineType.ref val1 = new SimpleInlineType(i);
SimpleInlineType.ref val2 = new SimpleInlineType(i);
if (b) {
val1 = null;
val2 = null;
}
return val1 == val2;
}

@DontCompile
public void test138_verifier(boolean warmup) {
Asserts.assertTrue(test138(rI, false));
Asserts.assertTrue(test138(rI, true));
}
}
@@ -173,6 +173,7 @@ public void testAlot() {
if (a != b) throw new RuntimeException("Substitutability test failed" + a + " != " + b);
}
}
System.gc();
} while (ref.get() != null);
}