8182161: aarch64: combine andr+cbnz into tbnz when possible
authorfyang
Wed, 14 Jun 2017 17:33:54 +0800
changeset 46538 44ea5e0f2901
parent 46537 8f9a3ff618bd
child 46539 c23c825bcfc2
8182161: aarch64: combine andr+cbnz into tbnz when possible Summary: Combine andr+cbnz into tbnz when possible to save one instruction Reviewed-by: aph
hotspot/src/cpu/aarch64/vm/c1_LIRAssembler_aarch64.cpp
hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.cpp
hotspot/src/cpu/aarch64/vm/jniFastGetField_aarch64.cpp
hotspot/src/cpu/aarch64/vm/templateTable_aarch64.cpp
--- a/hotspot/src/cpu/aarch64/vm/c1_LIRAssembler_aarch64.cpp	Tue Jun 13 16:29:42 2017 +0000
+++ b/hotspot/src/cpu/aarch64/vm/c1_LIRAssembler_aarch64.cpp	Wed Jun 14 17:33:54 2017 +0800
@@ -2740,8 +2740,7 @@
         // set already but no need to check.
         __ cbz(rscratch1, next);
 
-        __ andr(rscratch1, tmp, TypeEntries::type_unknown);
-        __ cbnz(rscratch1, next); // already unknown. Nothing to do anymore.
+        __ tbnz(tmp, exact_log2(TypeEntries::type_unknown), next); // already unknown. Nothing to do anymore.
 
         if (TypeEntries::is_type_none(current_klass)) {
           __ cbz(rscratch2, none);
@@ -2761,8 +2760,7 @@
                ciTypeEntries::valid_ciklass(current_klass) != exact_klass, "conflict only");
 
         __ ldr(tmp, mdo_addr);
-        __ andr(rscratch1, tmp, TypeEntries::type_unknown);
-        __ cbnz(rscratch1, next); // already unknown. Nothing to do anymore.
+        __ tbnz(tmp, exact_log2(TypeEntries::type_unknown), next); // already unknown. Nothing to do anymore.
       }
 
       // different than before. Cannot keep accurate profile.
@@ -2812,8 +2810,7 @@
                ciTypeEntries::valid_ciklass(current_klass) != exact_klass, "inconsistent");
 
         __ ldr(tmp, mdo_addr);
-        __ andr(rscratch1, tmp, TypeEntries::type_unknown);
-        __ cbnz(rscratch1, next); // already unknown. Nothing to do anymore.
+        __ tbnz(tmp, exact_log2(TypeEntries::type_unknown), next); // already unknown. Nothing to do anymore.
 
         __ orr(tmp, tmp, TypeEntries::type_unknown);
         __ str(tmp, mdo_addr);
--- a/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.cpp	Tue Jun 13 16:29:42 2017 +0000
+++ b/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.cpp	Wed Jun 14 17:33:54 2017 +0800
@@ -1754,8 +1754,7 @@
     // Load the offset of the area within the MDO used for
     // parameters. If it's negative we're not profiling any parameters
     ldr(tmp1, Address(mdp, in_bytes(MethodData::parameters_type_data_di_offset()) - in_bytes(MethodData::data_offset())));
-    cmp(tmp1, 0u);
-    br(Assembler::LT, profile_continue);
+    tbnz(tmp1, 63, profile_continue);  // i.e. sign bit set
 
     // Compute a pointer to the area for parameters from the offset
     // and move the pointer to the slot for the last
--- a/hotspot/src/cpu/aarch64/vm/jniFastGetField_aarch64.cpp	Tue Jun 13 16:29:42 2017 +0000
+++ b/hotspot/src/cpu/aarch64/vm/jniFastGetField_aarch64.cpp	Wed Jun 14 17:33:54 2017 +0800
@@ -76,8 +76,7 @@
           SafepointSynchronize::safepoint_counter_addr(), offset);
   Address safepoint_counter_addr(rcounter_addr, offset);
   __ ldrw(rcounter, safepoint_counter_addr);
-  __ andw(rscratch1, rcounter, 1);
-  __ cbnzw(rscratch1, slow);
+  __ tbnz(rcounter, 0, slow);
   __ eor(robj, c_rarg1, rcounter);
   __ eor(robj, robj, rcounter);               // obj, since
                                               // robj ^ rcounter ^ rcounter == robj
--- a/hotspot/src/cpu/aarch64/vm/templateTable_aarch64.cpp	Tue Jun 13 16:29:42 2017 +0000
+++ b/hotspot/src/cpu/aarch64/vm/templateTable_aarch64.cpp	Wed Jun 14 17:33:54 2017 +0800
@@ -246,8 +246,7 @@
       assert(load_bc_into_bc_reg, "we use bc_reg as temp");
       __ get_cache_and_index_and_bytecode_at_bcp(temp_reg, bc_reg, temp_reg, byte_no, 1);
       __ movw(bc_reg, bc);
-      __ cmpw(temp_reg, (unsigned) 0);
-      __ br(Assembler::EQ, L_patch_done);  // don't patch
+      __ cbzw(temp_reg, L_patch_done);  // don't patch
     }
     break;
   default: