8136615: aarch64: elide DecodeN when followed by CmpP 0
authorenevill
Wed, 16 Sep 2015 13:50:57 +0000
changeset 33079 65fc34b22fdb
parent 33078 9452eb89c16d
child 33080 73c9bbe40ff8
8136615: aarch64: elide DecodeN when followed by CmpP 0 Summary: remove DecodeN when comparing a narrow oop with 0 Reviewed-by: kvn, adinn
hotspot/src/cpu/aarch64/vm/aarch64.ad
--- a/hotspot/src/cpu/aarch64/vm/aarch64.ad	Tue Sep 22 15:25:34 2015 +0200
+++ b/hotspot/src/cpu/aarch64/vm/aarch64.ad	Wed Sep 16 13:50:57 2015 +0000
@@ -13814,6 +13814,25 @@
   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
+            || n->in(1)->as_Bool()->_test._test == BoolTest::eq);
+  effect(USE labl);
+
+  ins_cost(BRANCH_COST);
+  format %{ "cb$cmp   $oop, $labl" %}
+  ins_encode %{
+    Label* L = $labl$$label;
+    Assembler::Condition cond = (Assembler::Condition)$cmp$$cmpcode;
+    if (cond == Assembler::EQ)
+      __ cbzw($oop$$Register, *L);
+    else
+      __ cbnzw($oop$$Register, *L);
+  %}
+  ins_pipe(pipe_cmp_branch);
+%}
+
 // Conditional Far Branch
 // Conditional Far Branch Unsigned
 // TODO: fixme