Skip to content

Commit 3ceabf0

Browse files
SirYwelleme64
authored andcommittedApr 3, 2025
8353359: C2: Or(I|L)Node::Ideal is missing AddNode::Ideal call
Reviewed-by: epeter, chagedorn
1 parent b263292 commit 3ceabf0

File tree

3 files changed

+41
-8
lines changed

3 files changed

+41
-8
lines changed
 

‎src/hotspot/share/opto/addnode.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ Node* OrINode::Ideal(PhaseGVN* phase, bool can_reshape) {
829829
Node* tn = phase->transform(and_a_b);
830830
return AddNode::make_not(phase, tn, T_INT);
831831
}
832-
return nullptr;
832+
return AddNode::Ideal(phase, can_reshape);
833833
}
834834

835835
//------------------------------add_ring---------------------------------------
@@ -909,7 +909,7 @@ Node* OrLNode::Ideal(PhaseGVN* phase, bool can_reshape) {
909909
return AddNode::make_not(phase, tn, T_LONG);
910910
}
911911

912-
return nullptr;
912+
return AddNode::Ideal(phase, can_reshape);
913913
}
914914

915915
//------------------------------add_ring---------------------------------------

‎test/hotspot/jtreg/compiler/c2/irTests/OrINodeIdealizationTests.java

+19-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,7 @@
2727

2828
/*
2929
* @test
30-
* @bug 8322077
30+
* @bug 8322077 8353359
3131
* @summary Test that Ideal transformations of OrINode* are being performed as expected.
3232
* @library /test/lib /
3333
* @run driver compiler.c2.irTests.OrINodeIdealizationTests
@@ -38,7 +38,7 @@ public static void main(String[] args) {
3838
TestFramework.run();
3939
}
4040

41-
@Run(test = { "test1" })
41+
@Run(test = { "test1", "test2", "test3" })
4242
public void runMethod() {
4343
int a = RunInfo.getRandom().nextInt();
4444
int b = RunInfo.getRandom().nextInt();
@@ -55,6 +55,8 @@ public void runMethod() {
5555
@DontCompile
5656
public void assertResult(int a, int b) {
5757
Asserts.assertEQ((~a) | (~b), test1(a, b));
58+
Asserts.assertEQ((a | 3) | 6, test2(a));
59+
Asserts.assertEQ((a | 3) | a, test3(a));
5860
}
5961

6062
// Checks (~a) | (~b) => ~(a & b)
@@ -65,4 +67,18 @@ public void assertResult(int a, int b) {
6567
public int test1(int a, int b) {
6668
return (~a) | (~b);
6769
}
70+
71+
// Checks (a | 3) | 6 => a | (3 | 6) => a | 7
72+
@Test
73+
@IR(counts = { IRNode.OR, "1"})
74+
public int test2(int a) {
75+
return (a | 3) | 6;
76+
}
77+
78+
// Checks (a | 3) | a => (a | a) | 3 => a | 3
79+
@Test
80+
@IR(counts = { IRNode.OR, "1"})
81+
public int test3(int a) {
82+
return (a | 3) | a;
83+
}
6884
}

‎test/hotspot/jtreg/compiler/c2/irTests/OrLNodeIdealizationTests.java

+20-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,7 @@
2727

2828
/*
2929
* @test
30-
* @bug 8322077
30+
* @bug 8322077 8353359
3131
* @summary Test that Ideal transformations of OrLNode* are being performed as expected.
3232
* @library /test/lib /
3333
* @run driver compiler.c2.irTests.OrLNodeIdealizationTests
@@ -38,7 +38,7 @@ public static void main(String[] args) {
3838
TestFramework.run();
3939
}
4040

41-
@Run(test = { "test1" })
41+
@Run(test = { "test1", "test2", "test3" })
4242
public void runMethod() {
4343
long a = RunInfo.getRandom().nextLong();
4444
long b = RunInfo.getRandom().nextLong();
@@ -55,6 +55,8 @@ public void runMethod() {
5555
@DontCompile
5656
public void assertResult(long a, long b) {
5757
Asserts.assertEQ((~a) | (~b), test1(a, b));
58+
Asserts.assertEQ((a | 3) | 6, test2(a));
59+
Asserts.assertEQ((a | 3) | a, test3(a));
5860
}
5961

6062
// Checks (~a) | (~b) => ~(a & b)
@@ -65,4 +67,19 @@ public void assertResult(long a, long b) {
6567
public long test1(long a, long b) {
6668
return (~a) | (~b);
6769
}
70+
71+
72+
// Checks (a | 3) | 6 => a | (3 | 6) => a | 7
73+
@Test
74+
@IR(counts = { IRNode.OR, "1"})
75+
public long test2(long a) {
76+
return (a | 3) | 6;
77+
}
78+
79+
// Checks (a | 3) | a => (a | a) | 3 => a | 3
80+
@Test
81+
@IR(counts = { IRNode.OR, "1"})
82+
public long test3(long a) {
83+
return (a | 3) | a;
84+
}
6885
}

1 commit comments

Comments
 (1)

openjdk-notifier[bot] commented on Apr 3, 2025

@openjdk-notifier[bot]
Please sign in to comment.