From c4e39cea51faa01ec7dcd447c2e89ef988e6a7fb Mon Sep 17 00:00:00 2001 From: Ashay Rane <253344819+raneashay@users.noreply.github.com> Date: Mon, 2 Mar 2026 16:49:28 +0000 Subject: [PATCH] 8373635: C2: Wrong constant in GraphKit::basic_plus_adr() Reviewed-by: qamai, mhaessig --- src/hotspot/share/opto/graphKit.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/opto/graphKit.cpp b/src/hotspot/share/opto/graphKit.cpp index 084b137f313..c969abb85bb 100644 --- a/src/hotspot/share/opto/graphKit.cpp +++ b/src/hotspot/share/opto/graphKit.cpp @@ -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) ); }