Re: [SH] PR 50751 - add HImode displacement addressing support

2012-04-11 Thread Kaz Kojima
Oleg Endo oleg.e...@t-online.de wrote:
 BTW, do you have the numbers of CSiBE with this?
 
 
 Only for -m4-single -ml -O2 -mpretend-cmove so far.
 Not so spectacular :T
 I'll also do a comparison of more variants to see if something went
 really bad.  It's a bit difficult to isolate the degradations because
 there's quite some code reordering happening after the patch... 

Thanks for numbers!  Looks good considering that HImode would be
less frequently used than QImode in the usual working set.

Regards,
kaz


Re: [SH] PR 50751 - add HImode displacement addressing support

2012-04-11 Thread Oleg Endo
On Wed, 2012-04-11 at 22:10 +0900, Kaz Kojima wrote:
 Oleg Endo oleg.e...@t-online.de wrote:
  BTW, do you have the numbers of CSiBE with this?
  
  
  Only for -m4-single -ml -O2 -mpretend-cmove so far.
  Not so spectacular :T
  I'll also do a comparison of more variants to see if something went
  really bad.  It's a bit difficult to isolate the degradations because
  there's quite some code reordering happening after the patch... 
 
 Thanks for numbers!  Looks good considering that HImode would be
 less frequently used than QImode in the usual working set.
 
Sure, no problem.
I think there is some room for improvement in the
'sh_find_mov_disp_adjust' function.  If it was a bit smarter, all the
displacement move insns would instantly benefit from it.

Cheers,
Oleg



Re: [SH] PR 50751 - add HImode displacement addressing support

2012-04-10 Thread Kaz Kojima
Oleg Endo oleg.e...@t-online.de wrote:
 The attached patch adds HImode addressing support.
 Tested against rev. 186243 with
 sudo make -k check RUNTESTFLAGS=--target_board=sh-sim
 \{-m2/-ml,-m2/-mb,-m2a/-mb,-m2a-single/-mb,-m4/-ml,-m4/-mb,
 -m4-single/-ml,-m4-single/-mb,-m4a-single/-ml,-m4a-single/-mb}
 
 and no new failures.
 Test cases will follow soon.

The patch is OK for trunk.

BTW, do you have the numbers of CSiBE with this?

Regards,
kaz


Re: [SH] PR 50751 - add HImode displacement addressing support

2012-04-10 Thread Oleg Endo
On Tue, 2012-04-10 at 22:42 +0900, Kaz Kojima wrote:
 Oleg Endo oleg.e...@t-online.de wrote:
  The attached patch adds HImode addressing support.
  Tested against rev. 186243 with
  sudo make -k check RUNTESTFLAGS=--target_board=sh-sim
  \{-m2/-ml,-m2/-mb,-m2a/-mb,-m2a-single/-mb,-m4/-ml,-m4/-mb,
  -m4-single/-ml,-m4-single/-mb,-m4a-single/-ml,-m4a-single/-mb}
  
  and no new failures.
  Test cases will follow soon.
 
 The patch is OK for trunk.
 
 BTW, do you have the numbers of CSiBE with this?
 

Only for -m4-single -ml -O2 -mpretend-cmove so far.
Not so spectacular :T
I'll also do a comparison of more variants to see if something went
really bad.  It's a bit difficult to isolate the degradations because
there's quite some code reordering happening after the patch... 

Cheers,
Oleg



