8353359: C2: Or(I|L)Node::Ideal is missing AddNode::Ideal call

Reviewed-by: epeter, chagedorn
This commit is contained in:
Hannes Greule 2025-04-03 11:34:45 +00:00 committed by Emanuel Peter
parent b263292a75
commit 3ceabf0f64
3 changed files with 41 additions and 8 deletions

View File

@ -829,7 +829,7 @@ Node* OrINode::Ideal(PhaseGVN* phase, bool can_reshape) {
Node* tn = phase->transform(and_a_b);
return AddNode::make_not(phase, tn, T_INT);
}
return nullptr;
return AddNode::Ideal(phase, can_reshape);
}
//------------------------------add_ring---------------------------------------
@ -909,7 +909,7 @@ Node* OrLNode::Ideal(PhaseGVN* phase, bool can_reshape) {
return AddNode::make_not(phase, tn, T_LONG);
}
return nullptr;
return AddNode::Ideal(phase, can_reshape);
}
//------------------------------add_ring---------------------------------------

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -27,7 +27,7 @@ import compiler.lib.ir_framework.*;
/*
* @test
* @bug 8322077
* @bug 8322077 8353359
* @summary Test that Ideal transformations of OrINode* are being performed as expected.
* @library /test/lib /
* @run driver compiler.c2.irTests.OrINodeIdealizationTests
@ -38,7 +38,7 @@ public class OrINodeIdealizationTests {
TestFramework.run();
}
@Run(test = { "test1" })
@Run(test = { "test1", "test2", "test3" })
public void runMethod() {
int a = RunInfo.getRandom().nextInt();
int b = RunInfo.getRandom().nextInt();
@ -55,6 +55,8 @@ public class OrINodeIdealizationTests {
@DontCompile
public void assertResult(int a, int b) {
Asserts.assertEQ((~a) | (~b), test1(a, b));
Asserts.assertEQ((a | 3) | 6, test2(a));
Asserts.assertEQ((a | 3) | a, test3(a));
}
// Checks (~a) | (~b) => ~(a & b)
@ -65,4 +67,18 @@ public class OrINodeIdealizationTests {
public int test1(int a, int b) {
return (~a) | (~b);
}
// Checks (a | 3) | 6 => a | (3 | 6) => a | 7
@Test
@IR(counts = { IRNode.OR, "1"})
public int test2(int a) {
return (a | 3) | 6;
}
// Checks (a | 3) | a => (a | a) | 3 => a | 3
@Test
@IR(counts = { IRNode.OR, "1"})
public int test3(int a) {
return (a | 3) | a;
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -27,7 +27,7 @@ import compiler.lib.ir_framework.*;
/*
* @test
* @bug 8322077
* @bug 8322077 8353359
* @summary Test that Ideal transformations of OrLNode* are being performed as expected.
* @library /test/lib /
* @run driver compiler.c2.irTests.OrLNodeIdealizationTests
@ -38,7 +38,7 @@ public class OrLNodeIdealizationTests {
TestFramework.run();
}
@Run(test = { "test1" })
@Run(test = { "test1", "test2", "test3" })
public void runMethod() {
long a = RunInfo.getRandom().nextLong();
long b = RunInfo.getRandom().nextLong();
@ -55,6 +55,8 @@ public class OrLNodeIdealizationTests {
@DontCompile
public void assertResult(long a, long b) {
Asserts.assertEQ((~a) | (~b), test1(a, b));
Asserts.assertEQ((a | 3) | 6, test2(a));
Asserts.assertEQ((a | 3) | a, test3(a));
}
// Checks (~a) | (~b) => ~(a & b)
@ -65,4 +67,19 @@ public class OrLNodeIdealizationTests {
public long test1(long a, long b) {
return (~a) | (~b);
}
// Checks (a | 3) | 6 => a | (3 | 6) => a | 7
@Test
@IR(counts = { IRNode.OR, "1"})
public long test2(long a) {
return (a | 3) | 6;
}
// Checks (a | 3) | a => (a | a) | 3 => a | 3
@Test
@IR(counts = { IRNode.OR, "1"})
public long test3(long a) {
return (a | 3) | a;
}
}