Re: [PATCH][AArch64] Remove aarch64_simd_attr_length_move

2016-05-31 Thread James Greenhalgh
On Fri, May 27, 2016 at 05:57:17PM +0100, Kyrill Tkachov wrote:
> Hi all,
> 
> I notice that we can do without aarch64_simd_attr_length_move. The move 
> alternatives for
> the OI,CI,XImode modes that involve memory operands all use a single 
> load/store so are always
> length 4, whereas the register-to-register moves have a statically-known 
> length of
> (GET_MODE_BITSIZE (mode) / 128) * 4, i.e. 4 bytes for every 128-bit SIMD move 
> instruction.
> This is already encoded in the insn_count mode attribute so use that when 
> needed.
> 
> That way we avoid a call to recog and a switch statement just to get the 
> length of an insn.
> 
> Bootstrapped and tested on aarch64.
> 
> Ok for trunk?

OK.

Thanks,
James

> 
> Thanks,
> Kyrill
> 
> 2016-05-27  Kyrylo Tkachov  
> 
> * config/aarch64/aarch64.c (aarch64_simd_attr_length_move): Delete.
> * config/aarch64/aarch64-protos.h (aarch64_simd_attr_length_move):
> Delete prototype.
> * config/aarch64/iterators.md (insn_count): Add descriptive comment.
> * config/aarch64/aarch64-simd.md (*aarch64_mov, VSTRUCT modes):
> Remove use of aarch64_simd_attr_length_move, set length attribute
> directly.
> (*aarch64_be_movoi): Likewise.
> (*aarch64_be_movci): Likewise.
> (*aarch64_be_movxi): Likewise.



[PATCH][AArch64] Remove aarch64_simd_attr_length_move

2016-05-27 Thread Kyrill Tkachov

Hi all,

I notice that we can do without aarch64_simd_attr_length_move. The move 
alternatives for
the OI,CI,XImode modes that involve memory operands all use a single load/store 
so are always
length 4, whereas the register-to-register moves have a statically-known length 
of
(GET_MODE_BITSIZE (mode) / 128) * 4, i.e. 4 bytes for every 128-bit SIMD move 
instruction.
This is already encoded in the insn_count mode attribute so use that when 
needed.

That way we avoid a call to recog and a switch statement just to get the length 
of an insn.

Bootstrapped and tested on aarch64.

Ok for trunk?

Thanks,
Kyrill

2016-05-27  Kyrylo Tkachov  

* config/aarch64/aarch64.c (aarch64_simd_attr_length_move): Delete.
* config/aarch64/aarch64-protos.h (aarch64_simd_attr_length_move):
Delete prototype.
* config/aarch64/iterators.md (insn_count): Add descriptive comment.
* config/aarch64/aarch64-simd.md (*aarch64_mov, VSTRUCT modes):
Remove use of aarch64_simd_attr_length_move, set length attribute
directly.
(*aarch64_be_movoi): Likewise.
(*aarch64_be_movci): Likewise.
(*aarch64_be_movxi): Likewise.
diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h
index 6e97c01cf768ec5ca2f18e795a8085b8a247f5b6..b39eac94ae6fdef4c39bd1bab5b832f3a1bef618 100644
--- a/gcc/config/aarch64/aarch64-protos.h
+++ b/gcc/config/aarch64/aarch64-protos.h
@@ -337,7 +337,6 @@ machine_mode aarch64_hard_regno_caller_save_mode (unsigned, unsigned,
 		   machine_mode);
 int aarch64_hard_regno_mode_ok (unsigned, machine_mode);
 int aarch64_hard_regno_nregs (unsigned, machine_mode);
-int aarch64_simd_attr_length_move (rtx_insn *);
 int aarch64_uxt_size (int, HOST_WIDE_INT);
 int aarch64_vec_fpconst_pow_of_2 (rtx);
 rtx aarch64_final_eh_return_addr (void);
