8150038: aarch64: make use of CBZ and CBNZ when comparing narrow pointer with zero
authorfyang
Wed, 17 Feb 2016 20:19:24 +0800
changeset 36339 718dd000cd20
parent 36338 de236db57636
child 36340 f1401b7f2d58
8150038: aarch64: make use of CBZ and CBNZ when comparing narrow pointer with zero Summary: aarch64: c2 make use of CBZ and CBNZ when comparing narrow pointer with zero Reviewed-by: aph Contributed-by: felix.yang@linaro.org
hotspot/src/cpu/aarch64/vm/aarch64.ad
--- a/hotspot/src/cpu/aarch64/vm/aarch64.ad	Wed Feb 24 04:45:50 2016 -0800
+++ b/hotspot/src/cpu/aarch64/vm/aarch64.ad	Wed Feb 17 20:19:24 2016 +0800
@@ -14191,6 +14191,25 @@
   ins_pipe(pipe_cmp_branch);
 %}
 
+instruct cmpN_imm0_branch(cmpOp cmp, iRegN op1, immN0 op2, label labl, rFlagsReg cr) %{
+  match(If cmp (CmpN op1 op2));
+  predicate(n->in(1)->as_Bool()->_test._test == BoolTest::ne
+	    || n->in(1)->as_Bool()->_test._test == BoolTest::eq);
+  effect(USE labl);
+
+  ins_cost(BRANCH_COST);
+  format %{ "cbw$cmp   $op1, $labl" %}
+  ins_encode %{
+    Label* L = $labl$$label;
+    Assembler::Condition cond = (Assembler::Condition)$cmp$$cmpcode;
+    if (cond == Assembler::EQ)
+      __ cbzw($op1$$Register, *L);
+    else
+      __ cbnzw($op1$$Register, *L);
+  %}
+  ins_pipe(pipe_cmp_branch);
+%}
+
 instruct cmpP_narrowOop_imm0_branch(cmpOp cmp, iRegN oop, immP0 zero, label labl, rFlagsReg cr) %{
   match(If cmp (CmpP (DecodeN oop) zero));
   predicate(n->in(1)->as_Bool()->_test._test == BoolTest::ne