@@ -1713,7 +1713,7 @@ void LIR_Assembler::emit_typecheck_helper(LIR_OpTypeCheck *op, Label* success, L
17131713
17141714 assert_different_registers (obj, k_RInfo, klass_RInfo);
17151715
1716- __ cmpptr (obj, NULL_WORD );
1716+ __ testptr (obj, obj );
17171717 if (op->should_profile ()) {
17181718 Label not_null;
17191719 __ jccb (Assembler::notEqual, not_null);
@@ -1792,7 +1792,7 @@ void LIR_Assembler::emit_typecheck_helper(LIR_OpTypeCheck *op, Label* success, L
17921792 __ pop (klass_RInfo);
17931793 __ pop (klass_RInfo);
17941794 // result is a boolean
1795- __ cmpl (klass_RInfo, 0 );
1795+ __ testl (klass_RInfo, klass_RInfo );
17961796 __ jcc (Assembler::equal, *failure_target);
17971797 // successful cast, fall through to profile or jump
17981798 }
@@ -1806,7 +1806,7 @@ void LIR_Assembler::emit_typecheck_helper(LIR_OpTypeCheck *op, Label* success, L
18061806 __ pop (klass_RInfo);
18071807 __ pop (k_RInfo);
18081808 // result is a boolean
1809- __ cmpl (k_RInfo, 0 );
1809+ __ testl (k_RInfo, k_RInfo );
18101810 __ jcc (Assembler::equal, *failure_target);
18111811 // successful cast, fall through to profile or jump
18121812 }
@@ -1859,7 +1859,7 @@ void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) {
18591859 Label *success_target = op->should_profile () ? &profile_cast_success : &done;
18601860 Label *failure_target = op->should_profile () ? &profile_cast_failure : stub->entry ();
18611861
1862- __ cmpptr (value, NULL_WORD );
1862+ __ testptr (value, value );
18631863 if (op->should_profile ()) {
18641864 Label not_null;
18651865 __ jccb (Assembler::notEqual, not_null);
@@ -1890,7 +1890,7 @@ void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) {
18901890 __ pop (klass_RInfo);
18911891 __ pop (k_RInfo);
18921892 // result is a boolean
1893- __ cmpl (k_RInfo, 0 );
1893+ __ testl (k_RInfo, k_RInfo );
18941894 __ jcc (Assembler::equal, *failure_target);
18951895 // fall through to the success case
18961896
@@ -2664,21 +2664,26 @@ void LIR_Assembler::comp_op(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2,
26642664 // cpu register - constant
26652665 LIR_Const* c = opr2->as_constant_ptr ();
26662666 if (c->type () == T_INT) {
2667- __ cmpl (reg1, c->as_jint ());
2667+ jint i = c->as_jint ();
2668+ if (i == 0 ) {
2669+ __ testl (reg1, reg1);
2670+ } else {
2671+ __ cmpl (reg1, i);
2672+ }
26682673 } else if (c->type () == T_METADATA) {
26692674 // All we need for now is a comparison with null for equality.
26702675 assert (condition == lir_cond_equal || condition == lir_cond_notEqual, " oops" );
26712676 Metadata* m = c->as_metadata ();
26722677 if (m == nullptr ) {
2673- __ cmpptr (reg1, NULL_WORD );
2678+ __ testptr (reg1, reg1 );
26742679 } else {
26752680 ShouldNotReachHere ();
26762681 }
26772682 } else if (is_reference_type (c->type ())) {
26782683 // In 64bit oops are single register
26792684 jobject o = c->as_jobject ();
26802685 if (o == nullptr ) {
2681- __ cmpptr (reg1, NULL_WORD );
2686+ __ testptr (reg1, reg1 );
26822687 } else {
26832688 __ cmpoop (reg1, o, rscratch1);
26842689 }
@@ -3146,7 +3151,7 @@ void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) {
31463151
31473152#endif // _LP64
31483153
3149- __ cmpl (rax, 0 );
3154+ __ testl (rax, rax );
31503155 __ jcc (Assembler::equal, *stub->continuation ());
31513156
31523157 __ mov (tmp, rax);
@@ -3288,7 +3293,7 @@ void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) {
32883293 __ pop (dst);
32893294 __ pop (src);
32903295
3291- __ cmpl (src, 0 );
3296+ __ testl (src, src );
32923297 __ jcc (Assembler::notEqual, cont);
32933298
32943299 __ bind (slow);
0 commit comments