Consider
https://github.com/openjdk/jdk/blob/master/test/hotspot/jtreg/compiler/c2/irTests/MaxMinINodeIdealizationTests.java
Existing tests for the optimization check only one order of nodes, e.g.
// Transform max(x + c0, max(y + c1, z)) to max(add(x, c2), z) if x == y, where c2 = MAX2(c0, c1).
// c0,c1,c2 are constants. x,y,z can be any valid c2 nodes. In this example, x and y are
// RShiftI nodes and z is a ConI.
@Test
@IR(counts = {IRNode.MAX_I, "1",
IRNode.ADD , "1",
})
public int testMax1(int i) {
return Math.max(((i >> 1) + 100), Math.max(((i >> 1) + 150), 200));
}
If Max inputs are swapped, the optimization fails, e.g.
@Test
@IR(counts = {IRNode.MAX_I, "1",
IRNode.ADD , "1",
})
public int testMax1i(int i) {
return Math.max(((i >> 1) + 100), Math.max(200, ((i >> 1) + 150)));
}
That happens because Ideal() looks for Add only as a first input but that is not guaranteed.
// Get left input & constant
Node* x = l;
jint x_off = 0;
if (x->Opcode() == Op_AddI...
https://github.com/openjdk/jdk/blob/master/test/hotspot/jtreg/compiler/c2/irTests/MaxMinINodeIdealizationTests.java
Existing tests for the optimization check only one order of nodes, e.g.
// Transform max(x + c0, max(y + c1, z)) to max(add(x, c2), z) if x == y, where c2 = MAX2(c0, c1).
// c0,c1,c2 are constants. x,y,z can be any valid c2 nodes. In this example, x and y are
// RShiftI nodes and z is a ConI.
@Test
@IR(counts = {IRNode.MAX_I, "1",
IRNode.ADD , "1",
})
public int testMax1(int i) {
return Math.max(((i >> 1) + 100), Math.max(((i >> 1) + 150), 200));
}
If Max inputs are swapped, the optimization fails, e.g.
@Test
@IR(counts = {IRNode.MAX_I, "1",
IRNode.ADD , "1",
})
public int testMax1i(int i) {
return Math.max(((i >> 1) + 100), Math.max(200, ((i >> 1) + 150)));
}
That happens because Ideal() looks for Add only as a first input but that is not guaranteed.
// Get left input & constant
Node* x = l;
jint x_off = 0;
if (x->Opcode() == Op_AddI...
- relates to
-
JDK-8290248 Implement MaxINode::Ideal transformation
-
- Resolved
-