mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-22 20:14:43 +02:00
8153357: C2 creates incorrect cast after eliminating phi with unique input
Refine C2's logic to determine the type of cast node added. Reviewed-by: kvn
This commit is contained in:
parent
acab1fddac
commit
c05dd2fdca
1 changed files with 5 additions and 2 deletions
|
@ -1703,16 +1703,19 @@ Node *PhiNode::Ideal(PhaseGVN *phase, bool can_reshape) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uncasted) {
|
if (uncasted) {
|
||||||
// Wait until after parsing for the type information to propagate from the casts
|
// Add a cast node between the phi to be removed and its unique input.
|
||||||
|
// Wait until after parsing for the type information to propagate from the casts.
|
||||||
assert(can_reshape, "Invalid during parsing");
|
assert(can_reshape, "Invalid during parsing");
|
||||||
const Type* phi_type = bottom_type();
|
const Type* phi_type = bottom_type();
|
||||||
assert(phi_type->isa_int() || phi_type->isa_ptr(), "bad phi type");
|
assert(phi_type->isa_int() || phi_type->isa_ptr(), "bad phi type");
|
||||||
int opcode;
|
int opcode;
|
||||||
|
// Determine the type of cast to be added.
|
||||||
if (phi_type->isa_int()) {
|
if (phi_type->isa_int()) {
|
||||||
opcode = Op_CastII;
|
opcode = Op_CastII;
|
||||||
} else {
|
} else {
|
||||||
const Type* uin_type = phase->type(uin);
|
const Type* uin_type = phase->type(uin);
|
||||||
if (phi_type->join(TypePtr::NOTNULL) == uin_type->join(TypePtr::NOTNULL)) {
|
if ((phi_type->join(TypePtr::NOTNULL) == uin_type->join(TypePtr::NOTNULL)) ||
|
||||||
|
(!phi_type->isa_oopptr() && !uin_type->isa_oopptr())) {
|
||||||
opcode = Op_CastPP;
|
opcode = Op_CastPP;
|
||||||
} else {
|
} else {
|
||||||
opcode = Op_CheckCastPP;
|
opcode = Op_CheckCastPP;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue