diff a/src/hotspot/share/c1/c1_Optimizer.cpp b/src/hotspot/share/c1/c1_Optimizer.cpp
--- a/src/hotspot/share/c1/c1_Optimizer.cpp
+++ b/src/hotspot/share/c1/c1_Optimizer.cpp
@@ -87,11 +87,12 @@
   }
 
   virtual void block_do(BlockBegin* block);
 
  private:
-  Value make_ifop(Value x, Instruction::Condition cond, Value y, Value tval, Value fval);
+  Value make_ifop(Value x, Instruction::Condition cond, Value y, Value tval, Value fval,
+                  ValueStack* state_before, bool substitutability_check);
 };
 
 void CE_Eliminator::block_do(BlockBegin* block) {
   // 1) find conditional expression
   // check if block ends with an If
@@ -216,11 +217,12 @@
     f_value = new Constant(f_const->type());
     NOT_PRODUCT(f_value->set_printable_bci(if_->printable_bci()));
     cur_end = cur_end->set_next(f_value);
   }
 
-  Value result = make_ifop(if_->x(), if_->cond(), if_->y(), t_value, f_value);
+  Value result = make_ifop(if_->x(), if_->cond(), if_->y(), t_value, f_value,
+                           if_->state_before(), if_->substitutability_check());
   assert(result != nullptr, "make_ifop must return a non-null instruction");
   if (!result->is_linked() && result->can_be_linked()) {
     NOT_PRODUCT(result->set_printable_bci(if_->printable_bci()));
     cur_end = cur_end->set_next(result);
   }
@@ -271,13 +273,14 @@
   _hir->verify_local(blocks_to_verify_later);
 #endif // DO_DELAYED_VERIFICATION
 
 }
 
-Value CE_Eliminator::make_ifop(Value x, Instruction::Condition cond, Value y, Value tval, Value fval) {
+Value CE_Eliminator::make_ifop(Value x, Instruction::Condition cond, Value y, Value tval, Value fval,
+                               ValueStack* state_before, bool substitutability_check) {
   if (!OptimizeIfOps) {
-    return new IfOp(x, cond, y, tval, fval);
+    return new IfOp(x, cond, y, tval, fval, state_before, substitutability_check);
   }
 
   tval = tval->subst();
   fval = fval->subst();
   if (tval == fval) {
@@ -308,11 +311,11 @@
 
           _ifop_count++;
           if (new_tval == new_fval) {
             return new_tval;
           } else {
-            return new IfOp(x_ifop->x(), x_ifop_cond, x_ifop->y(), new_tval, new_fval);
+            return new IfOp(x_ifop->x(), x_ifop_cond, x_ifop->y(), new_tval, new_fval, state_before, substitutability_check);
           }
         }
       }
     } else {
       Constant* x_const = x->as_Constant();
@@ -324,11 +327,11 @@
           return x_compare_res == Constant::cond_true ? tval : fval;
         }
       }
     }
   }
-  return new IfOp(x, cond, y, tval, fval);
+  return new IfOp(x, cond, y, tval, fval, state_before, substitutability_check);
 }
 
 void Optimizer::eliminate_conditional_expressions() {
   // find conditional expressions & replace them with IfOps
   CE_Eliminator ce(ir());
@@ -464,11 +467,11 @@
       if (!con || !ifop) {
         ifop = if_->y()->as_IfOp();
         con  = if_->x()->as_Constant();
         swapped = true;
       }
-      if (con && ifop) {
+      if (con && ifop && !ifop->substitutability_check()) {
         Constant* tval = ifop->tval()->as_Constant();
         Constant* fval = ifop->fval()->as_Constant();
         if (tval && fval) {
           // Find the instruction before if_, starting with ifop.
           // When if_ and ifop are not in the same block, prev
@@ -489,11 +492,11 @@
 
             BlockBegin* tblock = tval->compare(cond, con, tsux, fsux);
             BlockBegin* fblock = fval->compare(cond, con, tsux, fsux);
             if (tblock != fblock && !if_->is_safepoint()) {
               If* newif = new If(ifop->x(), ifop->cond(), false, ifop->y(),
-                                 tblock, fblock, if_->state_before(), if_->is_safepoint());
+                                 tblock, fblock, if_->state_before(), if_->is_safepoint(), ifop->substitutability_check());
               newif->set_state(if_->state()->copy());
 
               assert(prev->next() == if_, "must be guaranteed by above search");
               NOT_PRODUCT(newif->set_printable_bci(if_->printable_bci()));
               prev->set_next(newif);
@@ -584,10 +587,11 @@
   void do_UnsafeGet      (UnsafeGet*       x);
   void do_UnsafePut      (UnsafePut*       x);
   void do_UnsafeGetAndSet(UnsafeGetAndSet* x);
   void do_ProfileCall    (ProfileCall*     x);
   void do_ProfileReturnType (ProfileReturnType*  x);
+  void do_ProfileACmpTypes(ProfileACmpTypes*  x);
   void do_ProfileInvoke  (ProfileInvoke*   x);
   void do_RuntimeCall    (RuntimeCall*     x);
   void do_MemBar         (MemBar*          x);
   void do_RangeCheckPredicate(RangeCheckPredicate* x);
 #ifdef ASSERT
@@ -712,10 +716,11 @@
   void handle_Intrinsic       (Intrinsic* x);
   void handle_ExceptionObject (ExceptionObject* x);
   void handle_Phi             (Phi* x);
   void handle_ProfileCall     (ProfileCall* x);
   void handle_ProfileReturnType (ProfileReturnType* x);
+  void handle_ProfileACmpTypes(ProfileACmpTypes* x);
 };
 
 
 // NEEDS_CLEANUP
 // There may be other instructions which need to clear the last
@@ -769,10 +774,11 @@
 void NullCheckVisitor::do_UnsafeGetAndSet(UnsafeGetAndSet* x) {}
 void NullCheckVisitor::do_ProfileCall    (ProfileCall*     x) { nce()->clear_last_explicit_null_check();
                                                                 nce()->handle_ProfileCall(x); }
 void NullCheckVisitor::do_ProfileReturnType (ProfileReturnType* x) { nce()->handle_ProfileReturnType(x); }
 void NullCheckVisitor::do_ProfileInvoke  (ProfileInvoke*   x) {}
+void NullCheckVisitor::do_ProfileACmpTypes(ProfileACmpTypes* x) { nce()->handle_ProfileACmpTypes(x); }
 void NullCheckVisitor::do_RuntimeCall    (RuntimeCall*     x) {}
 void NullCheckVisitor::do_MemBar         (MemBar*          x) {}
 void NullCheckVisitor::do_RangeCheckPredicate(RangeCheckPredicate* x) {}
 #ifdef ASSERT
 void NullCheckVisitor::do_Assert         (Assert*          x) {}
@@ -1196,10 +1202,15 @@
 
 void NullCheckEliminator::handle_ProfileReturnType(ProfileReturnType* x) {
   x->set_needs_null_check(!set_contains(x->ret()));
 }
 
+void NullCheckEliminator::handle_ProfileACmpTypes(ProfileACmpTypes* x) {
+  x->set_left_maybe_null(!set_contains(x->left()));
+  x->set_right_maybe_null(!set_contains(x->right()));
+}
+
 void Optimizer::eliminate_null_checks() {
   ResourceMark rm;
 
   NullCheckEliminator nce(this);
 
