The fix for 5107650 accidentally removed the identity for x | 0. Previously this was handled by AddNode::Identity but when OrINode::Identity was introduced it didn't call it's super so now x | 0 is no longer being optimized. This was noticed in spec/jbb/infra/Util/DisplayScreen.putInt. The code there uses a bitwise or instead of a logical or for a range check, but this shouldn't result in any different code, apart from any reordering allowed by different code shapes. here's a test case with both forms.
public class or {
static public int v = 0;
static public int l = 10;
static public int e = 0;
public static void main(String[] args) {
for (int i = 0; i < 100000; i++) {
logic_or(i % 10);
}
for (int i = 0; i < 100000; i++) {
bitwise_or(i % 10);
}
}
public static void bitwise_or(int x) {
if ((x < 0) | x >= l) {
throw new InternalError("out of range " + x);
} else {
e++;
}
}
public static void logic_or(int x) {
if ((x < 0) || x >= l) {
throw new InternalError("out of range " + x);
} else {
e++;
}
}
}
OrLNode has the same problem.
###@###.### 2005-03-14 20:47:08 GMT
public class or {
static public int v = 0;
static public int l = 10;
static public int e = 0;
public static void main(String[] args) {
for (int i = 0; i < 100000; i++) {
logic_or(i % 10);
}
for (int i = 0; i < 100000; i++) {
bitwise_or(i % 10);
}
}
public static void bitwise_or(int x) {
if ((x < 0) | x >= l) {
throw new InternalError("out of range " + x);
} else {
e++;
}
}
public static void logic_or(int x) {
if ((x < 0) || x >= l) {
throw new InternalError("out of range " + x);
} else {
e++;
}
}
}
OrLNode has the same problem.
###@###.### 2005-03-14 20:47:08 GMT
- relates to
-
JDK-5107650 AND/OR identities
-
- Resolved
-