OpenTCP-1.0.4
  arp 2089 - 2061 -28 / -1.340354 %
  bootp/bootp  740 - 704  -36 / -4.864865 %
  demo/main_demo   372 - 368   -4 / -1.075269 %
  demo/tcp_client_demo 396 - 396 
  demo/tcp_server_demo 468 - 468 
  demo/udp_demo268 - 268 
  dhcp/dhcpc  1588 - 1588
  dns/dns 1340 - 1328 -12 / -0.895522 %
  ethernet1240 - 1228 -12 / -0.967742 %
  http/http_server1784 - 1764 -20 / -1.121076 %
  http/https_callbacks 656 - 656 
  icmp 348 - 352   +4 / +1.149425 %
  ip  1780 - 1668-112 / -6.292135 %
  pop3/pop3_client3796 - 3728 -68 / -1.791359 %
  pop3/pop3c_callbacks  28 - 28  
  smtp/smtp_client2284 - 2212 -72 / -3.152364 %
  smtp/smtpc_callbacks  32 - 32  
  system   980 - 980 
  tcp 4966 - 4970  +4 / +0.080548 %
  tftp/tftps  1024 - 920 -104 / -10.156250 %
  timers   228 - 228 
  udp 1362 - 1322 -40 / -2.936858 %

 total: 27769 - 27269  -500 / -1.800569 %


bzip2-1.0.2
  blocksort   7262 - 7258  -4 / -0.055081 %
  bzip2  17288 - 17248-40 / -0.231374 %
  bzip2recover3868 - 3868
  bzlib  10668 - 10636-32 / -0.299963 %
  compress   14208 - 14192-16 / -0.112613 %
  crctable1024 - 1024
  decompress  8380 - 8380
  huffman 1436 - 1436
  randtable   2048 - 2048

 total: 66182 - 66090  -92 / -0.139011 %


cg_compiler_opensrc
  atom3728 - 3728
  binding 1752 - 1728 -24 / -1.369863 %
  cgcmain 2388 - 2388
  cgstruct 128 - 128 
  check   3300 - 3300
  compile14052 - 14052   
  constfold   3996 - 3996
  cpp 6776 - 6768  -8 / -0.118064 %
  generic_hal 2516 - 2516
  hal 2720 - 2720
  inline  2724 - 2724
  memory   548 - 548 
  parser 15796 - 15796   
  printutils 11888 - 11888   
  scanner 6716 - 6672 -44 / -0.655152 %
  semantic4364 - 4364
  stdlib  3224 - 3224
  support24328 - 24332 +4 / +0.016442 %
  support_iter1832 - 1832
  symbols 6324 - 6312 -12 / -0.189753 %
  tokenize 624 - 624 
  tokens  3112 - 3120  +8 / +0.257069 %

 total:122836 - 122760 -76 / -0.061871 %


compiler
  cg 2868 - 2868
  main   2600 - 2600
  parser 4524 - 4528  +4 / +0.088417 %
  scanner3788 - 3788
  vam5264 - 5264
  vas6292 - 6300  +8 / +0.127146 %

 total: 25336 - 25348  +12 / +0.047363 %


flex-2.5.31
  buf  1100 - 1100
  ccl  1220 - 1220
  dfa  6952 - 6952
  ecs   612 - 612 
  filter   2360 - 2360
  gen 24512 - 24488-24 / -0.097911 %
  libmain28 - 28  
  libyywrap   4 - 4   
  main19804 - 19792-12 / -0.060594 %
  misc 6480 - 6480
  nfa  3812 - 3812
  options  2768 - 2768
  parse9524 - 9528  +4 / +0.041999 %
  regex 596 - 596 
  scan47012 - 47004 -8 / -0.017017 %
  scanopt  3672 - 3672
  skel96652 - 96652   
  sym  1012 - 1012
  tables   2080 - 2064 -16 / -0.769231 %
  tables_shared  28 - 28  
  tblcmp   3764 - 3764
  yylex1292 - 1292

 total:235284 - 235228 -56 / -0.023801 %


jikespg-1.3
  src/ctabs  49912 - 49876-36 / -0.072127 %
  src/globals  288 - 288 
  src/lpgparse   47340 - 47036   -304 / -0.642163 %
  src/lpgutil 5152 - 5120 -32 / -0.621118 %
  src/main5440 - 5440
  src/mkfirst

Re: [SH] PR 50751 - add HImode displacement addressing support

