8373635: C2: Wrong constant in GraphKit::basic_plus_adr()

Reviewed-by: qamai, mhaessig
This commit is contained in:
Ashay Rane 2026-03-02 16:49:28 +00:00 committed by Quan Anh Mai
parent 4fbc29199c
commit c4e39cea51

View File

@ -1177,7 +1177,21 @@ bool GraphKit::compute_stack_effects(int& inputs, int& depth) {
//------------------------------basic_plus_adr---------------------------------
Node* GraphKit::basic_plus_adr(Node* base, Node* ptr, Node* offset) {
// short-circuit a common case
if (offset == intcon(0)) return ptr;
if (offset == MakeConX(0)) {
return ptr;
}
#ifdef ASSERT
// Both 32-bit and 64-bit zeros should have been handled by the previous `if`
// statement, so if we see either 32-bit or 64-bit zeros here, then we have a
// problem.
if (offset->is_Con()) {
const Type* t = offset->bottom_type();
bool is_zero_int = t->isa_int() && t->is_int()->get_con() == 0;
bool is_zero_long = t->isa_long() && t->is_long()->get_con() == 0;
assert(!is_zero_int && !is_zero_long,
"Unexpected zero offset - should have matched MakeConX(0)");
}
#endif
return _gvn.transform( new AddPNode(base, ptr, offset) );
}