]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR target/36134 (GCC creates suboptimal ASM : usage of ADDA.L where LEA could...
authorMaxim Kuvyrkov <maxim@codesourcery.com>
Fri, 14 Nov 2008 10:49:06 +0000 (10:49 +0000)
committerAndrew Stubbs <ams@gcc.gnu.org>
Fri, 14 Nov 2008 10:49:06 +0000 (10:49 +0000)
2008-11-14  Maxim Kuvyrkov  <maxim@codesourcery.com>
    Andrew Stubbs  <ams@codesourcery.com>
    Gunnar Von Boehn  <gunnar@genesi-usa.com>

gcc/
PR target/36134
* config/m68k/m68k.md (addsi3_5200): Add a new alternative preferring
the shorter LEA insn over ADD.L where possible.

gcc/testsuite/
PR target/36134
* gcc.target/m68k/pr36134.c: New test.

Co-Authored-By: Andrew Stubbs <ams@codesourcery.com>
Co-Authored-By: Gunnar Von Boehn <gunnar@genesi-usa.com>
From-SVN: r141853

gcc/ChangeLog
gcc/config/m68k/m68k.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/m68k/pr36134.c [new file with mode: 0644]

index 4d33ff35cac725d82381e291591d51180b79f459..446906e47b3635e2e9ec867bddcf4b17431077ff 100644 (file)
@@ -1,3 +1,11 @@
+2008-11-14  Maxim Kuvyrkov  <maxim@codesourcery.com>
+           Andrew Stubbs  <ams@codesourcery.com>
+           Gunnar Von Boehn  <gunnar@genesi-usa.com>
+
+       PR target/36134
+       * config/m68k/m68k.md (addsi3_5200): Add a new alternative preferring
+       the shorter LEA insn over ADD.L where possible.
+
 2008-11-14  Thomas Schwinge  <tschwinge@gnu.org>
 
        * configure.ac (gcc_cv_libc_provides_ssp): Also consider GNU/Hurd
index 9effb344ec5ea0f96cd153cc474b7bcd40b374c5..cf3e120590fff2741f0fa7d8108b7785e55ef224 100644 (file)
   "* return output_addsi3 (operands);")
 
 (define_insn_and_split "*addsi3_5200"
-  [(set (match_operand:SI 0 "nonimmediate_operand"         "=mr,mr,m,r,  ?a,?a,?a,?a")
-       (plus:SI (match_operand:SI 1 "general_operand"     "%0, 0, 0,0,   a, a, r, a")
-                (match_operand:SI 2 "general_src_operand" " I, L, d,mrKi,Cj,r, a, J")))]
+  [(set (match_operand:SI 0 "nonimmediate_operand"         "=mr,mr,a,m,r,  ?a, ?a,?a,?a")
+       (plus:SI (match_operand:SI 1 "general_operand"     "%0, 0, 0,0,0,   a,  a, r, a")
+                (match_operand:SI 2 "general_src_operand" " I, L, J,d,mrKi,Cj, r, a, J")))]
   "TARGET_COLDFIRE"
 {
   switch (which_alternative)
       operands[2] = GEN_INT (- INTVAL (operands[2]));
       return "subq%.l %2,%0";
 
-    case 2:
     case 3:
+    case 4:
       return "add%.l %2,%0";
 
-    case 4:
+    case 5:
       /* move%.l %2,%0\n\tadd%.l %1,%0 */
       return "#";
 
-    case 5:
+    case 6:
       return MOTOROLA ? "lea (%1,%2.l),%0" : "lea %1@(0,%2:l),%0";
 
-    case 6:
+    case 7:
       return MOTOROLA ? "lea (%2,%1.l),%0" : "lea %2@(0,%1:l),%0";
 
-    case 7:
+    case 2:
+    case 8:
       return MOTOROLA ? "lea (%c2,%1),%0" : "lea %1@(%c2),%0";
 
     default:
       return "";
     }
 }
-  "&& reload_completed && (extract_constrain_insn_cached (insn), which_alternative == 4) && !operands_match_p (operands[0], operands[1])"
+  "&& reload_completed && (extract_constrain_insn_cached (insn), which_alternative == 5) && !operands_match_p (operands[0], operands[1])"
   [(set (match_dup 0)
        (match_dup 2))
    (set (match_dup 0)
        (plus:SI (match_dup 0)
                 (match_dup 1)))]
   ""
-  [(set_attr "type" "aluq_l,aluq_l,alu_l,alu_l,*,lea,lea,lea")
-   (set_attr "opy" "2,2,2,2,*,*,*,*")
-   (set_attr "opy_type" "*,*,*,*,*,mem6,mem6,mem5")])
+  [(set_attr "type" "aluq_l,aluq_l,lea,alu_l,alu_l,*,lea,lea,lea")
+   (set_attr "opy" "2,2,*,2,2,*,*,*,*")
+   (set_attr "opy_type" "*,*,mem5,*,*,*,mem6,mem6,mem5")])
 
 (define_insn ""
   [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
index c1d3548b4a53f4e0367c729f00565e6f34b88cf4..0d05fdb2480de87b80a110a3a0e13c409feffaa4 100644 (file)
@@ -1,3 +1,10 @@
+2008-11-14  Maxim Kuvyrkov  <maxim@codesourcery.com>
+           Andrew Stubbs  <ams@codesourcery.com>
+           Gunnar Von Boehn  <gunnar@genesi-usa.com>
+
+       PR target/36134
+       * gcc.target/m68k/pr36134.c: New test.
+
 2008-11-14  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/36125
diff --git a/gcc/testsuite/gcc.target/m68k/pr36134.c b/gcc/testsuite/gcc.target/m68k/pr36134.c
new file mode 100644 (file)
index 0000000..d8d65c1
--- /dev/null
@@ -0,0 +1,23 @@
+/* pr36134.c
+
+   This test ensures that the shorter LEA instruction is used in preference
+   to the longer ADD instruction.  */
+
+/* { dg-do compile }  */
+/* { dg-options "-O2" }  */
+/* { dg-final { scan-assembler "lea" } } */
+/* { dg-final { scan-assembler-not "add" } } */
+
+int *a, *b;
+
+void
+f ()
+{
+  while (a > b)
+    {
+      *a++ = *b++;
+      *a++ = *b++;
+      *a++ = *b++;
+      *a++ = *b++;
+    }
+}