2012-04-10 Thread Nathan Froyd
- Original Message -
  BTW, do you have the numbers of CSiBE with this?
 
 Only for -m4-single -ml -O2 -mpretend-cmove so far.
 Not so spectacular :T
 I'll also do a comparison of more variants to see if something went
 really bad.  It's a bit difficult to isolate the degradations because
 there's quite some code reordering happening after the patch...

Are you looking at execution time or code size?  If the latter, you could try 
disabling scheduling for comparison purposes (-fno-schedule-insns 
-fno-schedule-insns2).  Even if you're looking at execution time, disabling 
scheduling might make it easier to see where things are going wrong in the 
patched code.

-Nathan


Re: [SH] PR 50751 - add HImode displacement addressing support

2012-04-10 Thread Oleg Endo
On Tue, 2012-04-10 at 07:14 -0700, Nathan Froyd wrote:
 - Original Message -
   BTW, do you have the numbers of CSiBE with this?
  
  Only for -m4-single -ml -O2 -mpretend-cmove so far.
  Not so spectacular :T
  I'll also do a comparison of more variants to see if something went
  really bad.  It's a bit difficult to isolate the degradations because
  there's quite some code reordering happening after the patch...
 
 Are you looking at execution time or code size?  If the latter, you
 could try disabling scheduling for comparison purposes
 (-fno-schedule-insns -fno-schedule-insns2).  Even if you're looking at
 execution time, disabling scheduling might make it easier to see where
 things are going wrong in the patched code.

Code size only.  Thanks for the hint, will try it out.

Cheers,
Oleg



[SH] PR 50751 - add HImode displacement addressing support

2012-04-09 Thread Oleg Endo
Hello,

The attached patch adds HImode addressing support.
Tested against rev. 186243 with
sudo make -k check RUNTESTFLAGS=--target_board=sh-sim
\{-m2/-ml,-m2/-mb,-m2a/-mb,-m2a-single/-mb,-m4/-ml,-m4/-mb,
-m4-single/-ml,-m4-single/-mb,-m4a-single/-ml,-m4a-single/-mb}

and no new failures.
Test cases will follow soon.

Cheers,
Oleg

ChangeLog:

PR target/50751
* config/sh/sh-protos.h (sh_legitimate_index_p): Add
new arguments consider_sh2a and allow_zero.
* config/sh/sh.c (sh_legitimate_index_p): Likewise.
(disp_addr_displacement): New function.
(sh_address_cost): Use disp_addr_displacement function instead
of DISP_ADDR_OFFSET.
(sh_legitimate_address_p): Adapt to changed
sh_legitimate_index_p declaration.
(sh_find_mov_disp_adjust): Remove HImode check.
(sh_secondary_reload): Add HImode case.  Use 
satisfies_constraint_Sdd, disp_addr_displacement and
max_mov_insn_displacement.
(max_mov_insn_displacement): Remove HImode check.
* config/sh/sh.h (CONST_OK_FOR_K04, CONST_OK_FOR_K12, 
DISP_ADDR_P, DISP_ADDR_OFFSET): Remove.
* config/sh/constraints.md (K05, K13): New constraints.
(K12): Correct comment.
(Sdd): Do not use DISP_ADDR_P macro.
(Snd): Use satisfies_constraint_Sdd.
(Sbw): Likewise.
* config/sh/sh.md (extendhisi2): Remove constraints from
expander.
(*extendhisi2_compact, movhi_i): Remove.
(*extendhisi2_compact_reg, *extendhisi2_compact_mem_disp,
*extendhisi2_compact_mem_disp, *extendhisi2_compact_snd,
*movhi_reg_reg, *movhi_store_mem_disp05,
*movhi_store_mem_disp13, *movhi_load_mem_disp, 
*movhi_load_mem_disp, *movhi): New insns.
(*extendqisi2_compact_mem_disp, *extendqisi2_compact_mem_disp,
*movqi_store_mem_disp04, *movqi_store_mem_disp12,
*movqi_load_mem_disp, *movqi_load_mem_disp): Use 
sh_legitimate_index_p instead of CONST_OK_FOR_Kxx.
Add new peepholes for HImode displacement addressing.
Index: gcc/config/sh/predicates.md
===
--- gcc/config/sh/predicates.md	(revision 186233)
+++ gcc/config/sh/predicates.md	(working copy)
@@ -404,7 +404,7 @@
   if (GET_CODE (x) == PLUS
 	   REG_P (XEXP (x, 0))
 	   CONST_INT_P (XEXP (x, 1)))
