-
Enhancement
-
Resolution: Fixed
-
P4
-
8, 9
-
b64
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8082632 | emb-9 | Tobias Hartmann | P4 | Resolved | Fixed | team |
JDK-8228608 | openjdk8u232 | Tobias Hartmann | P4 | Resolved | Fixed | b01 |
C2 adds an unnecessary sign extension while compiling a byte array access.
public static byte[] byteArr;
public static byte accessByte(int index) {
return byteArr[index];
}
The generated code contains:
0x00007f76f4747208: movslq %esi,%r11
0x00007f76f474720b: movsbl 0x10(%r10,%r11,1),%eax
Where the 'movslq' instruction is not necessary because we emit range checks guaranteeing that index %esi is not negative.
For a char array access no such sign extension is created:
public static char[] charArr;
public static char accessChar(int index) {
return charArr[index];
}
0x00007fab3916b188: movzwl 0x10(%r10,%rsi,2),%eax
public static byte[] byteArr;
public static byte accessByte(int index) {
return byteArr[index];
}
The generated code contains:
0x00007f76f4747208: movslq %esi,%r11
0x00007f76f474720b: movsbl 0x10(%r10,%r11,1),%eax
Where the 'movslq' instruction is not necessary because we emit range checks guaranteeing that index %esi is not negative.
For a char array access no such sign extension is created:
public static char[] charArr;
public static char accessChar(int index) {
return charArr[index];
}
0x00007fab3916b188: movzwl 0x10(%r10,%rsi,2),%eax
- backported by
-
JDK-8082632 Unnecessary sign extension for byte array access
- Resolved
-
JDK-8228608 Unnecessary sign extension for byte array access
- Resolved
- is blocked by
-
JDK-8075324 Costs of memory operands in aarch64.ad are inconsistent
- Resolved
- relates to
-
JDK-8074124 Most Unsafe.get*() access shapes are losing vs. the plain Java accesses
- Open