[aarch64-port-dev ] RFR: Minor optimisation for divide by 2

Edward Nevill ed at camswl.com
Mon May 12 14:45:10 UTC 2014


On Mon, 2014-05-12 at 13:10 +0100, Andrew Haley wrote:

> Why is there no long version of this?

Here is the patch for the long case,

Regards,
Ed.

--- CUT HERE ---
# HG changeset patch
# User Edward Nevill edward.nevill at linaro.org
# Date 1399905423 -3600
#      Mon May 12 15:37:03 2014 +0100
# Node ID 5fb4ac5c2400d120e9ea1de2d3c6a218b71ea9b2
# Parent  6523308f9626004171794372e5577a0f6939b4df
Optimise long divide by 2

diff -r 6523308f9626 -r 5fb4ac5c2400 src/cpu/aarch64/vm/aarch64.ad
--- a/src/cpu/aarch64/vm/aarch64.ad	Mon May 12 13:41:43 2014 +0100
+++ b/src/cpu/aarch64/vm/aarch64.ad	Mon May 12 15:37:03 2014 +0100
@@ -3464,6 +3464,16 @@
   interface(CONST_INTER);
 %}
 
+operand immL_63()
+%{
+  predicate(n->get_int() == 63);
+  match(ConI);
+
+  op_cost(0);
+  format %{ %}
+  interface(CONST_INTER);
+%}
+
 operand immL_255()
 %{
   predicate(n->get_int() == 255);
@@ -7353,6 +7363,30 @@
   ins_pipe(pipe_class_default);
 %}
 
+instruct signExtractL(iRegLNoSp dst, iRegL src, immL_63 div1, immL_63
div2) %{
+  match(Set dst (URShiftL (RShiftL src div1) div2));
+  ins_cost(INSN_COST);
+  format %{ "lsr $dst, $src, $div1" %}
+  ins_encode %{
+    __ lsr(as_Register($dst$$reg), as_Register($src$$reg), 63);
+  %}
+  ins_pipe(pipe_class_default);
+%}
+
+instruct div2RoundL(iRegLNoSp dst, iRegL src, immL_63 div1, immL_63
div2) %{
+  match(Set dst (AddL src (URShiftL (RShiftL src div1) div2)));
+  ins_cost(INSN_COST);
+  format %{ "add $dst, $src, $div1" %}
+
+  ins_encode %{
+    __ add(as_Register($dst$$reg),
+	      as_Register($src$$reg),
+	      as_Register($src$$reg),
+	      Assembler::LSR, 63);
+  %}
+  ins_pipe(pipe_class_default);
+%}
+
 // Integer Remainder
 
 instruct modI(iRegINoSp dst, iRegIorL2I src1, iRegIorL2I src2) %{
--- CUT HERE ---




More information about the aarch64-port-dev mailing list