aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Kuvyrkov <maxim@codesourcery.com>2008-11-14 10:49:06 +0000
committerAndrew Stubbs <ams@gcc.gnu.org>2008-11-14 10:49:06 +0000
commit7279bb227886a9de1a642b497a306813d5c4ea4c (patch)
tree0e026a86a319fb6826141d6e5becfbee3ec8c882
parent1da1a26884586f1667174037dcbf58de5196f35e (diff)
downloadgcc-7279bb227886a9de1a642b497a306813d5c4ea4c.zip
gcc-7279bb227886a9de1a642b497a306813d5c4ea4c.tar.gz
gcc-7279bb227886a9de1a642b497a306813d5c4ea4c.tar.bz2
re PR target/36134 (GCC creates suboptimal ASM : usage of ADDA.L where LEA could be used)
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
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/config/m68k/m68k.md25
-rw-r--r--gcc/testsuite/ChangeLog7
-rw-r--r--gcc/testsuite/gcc.target/m68k/pr36134.c23
4 files changed, 51 insertions, 12 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4d33ff3..446906e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/config/m68k/m68k.md b/gcc/config/m68k/m68k.md
index 9effb34..cf3e120 100644
--- a/gcc/config/m68k/m68k.md
+++ b/gcc/config/m68k/m68k.md
@@ -2325,9 +2325,9 @@
"* 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)
@@ -2339,21 +2339,22 @@
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:
@@ -2361,16 +2362,16 @@
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")
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c1d3548..0d05fdb 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..d8d65c1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/m68k/pr36134.c
@@ -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++;
+ }
+}