patches/gcc/3.4.4/600-gcc34-arm-ldm-peephole.patch
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sat Feb 24 11:00:05 2007 +0000 (2007-02-24)
changeset 1 eeea35fbf182
permissions -rw-r--r--
Add the full crosstool-NG sources to the new repository of its own.
You might just say: 'Yeah! crosstool-NG's got its own repo!".
Unfortunately, that's because the previous repo got damaged beyond repair and I had no backup.
That means I'm putting backups in place in the afternoon.
That also means we've lost history... :-(
yann@1
     1
--- gcc-3.4.0/gcc/config/arm/arm.md.arm-ldm-peephole	2004-01-13 08:24:37.000000000 -0500
yann@1
     2
+++ gcc-3.4.0/gcc/config/arm/arm.md	2004-04-24 18:18:04.000000000 -0400
yann@1
     3
@@ -8810,13 +8810,16 @@
yann@1
     4
    (set_attr "length" "4,8,8")]
yann@1
     5
 )
yann@1
     6
 
yann@1
     7
+; Try to convert LDR+LDR+arith into [add+]LDM+arith
yann@1
     8
+; On XScale, LDM is always slower than two LDRs, so only do this if
yann@1
     9
+; optimising for size.
yann@1
    10
 (define_insn "*arith_adjacentmem"
yann@1
    11
   [(set (match_operand:SI 0 "s_register_operand" "=r")
yann@1
    12
 	(match_operator:SI 1 "shiftable_operator"
yann@1
    13
 	 [(match_operand:SI 2 "memory_operand" "m")
yann@1
    14
 	  (match_operand:SI 3 "memory_operand" "m")]))
yann@1
    15
    (clobber (match_scratch:SI 4 "=r"))]
yann@1
    16
-  "TARGET_ARM && adjacent_mem_locations (operands[2], operands[3])"
yann@1
    17
+  "TARGET_ARM && (!arm_tune_xscale || optimize_size) && adjacent_mem_locations (operands[2], operands[3])"
yann@1
    18
   "*
yann@1
    19
   {
yann@1
    20
     rtx ldm[3];
yann@1
    21
@@ -8851,6 +8854,8 @@
yann@1
    22
       }
yann@1
    23
    if (val1 && val2)
yann@1
    24
       {
yann@1
    25
+	/* This would be a loss on a Harvard core, but adjacent_mem_locations()
yann@1
    26
+	   will prevent it from happening.  */
yann@1
    27
 	rtx ops[3];
yann@1
    28
 	ldm[0] = ops[0] = operands[4];
yann@1
    29
 	ops[1] = XEXP (XEXP (operands[2], 0), 0);
yann@1
    30
--- gcc-3.4.0/gcc/config/arm/arm.c.arm-ldm-peephole	2004-04-24 18:16:25.000000000 -0400
yann@1
    31
+++ gcc-3.4.0/gcc/config/arm/arm.c	2004-04-24 18:18:04.000000000 -0400
yann@1
    32
@@ -4838,6 +4841,11 @@
yann@1
    33
       *load_offset = unsorted_offsets[order[0]];
yann@1
    34
     }
yann@1
    35
 
yann@1
    36
+  /* For XScale a two-word LDM is a performance loss, so only do this if
yann@1
    37
+     size is more important.  See comments in arm_gen_load_multiple.  */
yann@1
    38
+  if (nops == 2 && arm_tune_xscale && !optimize_size)
yann@1
    39
+    return 0;
yann@1
    40
+
yann@1
    41
   if (unsorted_offsets[order[0]] == 0)
yann@1
    42
     return 1; /* ldmia */
yann@1
    43
 
yann@1
    44
@@ -5064,6 +5072,11 @@
yann@1
    45
       *load_offset = unsorted_offsets[order[0]];
yann@1
    46
     }
yann@1
    47
 
yann@1
    48
+  /* For XScale a two-word LDM is a performance loss, so only do this if
yann@1
    49
+     size is more important.  See comments in arm_gen_load_multiple.  */
yann@1
    50
+  if (nops == 2 && arm_tune_xscale && !optimize_size)
yann@1
    51
+    return 0;
yann@1
    52
+
yann@1
    53
   if (unsorted_offsets[order[0]] == 0)
yann@1
    54
     return 1; /* stmia */
yann@1
    55
 
yann@1
    56
--- gcc-3.4.0/gcc/genpeep.c.arm-ldm-peephole	2003-07-05 01:27:22.000000000 -0400
yann@1
    57
+++ gcc-3.4.0/gcc/genpeep.c	2004-04-24 18:18:04.000000000 -0400
yann@1
    58
@@ -381,6 +381,7 @@
yann@1
    59
   printf ("#include \"recog.h\"\n");
yann@1
    60
   printf ("#include \"except.h\"\n\n");
yann@1
    61
   printf ("#include \"function.h\"\n\n");
yann@1
    62
+  printf ("#include \"flags.h\"\n\n");
yann@1
    63
 
yann@1
    64
   printf ("#ifdef HAVE_peephole\n");
yann@1
    65
   printf ("extern rtx peep_operand[];\n\n");