Commit 7279bb22 by Maxim Kuvyrkov Committed by Andrew Stubbs

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
parent 1da1a268
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> 2008-11-14 Thomas Schwinge <tschwinge@gnu.org>
* configure.ac (gcc_cv_libc_provides_ssp): Also consider GNU/Hurd * configure.ac (gcc_cv_libc_provides_ssp): Also consider GNU/Hurd
......
...@@ -2325,9 +2325,9 @@ ...@@ -2325,9 +2325,9 @@
"* return output_addsi3 (operands);") "* return output_addsi3 (operands);")
(define_insn_and_split "*addsi3_5200" (define_insn_and_split "*addsi3_5200"
[(set (match_operand:SI 0 "nonimmediate_operand" "=mr,mr,m,r, ?a,?a,?a,?a") [(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, a, a, r, 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, d,mrKi,Cj,r, a, J")))] (match_operand:SI 2 "general_src_operand" " I, L, J,d,mrKi,Cj, r, a, J")))]
"TARGET_COLDFIRE" "TARGET_COLDFIRE"
{ {
switch (which_alternative) switch (which_alternative)
...@@ -2339,21 +2339,22 @@ ...@@ -2339,21 +2339,22 @@
operands[2] = GEN_INT (- INTVAL (operands[2])); operands[2] = GEN_INT (- INTVAL (operands[2]));
return "subq%.l %2,%0"; return "subq%.l %2,%0";
case 2:
case 3: case 3:
case 4:
return "add%.l %2,%0"; return "add%.l %2,%0";
case 4: case 5:
/* move%.l %2,%0\n\tadd%.l %1,%0 */ /* move%.l %2,%0\n\tadd%.l %1,%0 */
return "#"; return "#";
case 5: case 6:
return MOTOROLA ? "lea (%1,%2.l),%0" : "lea %1@(0,%2:l),%0"; 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"; 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"; return MOTOROLA ? "lea (%c2,%1),%0" : "lea %1@(%c2),%0";
default: default:
...@@ -2361,16 +2362,16 @@ ...@@ -2361,16 +2362,16 @@
return ""; 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) [(set (match_dup 0)
(match_dup 2)) (match_dup 2))
(set (match_dup 0) (set (match_dup 0)
(plus:SI (match_dup 0) (plus:SI (match_dup 0)
(match_dup 1)))] (match_dup 1)))]
"" ""
[(set_attr "type" "aluq_l,aluq_l,alu_l,alu_l,*,lea,lea,lea") [(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" "2,2,*,2,2,*,*,*,*")
(set_attr "opy_type" "*,*,*,*,*,mem6,mem6,mem5")]) (set_attr "opy_type" "*,*,mem5,*,*,*,mem6,mem6,mem5")])
(define_insn "" (define_insn ""
[(set (match_operand:SI 0 "nonimmediate_operand" "=a") [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
......
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> 2008-11-14 Jakub Jelinek <jakub@redhat.com>
PR middle-end/36125 PR middle-end/36125
......
/* 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++;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment