From 32271b8bfd2325ebb0d7fd338f3454be7dd1f998 Mon Sep 17 00:00:00 2001
Date: Fri, 30 Oct 2020 18:15:32 +0800
Subject: [PATCH] 8250861: Crash in MinINode::Ideal(PhaseGVN*, bool)

Summary: C2: Added missing NULL checks.
LLT: N/A
Bug url: https://bugs.openjdk.java.net/browse/JDK-8250861
---
 hotspot/src/share/vm/opto/addnode.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hotspot/src/share/vm/opto/addnode.cpp b/hotspot/src/share/vm/opto/addnode.cpp
index 7bfa6e404..61b376e9b 100644
--- a/hotspot/src/share/vm/opto/addnode.cpp
+++ b/hotspot/src/share/vm/opto/addnode.cpp
@@ -921,7 +921,7 @@ Node *MinINode::Ideal(PhaseGVN *phase, bool can_reshape) {
 
     // Transform MIN2(x + c0, MIN2(x + c1, z)) into MIN2(x + MIN2(c0, c1), z)
     // if x == y and the additions can't overflow.
-    if (phase->eqv(x,y) &&
+    if (phase->eqv(x,y) && tx != NULL &&
         !can_overflow(tx, x_off) &&
         !can_overflow(tx, y_off)) {
       return new (phase->C) MinINode(phase->transform(new (phase->C) AddINode(x, phase->intcon(MIN2(x_off, y_off)))), r->in(2));
@@ -929,7 +929,7 @@ Node *MinINode::Ideal(PhaseGVN *phase, bool can_reshape) {
   } else {
     // Transform MIN2(x + c0, y + c1) into x + MIN2(c0, c1)
     // if x == y and the additions can't overflow.
-    if (phase->eqv(x,y) &&
+    if (phase->eqv(x,y) && tx != NULL &&
         !can_overflow(tx, x_off) &&
         !can_overflow(tx, y_off)) {
       return new (phase->C) AddINode(x,phase->intcon(MIN2(x_off,y_off)));
-- 
2.12.3