-	return sh_legitimate_index_p (mode, XEXP (x, 1));
+	return sh_legitimate_index_p (mode, XEXP (x, 1), TARGET_SH2A, false);
 }
 
   if (TARGET_SHMEDIA
@@ -466,7 +466,7 @@
   if (GET_CODE (x) == PLUS
 	   REG_P (XEXP (x, 0))
 	   CONST_INT_P (XEXP (x, 1)))
-	return sh_legitimate_index_p (mode, XEXP (x, 1));
+	return sh_legitimate_index_p (mode, XEXP (x, 1), TARGET_SH2A, false);
 }
 
   return general_operand (op, mode);
Index: gcc/config/sh/sh-protos.h
===
--- gcc/config/sh/sh-protos.h	(revision 186233)
+++ gcc/config/sh/sh-protos.h	(working copy)
@@ -56,7 +56,7 @@
 extern bool fp_zero_operand (rtx);
 extern bool fp_one_operand (rtx);
 extern rtx get_fpscr_rtx (void);
-extern bool sh_legitimate_index_p (enum machine_mode, rtx);
+extern bool sh_legitimate_index_p (enum machine_mode, rtx, bool, bool);
 extern bool sh_legitimize_reload_address (rtx *, enum machine_mode, int, int);
 extern rtx legitimize_pic_address (rtx, enum machine_mode, rtx);
 extern bool nonpic_symbol_mentioned_p (rtx);
Index: gcc/config/sh/sh.c
===
--- gcc/config/sh/sh.c	(revision 186233)
+++ gcc/config/sh/sh.c	(working copy)
@@ -304,6 +304,7 @@
 static int mov_insn_size (enum machine_mode, bool);
 static int max_mov_insn_displacement (enum machine_mode, bool);
 static int mov_insn_alignment_mask (enum machine_mode, bool);
+static HOST_WIDE_INT disp_addr_displacement (rtx);
 
 static void sh_init_sync_libfuncs (void) ATTRIBUTE_UNUSED;
 
@@ -3160,11 +3161,6 @@
  scale the max. displacement value accordingly.  */
   const int disp_scale = consider_sh2a ? (4095 / 15) : 1;
 
-  /* FIXME: HImode with displacement addressing is not supported yet.
- Make it purposefully fail for now.  */
-  if (mode == HImode)
-return 0;
-
   /* SH2A supports FPU move insns with 12 bit displacements.
  Other variants to do not support any kind of displacements for
  FPU move insns.  */
@@ -3194,15 +3190,24 @@
   return mov_insn_sz  0 ? (mov_insn_sz - 1) : 0;
 }
 
+/* Return the displacement value of a displacement address.  */
+
+static inline HOST_WIDE_INT
+disp_addr_displacement (rtx x)
+{
+  gcc_assert (satisfies_constraint_Sdd (x));
+  return INTVAL (XEXP (XEXP (x, 0), 1));
+}
+
 /* Compute the cost of an address.  */
 
 static int
 sh_address_cost (rtx x, bool speed ATTRIBUTE_UNUSED)
 {
   /* 'reg + disp' addressing.  */
-  if (DISP_ADDR_P (x))
+  if (satisfies_constraint_Sdd (x))
 {
-  const HOST_WIDE_INT offset =