diff --git a/gcc/config/aarch64/aarch64-simd.md b/gcc/config/aarch64/aarch64-simd.md
index 8be69357eb086e288ae838dc536be8a2ebe0463b..2ca48aefd3dac120c5feeb0ebda6f258d120384c 100644
--- a/gcc/config/aarch64/aarch64-simd.md
+++ b/gcc/config/aarch64/aarch64-simd.md
@@ -4639,7 +4639,7 @@ (define_insn "*aarch64_mov"
ld1\\t{%S0.16b - %0.16b}, %1"
   [(set_attr "type" "multiple,neon_store_reg_q,\
 		 neon_load_reg_q")
-   (set (attr "length") (symbol_ref "aarch64_simd_attr_length_move (insn)"))]
+   (set_attr "length" ",4,4")]
 )
 
 (define_insn "aarch64_be_ld1"
@@ -4672,7 +4672,7 @@ (define_insn "*aarch64_be_movoi"
stp\\t%q1, %R1, %0
ldp\\t%q0, %R0, %1"
   [(set_attr "type" "multiple,neon_stp_q,neon_ldp_q")
-   (set (attr "length") (symbol_ref "aarch64_simd_attr_length_move (insn)"))]
+   (set_attr "length" "8,4,4")]
 )
 
 (define_insn "*aarch64_be_movci"
@@ -4683,7 +4683,7 @@ (define_insn "*aarch64_be_movci"
|| register_operand (operands[1], CImode))"
   "#"
   [(set_attr "type" "multiple")
-   (set (attr "length") (symbol_ref "aarch64_simd_attr_length_move (insn)"))]
+   (set_attr "length" "12,4,4")]
 )
 
 (define_insn "*aarch64_be_movxi"
@@ -4694,7 +4694,7 @@ (define_insn "*aarch64_be_movxi"
|| register_operand (operands[1], XImode))"
   "#"
   [(set_attr "type" "multiple")
-   (set (attr "length") (symbol_ref "aarch64_simd_attr_length_move (insn)"))]
+   (set_attr "length" "16,4,4")]
 )
 
 (define_split
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 2d62c9ba9548aefdb986e97a1419b1565c150b63..49cd50b61cf4ba8074a44ae4029316a8af2f793b 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -10765,33 +10765,6 @@ aarch64_simd_emit_reg_reg_move (rtx *operands, enum machine_mode mode,
 		  gen_rtx_REG (mode, rsrc + count - i - 1));
 }
 
-/* Compute and return the length of aarch64_simd_mov, where  is
-   one of VSTRUCT modes: OI, CI or XI.  */
-int
-aarch64_simd_attr_length_move (rtx_insn *insn)
-{
-  machine_mode mode;
-
-  extract_insn_cached (insn);
-
-  if (REG_P (recog_data.operand[0]) && REG_P (recog_data.operand[1]))
-{
-  mode = GET_MODE (recog_data.operand[0]);
-  switch (mode)
-	{
-	case OImode:
-	  return 8;
-	case CImode:
-	  return 12;
-	case XImode:
-	  return 16;
-	default:
-	  gcc_unreachable ();
-	}
-}
-  return 4;
-}
-
 /* Compute and return the length of aarch64_simd_reglist, where  is
one of VSTRUCT modes: OI, CI, or XI.  */
 int
diff --git a/gcc/config/aarch64/iterators.md b/gcc/config/aarch64/iterators.md
index d9bd39112c3f4af19781290778babdf919f1c514..43b22d81cda30398564af2f2fcaefceb215ec04c 100644
--- a/gcc/config/aarch64/iterators.md
+++ b/gcc/config/aarch64/iterators.md
@@ -715,6 +715,7 @@ (define_mode_attr vp [(V8QI "v") (V16QI "v")
 (define_mode_attr vsi2qi [(V2SI "v8qi") (V4SI "v16qi")])
 (define_mode_attr VSI2QI [(V2SI "V8QI") (V4SI "V16QI")])
 
+;; Sum of lengths of instructions needed to move vector registers of a mode.
 (define_mode_attr insn_count [(OI "8") (CI "12") (XI "16")])
 
 ;; -fpic small model GOT reloc modifers: gotpage_lo15/lo14 for ILP64/32.