public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, MIPS] 74k madd scheduler tweaks
@ 2012-08-01 22:06 Sandra Loosemore
  2012-08-04 13:48 ` Richard Sandiford
  0 siblings, 1 reply; 7+ messages in thread
From: Sandra Loosemore @ 2012-08-01 22:06 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 825 bytes --]

The existing scheduler bypass information for madd on the 74k uses some 
bits copied from the 24k, and is not quite correct.  This patch is based 
on one originally sent to us by MIPS and has been present in our local 
source base for years.  I've confirmed that we are legally allowed to 
contribute this to the FSF; ok for mainline?

-Sandra

2012-08-01  Sandra Loosemore  <sandra@codesourcery.com>
	    Maxim Kuvyrkov  <maxim@codesourcery.com>
	    Julian Brown  <julian@codesourcery.com>
	    MIPS Technologies, Inc.
	
	* config/mips/74k.md (r74k_int_mult, r74k_int_madd): Don't use
	mips_linked_madd_p for bypasses.
	(r74k_int_mul3): Use mips_mult_madd_chain_bypass_p for bypass.
	* config/mips/mips.c (mips_mult_madd_chain_bypass_p): New.
	* config/mips/mips-protos.h (mips_mult_madd_chain_bypass_p): Add
	prototype.



[-- Attachment #2: 74k.patch --]
[-- Type: text/x-patch, Size: 2160 bytes --]

Index: gcc/config/mips/74k.md
===================================================================
--- gcc/config/mips/74k.md	(revision 189988)
+++ gcc/config/mips/74k.md	(working copy)
@@ -168,10 +168,11 @@
 ;; mult/madd/msub->int_mfhilo  : 4 cycles (default)
 ;; mult->madd/msub             : 1 cycles
 ;; madd/msub->madd/msub        : 1 cycles
-(define_bypass 1 "r74k_int_mult,r74k_int_mul3" "r74k_int_madd"
-  "mips_linked_madd_p")
-(define_bypass 1 "r74k_int_madd" "r74k_int_madd"
-  "mips_linked_madd_p")
+(define_bypass 1 "r74k_int_mult" "r74k_int_madd")
+(define_bypass 1 "r74k_int_madd" "r74k_int_madd")
+
+(define_bypass 1 "r74k_int_mul3" "r74k_int_madd"
+  "mips_mult_madd_chain_bypass_p")
 
 ;; --------------------------------------------------------------
 ;; Floating Point Instructions
Index: gcc/config/mips/mips-protos.h
===================================================================
--- gcc/config/mips/mips-protos.h	(revision 189988)
+++ gcc/config/mips/mips-protos.h	(working copy)
@@ -296,6 +296,7 @@ extern unsigned int mips_sync_loop_insns
 extern const char *mips_output_division (const char *, rtx *);
 extern unsigned int mips_hard_regno_nregs (int, enum machine_mode);
 extern bool mips_linked_madd_p (rtx, rtx);
+extern bool mips_mult_madd_chain_bypass_p (rtx, rtx);
 extern bool mips_store_data_bypass_p (rtx, rtx);
 extern rtx mips_prefetch_cookie (rtx, rtx);
 
Index: gcc/config/mips/mips.c
===================================================================
--- gcc/config/mips/mips.c	(revision 189988)
+++ gcc/config/mips/mips.c	(working copy)
@@ -12392,6 +12392,18 @@ mips_linked_madd_p (rtx out_insn, rtx in
   return false;
 }
 
+/* Helper function for 74k; returns true to enable the chained mult/madd
+   bypass.  */
+bool
+mips_mult_madd_chain_bypass_p (rtx out_insn ATTRIBUTE_UNUSED,
+			       rtx in_insn ATTRIBUTE_UNUSED)
+{
+  if (reload_completed)
+    return false;
+  else
+    return true;
+}
+
 /* True if the dependency between OUT_INSN and IN_INSN is on the store
    data rather than the address.  We need this because the cprestore
    pattern is type "store", but is defined using an UNSPEC_VOLATILE,

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH, MIPS] 74k madd scheduler tweaks
  2012-08-01 22:06 [PATCH, MIPS] 74k madd scheduler tweaks Sandra Loosemore
@ 2012-08-04 13:48 ` Richard Sandiford
  2012-08-04 20:44   ` Sandra Loosemore
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Sandiford @ 2012-08-04 13:48 UTC (permalink / raw)
  To: Sandra Loosemore; +Cc: gcc-patches

Sandra Loosemore <sandra@codesourcery.com> writes:
> The existing scheduler bypass information for madd on the 74k uses some 
> bits copied from the 24k, and is not quite correct.  This patch is based 
> on one originally sent to us by MIPS and has been present in our local 
> source base for years.  I've confirmed that we are legally allowed to 
> contribute this to the FSF; ok for mainline?

Sorry to ask, but do you have a record of why?  Reason I ask is that...

> Index: gcc/config/mips/74k.md
> ===================================================================
> --- gcc/config/mips/74k.md	(revision 189988)
> +++ gcc/config/mips/74k.md	(working copy)
> @@ -168,10 +168,11 @@
>  ;; mult/madd/msub->int_mfhilo  : 4 cycles (default)
>  ;; mult->madd/msub             : 1 cycles
>  ;; madd/msub->madd/msub        : 1 cycles
> -(define_bypass 1 "r74k_int_mult,r74k_int_mul3" "r74k_int_madd"
> -  "mips_linked_madd_p")
> -(define_bypass 1 "r74k_int_madd" "r74k_int_madd"
> -  "mips_linked_madd_p")
> +(define_bypass 1 "r74k_int_mult" "r74k_int_madd")
> +(define_bypass 1 "r74k_int_madd" "r74k_int_madd")
> +
> +(define_bypass 1 "r74k_int_mul3" "r74k_int_madd"
> +  "mips_mult_madd_chain_bypass_p")
>  
>  ;; --------------------------------------------------------------
>  ;; Floating Point Instructions

...this looks like a step backwards.  Before reload, the original
version assumes that a multiplication feeding a madd is going to form
a chain _as long as_ the result of the multiplication is used as the
accumulator input to the madd.  The condition is important because
something like:

     r1 = r2 * r3
     r6 = r1 * r4 + r5

(which is perfectly OK before reload) shouldn't form a chain.

mult and mul3 are equivalent at this stage because we're still using
pseudo registers and haven't yet introduced uses of LO.  Having both
reservations in the same bypass makes sense because of that.

The original version should be OK after reload too.  It should then
never be the case that r74k_int_mul3 feeds r74k_int_madd in a way
that satisfies mips_linked_madd_p, so the bypass is harmless but
becomes temporarily redundant.  But it should always be the case
that r74k_int_mult only feeds r74k_int_madd in a way that satisfies
mips_linked_madd_p, so the _predicate_ should be harmless but temporarily
equivalent to "always true".

I.e. the original version should behave as:

  (define_bypass 1 "r74k_int_mult" "r74k_int_madd")
  (define_bypass 1 "r74k_int_madd" "r74k_int_madd")

after reload (with no bypass for r74k_int_mul3).

At least that's how it's supposed to work.  The new version is
obviously equivalent in the post-reload case, but seems to be making
the pre-reload case worse.  I'm wondering whether someone hit a
situation where mips_linked_madd_p wasn't working properly.

Richard

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH, MIPS] 74k madd scheduler tweaks
  2012-08-04 13:48 ` Richard Sandiford
@ 2012-08-04 20:44   ` Sandra Loosemore
  2012-08-08 19:10     ` Richard Sandiford
  0 siblings, 1 reply; 7+ messages in thread
From: Sandra Loosemore @ 2012-08-04 20:44 UTC (permalink / raw)
  To: gcc-patches, rdsandiford

On 08/04/2012 07:48 AM, Richard Sandiford wrote:
> Sandra Loosemore<sandra@codesourcery.com>  writes:
>> The existing scheduler bypass information for madd on the 74k uses some
>> bits copied from the 24k, and is not quite correct.  This patch is based
>> on one originally sent to us by MIPS and has been present in our local
>> source base for years.  I've confirmed that we are legally allowed to
>> contribute this to the FSF; ok for mainline?
>
> Sorry to ask, but do you have a record of why?  Reason I ask is that...
>
>> Index: gcc/config/mips/74k.md
>> ===================================================================
>> --- gcc/config/mips/74k.md	(revision 189988)
>> +++ gcc/config/mips/74k.md	(working copy)
>> @@ -168,10 +168,11 @@
>>   ;; mult/madd/msub->int_mfhilo  : 4 cycles (default)
>>   ;; mult->madd/msub             : 1 cycles
>>   ;; madd/msub->madd/msub        : 1 cycles
>> -(define_bypass 1 "r74k_int_mult,r74k_int_mul3" "r74k_int_madd"
>> -  "mips_linked_madd_p")
>> -(define_bypass 1 "r74k_int_madd" "r74k_int_madd"
>> -  "mips_linked_madd_p")
>> +(define_bypass 1 "r74k_int_mult" "r74k_int_madd")
>> +(define_bypass 1 "r74k_int_madd" "r74k_int_madd")
>> +
>> +(define_bypass 1 "r74k_int_mul3" "r74k_int_madd"
>> +  "mips_mult_madd_chain_bypass_p")
>>
>>   ;; --------------------------------------------------------------
>>   ;; Floating Point Instructions
>
> ...this looks like a step backwards.
>[long explanation trimmed]

Sigh, I wasn't able to find any detailed rationale for this patch. 
However, the "DSP ALU scheduling" patch I posted separately gives a clue 
what the intent was as it also uses mips_mult_madd_chain_bypass_p to 
give different behavior pre- and post-reload:

> +;; Before reload, all multiplier is registered as imul3 (which has a long
> +;;  latency).  We temporary jig the latency such that the macc groups
> +;;  are scheduled closely together during the first scheduler pass.
> +(define_bypass 1 "r74k_int_mul3" "r74k_dsp_mac"
> +  "mips_mult_madd_chain_bypass_p")
> +(define_bypass 1 "r74k_int_mul3" "r74k_dsp_mac_sat"
> +  "mips_mult_madd_chain_bypass_p")

If this is incorrect or looks like a hack to paper over some other 
problem, I'd be happy to drop the predicate on these bits too.  WDYT?

-Sandra

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH, MIPS] 74k madd scheduler tweaks
  2012-08-04 20:44   ` Sandra Loosemore
@ 2012-08-08 19:10     ` Richard Sandiford
  2012-08-14  0:06       ` Maxim Kuvyrkov
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Sandiford @ 2012-08-08 19:10 UTC (permalink / raw)
  To: Sandra Loosemore; +Cc: gcc-patches

Sandra Loosemore <sandra@codesourcery.com> writes:
>> +;; Before reload, all multiplier is registered as imul3 (which has a long
>> +;;  latency).  We temporary jig the latency such that the macc groups
>> +;;  are scheduled closely together during the first scheduler pass.
>> +(define_bypass 1 "r74k_int_mul3" "r74k_dsp_mac"
>> +  "mips_mult_madd_chain_bypass_p")
>> +(define_bypass 1 "r74k_int_mul3" "r74k_dsp_mac_sat"
>> +  "mips_mult_madd_chain_bypass_p")
>
> If this is incorrect or looks like a hack to paper over some other 
> problem, I'd be happy to drop the predicate on these bits too.  WDYT?

Hmm, yeah, it does look like they should be using mips_linked_madd_p
instead, except that mips_linked_madd_p isn't yet wired up to handle
DSP macs.  Rather than pattern-match them all, the easiest thing would
probably be to define a new attribute along the lines of:

(define_attr "accum_in" "none,0,1,2,3,4,5" (const_string "none"))

and use it for the existing imadds too.  E.g.:

(define_insn "*mul_acc_si"
  [(set (match_operand:SI 0 "register_operand" "=l*?*?,d?")
	(plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d,d")
			  (match_operand:SI 2 "register_operand" "d,d"))
		 (match_operand:SI 3 "register_operand" "0,d")))
   (clobber (match_scratch:SI 4 "=X,l"))
   (clobber (match_scratch:SI 5 "=X,&d"))]
  "GENERATE_MADD_MSUB && !TARGET_MIPS16"
  "@
    madd\t%1,%2
    #"
  [(set_attr "type"	"imadd")
   (set_attr "accum_in" "3")
   (set_attr "mode"	"SI")
   (set_attr "length"	"4,8")])

Then mips_linked_madd_p can use get_attr_accum_in to check for chains.

But if that's more work than you want right now, just dropping the
predicates above would be OK too, like you say.

Richard

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH, MIPS] 74k madd scheduler tweaks
  2012-08-08 19:10     ` Richard Sandiford
@ 2012-08-14  0:06       ` Maxim Kuvyrkov
  2012-08-14  7:08         ` Richard Sandiford
  0 siblings, 1 reply; 7+ messages in thread
From: Maxim Kuvyrkov @ 2012-08-14  0:06 UTC (permalink / raw)
  To: Richard Sandiford; +Cc: Sandra Loosemore, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1499 bytes --]

On 9/08/2012, at 7:10 AM, Richard Sandiford wrote:

> Hmm, yeah, it does look like they should be using mips_linked_madd_p
> instead, except that mips_linked_madd_p isn't yet wired up to handle
> DSP macs.  Rather than pattern-match them all, the easiest thing would
> probably be to define a new attribute along the lines of:
> 
> (define_attr "accum_in" "none,0,1,2,3,4,5" (const_string "none"))
> 
> and use it for the existing imadds too.  E.g.:
> 
> (define_insn "*mul_acc_si"
>  [(set (match_operand:SI 0 "register_operand" "=l*?*?,d?")
> 	(plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d,d")
> 			  (match_operand:SI 2 "register_operand" "d,d"))
> 		 (match_operand:SI 3 "register_operand" "0,d")))
>   (clobber (match_scratch:SI 4 "=X,l"))
>   (clobber (match_scratch:SI 5 "=X,&d"))]
>  "GENERATE_MADD_MSUB && !TARGET_MIPS16"
>  "@
>    madd\t%1,%2
>    #"
>  [(set_attr "type"	"imadd")
>   (set_attr "accum_in" "3")
>   (set_attr "mode"	"SI")
>   (set_attr "length"	"4,8")])
> 
> Then mips_linked_madd_p can use get_attr_accum_in to check for chains.
> 

I thought I'll butt in since I did a very similar thing for sync_memmodel a couple of months ago.

Is the attached patch what you have in mind?  It is a standalone change by itself and can be checked in if OK.  Sandra can than adjust DSP patches she's working on to use mips_linked_madd_p.

OK to apply if no regressions?

Thanks,

--
Maxim Kuvyrkov
CodeSourcery / Mentor Graphics


[-- Attachment #2: accum_in.ChangeLog --]
[-- Type: application/octet-stream, Size: 257 bytes --]

2012-08-14  Maxim Kuvyrkov  <maxim@codesourcery.com>

	* config/mips/mips.md (define_attr accum_in): New instruction attribute.
	Set it for imadd and fmadd patterns.
	* config/mips/mips.c (mips_linked_madd_p): Use accum_in to extract
	accumulator register.

[-- Attachment #3: accum_in.patch --]
[-- Type: application/octet-stream, Size: 6514 bytes --]

diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index e6e6c2d..1871f5c 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -12371,25 +12371,24 @@ mips_output_division (const char *division, rtx *operands)
 bool
 mips_linked_madd_p (rtx out_insn, rtx in_insn)
 {
-  rtx x;
+  enum attr_accum_in accum_in;
+  int accum_in_opnum;
+  rtx accum_in_op;
 
-  x = single_set (in_insn);
-  if (x == 0)
+  accum_in = get_attr_accum_in (in_insn);
+  if (accum_in == ACCUM_IN_NONE)
     return false;
 
-  x = SET_SRC (x);
+  accum_in_opnum = accum_in - ACCUM_IN_0;
 
-  if (GET_CODE (x) == PLUS
-      && GET_CODE (XEXP (x, 0)) == MULT
-      && reg_set_p (XEXP (x, 1), out_insn))
-    return true;
+  extract_insn (in_insn);
+  gcc_assert (accum_in_opnum < recog_data.n_operands);
+  accum_in_op = recog_data.operand[accum_in_opnum];
+  /* We take care in instruction definitions to make sure accum_in operand is
+     a register_operand or [a more restrictive] muldiv_target_operand.  */
+  gcc_assert (REG_P (accum_in_op));
 
-  if (GET_CODE (x) == MINUS
-      && GET_CODE (XEXP (x, 1)) == MULT
-      && reg_set_p (XEXP (x, 0), out_insn))
-    return true;
-
-  return false;
+  return reg_set_p (accum_in_op, out_insn);
 }
 
 /* Helper function for 74k; returns true to enable the chained mult/madd
diff --git a/gcc/config/mips/mips.md b/gcc/config/mips/mips.md
index 759958b..79c1f25 100644
--- a/gcc/config/mips/mips.md
+++ b/gcc/config/mips/mips.md
@@ -275,6 +275,10 @@
 (define_attr "sync_memmodel" "" (const_int 10))
 
 
+;; Accumulator operand for madd patterns.
+(define_attr "accum_in" "none,0,1,2,3,4,5" (const_string "none"))
+
+
 ;; Classification of each insn.
 ;; branch	conditional branch
 ;; jump		unconditional jump
@@ -1602,6 +1606,7 @@
     madd\t%1,%2
     #"
   [(set_attr "type"	"imadd")
+   (set_attr "accum_in"	"3")
    (set_attr "mode"	"SI")
    (set_attr "length"	"4,8")])
 
@@ -1620,6 +1625,7 @@
     madd\t%0,%1,%2
     #"
   [(set_attr "type"	"imadd")
+   (set_attr "accum_in"	"3")
    (set_attr "mode"	"SI")
    (set_attr "length"	"4,4,8")])
 
@@ -1658,6 +1664,7 @@
     return "%[macc\t%@,%1,%2%]";
 }
   [(set_attr "type" "imadd")
+   (set_attr "accum_in"	"3")
    (set_attr "mode" "SI")])
 
 (define_insn "*msac"
@@ -1676,6 +1683,7 @@
     return "msac\t$0,%2,%3";
 }
   [(set_attr "type"     "imadd")
+   (set_attr "accum_in"	"1")
    (set_attr "mode"     "SI")])
 
 ;; An msac-like instruction implemented using negation and a macc.
@@ -1699,6 +1707,7 @@
 	(clobber (match_dup 4))])]
   ""
   [(set_attr "type"     "imadd")
+   (set_attr "accum_in"	"1")
    (set_attr "length"	"8")])
 
 ;; Patterns generated by the define_peephole2 below.
@@ -1715,6 +1724,7 @@
   "ISA_HAS_MACC && reload_completed"
   "macc\t%3,%1,%2"
   [(set_attr "type"	"imadd")
+   (set_attr "accum_in"	"3")
    (set_attr "mode"	"SI")])
 
 (define_insn "*msac2"
@@ -1729,6 +1739,7 @@
   "ISA_HAS_MSAC && reload_completed"
   "msac\t%3,%1,%2"
   [(set_attr "type"	"imadd")
+   (set_attr "accum_in"	"3")
    (set_attr "mode"	"SI")])
 
 ;; Convert macc $0,<r1>,<r2> & mflo <r3> into macc <r3>,<r1>,<r2>
@@ -1831,6 +1842,7 @@
    msub\t%2,%3
    #"
   [(set_attr "type"     "imadd")
+   (set_attr "accum_in"	"1")
    (set_attr "mode"     "SI")
    (set_attr "length"   "4,8")])
 
@@ -2040,6 +2052,7 @@
     return "msac<u>\t$0,%1,%2";
 }
   [(set_attr "type" "imadd")
+   (set_attr "accum_in"	"3")
    (set_attr "mode" "SI")])
 
 ;; _highpart patterns
@@ -2260,6 +2273,7 @@
   "TARGET_MAD"
   "mad\t%1,%2"
   [(set_attr "type"	"imadd")
+   (set_attr "accum_in"	"0")
    (set_attr "mode"	"SI")])
 
 ;; See the comment above <u>msubsidi4 for the relationship between
@@ -2284,6 +2298,7 @@
     return "%[macc<u>\t%@,%1,%2%]";
 }
   [(set_attr "type" "imadd")
+   (set_attr "accum_in"	"3")
    (set_attr "mode" "SI")])
 
 ;; Floating point multiply accumulate instructions.
@@ -2296,6 +2311,7 @@
   "ISA_HAS_FP_MADD4_MSUB4 && TARGET_FUSED_MADD"
   "madd.<fmt>\t%0,%3,%1,%2"
   [(set_attr "type" "fmadd")
+   (set_attr "accum_in"	"3")
    (set_attr "mode" "<UNITMODE>")])
 
 (define_insn "*madd3<mode>"
@@ -2306,6 +2322,7 @@
   "ISA_HAS_FP_MADD3_MSUB3 && TARGET_FUSED_MADD"
   "madd.<fmt>\t%0,%1,%2"
   [(set_attr "type" "fmadd")
+   (set_attr "accum_in"	"3")
    (set_attr "mode" "<UNITMODE>")])
 
 (define_insn "*msub4<mode>"
@@ -2316,6 +2333,7 @@
   "ISA_HAS_FP_MADD4_MSUB4 && TARGET_FUSED_MADD"
   "msub.<fmt>\t%0,%3,%1,%2"
   [(set_attr "type" "fmadd")
+   (set_attr "accum_in"	"3")
    (set_attr "mode" "<UNITMODE>")])
 
 (define_insn "*msub3<mode>"
@@ -2326,6 +2344,7 @@
   "ISA_HAS_FP_MADD3_MSUB3 && TARGET_FUSED_MADD"
   "msub.<fmt>\t%0,%1,%2"
   [(set_attr "type" "fmadd")
+   (set_attr "accum_in"	"3")
    (set_attr "mode" "<UNITMODE>")])
 
 (define_insn "*nmadd4<mode>"
@@ -2340,6 +2359,7 @@
    && !HONOR_NANS (<MODE>mode)"
   "nmadd.<fmt>\t%0,%3,%1,%2"
   [(set_attr "type" "fmadd")
+   (set_attr "accum_in"	"3")
    (set_attr "mode" "<UNITMODE>")])
 
 (define_insn "*nmadd3<mode>"
@@ -2354,6 +2374,7 @@
    && !HONOR_NANS (<MODE>mode)"
   "nmadd.<fmt>\t%0,%1,%2"
   [(set_attr "type" "fmadd")
+   (set_attr "accum_in"	"3")
    (set_attr "mode" "<UNITMODE>")])
 
 (define_insn "*nmadd4<mode>_fastmath"
@@ -2368,6 +2389,7 @@
    && !HONOR_NANS (<MODE>mode)"
   "nmadd.<fmt>\t%0,%3,%1,%2"
   [(set_attr "type" "fmadd")
+   (set_attr "accum_in"	"3")
    (set_attr "mode" "<UNITMODE>")])
 
 (define_insn "*nmadd3<mode>_fastmath"
@@ -2382,6 +2404,7 @@
    && !HONOR_NANS (<MODE>mode)"
   "nmadd.<fmt>\t%0,%1,%2"
   [(set_attr "type" "fmadd")
+   (set_attr "accum_in"	"3")
    (set_attr "mode" "<UNITMODE>")])
 
 (define_insn "*nmsub4<mode>"
@@ -2396,6 +2419,7 @@
    && !HONOR_NANS (<MODE>mode)"
   "nmsub.<fmt>\t%0,%1,%2,%3"
   [(set_attr "type" "fmadd")
+   (set_attr "accum_in"	"1")
    (set_attr "mode" "<UNITMODE>")])
 
 (define_insn "*nmsub3<mode>"
@@ -2410,6 +2434,7 @@
    && !HONOR_NANS (<MODE>mode)"
   "nmsub.<fmt>\t%0,%1,%2"
   [(set_attr "type" "fmadd")
+   (set_attr "accum_in"	"1")
    (set_attr "mode" "<UNITMODE>")])
 
 (define_insn "*nmsub4<mode>_fastmath"
@@ -2424,6 +2449,7 @@
    && !HONOR_NANS (<MODE>mode)"
   "nmsub.<fmt>\t%0,%1,%2,%3"
   [(set_attr "type" "fmadd")
+   (set_attr "accum_in"	"1")
    (set_attr "mode" "<UNITMODE>")])
 
 (define_insn "*nmsub3<mode>_fastmath"
@@ -2438,6 +2464,7 @@
    && !HONOR_NANS (<MODE>mode)"
   "nmsub.<fmt>\t%0,%1,%2"
   [(set_attr "type" "fmadd")
+   (set_attr "accum_in"	"1")
    (set_attr "mode" "<UNITMODE>")])
 
 ;;

[-- Attachment #4: Type: text/plain, Size: 1 bytes --]



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH, MIPS] 74k madd scheduler tweaks
  2012-08-14  0:06       ` Maxim Kuvyrkov
@ 2012-08-14  7:08         ` Richard Sandiford
  2012-08-15  5:53           ` Maxim Kuvyrkov
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Sandiford @ 2012-08-14  7:08 UTC (permalink / raw)
  To: Maxim Kuvyrkov; +Cc: Sandra Loosemore, gcc-patches

Maxim Kuvyrkov <maxim@codesourcery.com> writes:
> I thought I'll butt in since I did a very similar thing for
> sync_memmodel a couple of months ago.

Thanks.

> +  /* We take care in instruction definitions to make sure accum_in operand is
> +     a register_operand or [a more restrictive] muldiv_target_operand.  */
> +  gcc_assert (REG_P (accum_in_op));

register_operand can accept subregs too.  I think it'd be better to
leave this bit out.

> diff --git a/gcc/config/mips/mips.md b/gcc/config/mips/mips.md
> index 759958b..79c1f25 100644
> --- a/gcc/config/mips/mips.md
> +++ b/gcc/config/mips/mips.md
> @@ -275,6 +275,10 @@
>  (define_attr "sync_memmodel" "" (const_int 10))
>  
>  
> +;; Accumulator operand for madd patterns.
> +(define_attr "accum_in" "none,0,1,2,3,4,5" (const_string "none"))
> +
> +

Nit: just one blank line between attributes.

> @@ -1715,6 +1724,7 @@
>    "ISA_HAS_MACC && reload_completed"
>    "macc\t%3,%1,%2"
>    [(set_attr "type"	"imadd")
> +   (set_attr "accum_in"	"3")
>     (set_attr "mode"	"SI")])
>  
>  (define_insn "*msac2"
> @@ -1729,6 +1739,7 @@
>    "ISA_HAS_MSAC && reload_completed"
>    "msac\t%3,%1,%2"
>    [(set_attr "type"	"imadd")
> +   (set_attr "accum_in"	"3")
>     (set_attr "mode"	"SI")])
>  
>  ;; Convert macc $0,<r1>,<r2> & mflo <r3> into macc <r3>,<r1>,<r2>

These two should be "0" instead.

OK with those changes, thanks.

Richard

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH, MIPS] 74k madd scheduler tweaks
  2012-08-14  7:08         ` Richard Sandiford
@ 2012-08-15  5:53           ` Maxim Kuvyrkov
  0 siblings, 0 replies; 7+ messages in thread
From: Maxim Kuvyrkov @ 2012-08-15  5:53 UTC (permalink / raw)
  To: Richard Sandiford; +Cc: Sandra Loosemore, gcc-patches

On 14/08/2012, at 7:08 PM, Richard Sandiford wrote:

> OK with those changes, thanks.

Checked in with the noted changes and a fixed bug.

It turns out that mips_linked_madd_p is also called via mips_macc_chains_reorder, which may pass a (use ...) instruction, which causes get_attr_* to blow up.  Fixed by adding

if (recog_memoized (in_insn) < 0)
  return false;

at the beginning of mips_linked_madd_p.

Richard, thanks for review, and thanks Sandra for testing the patch.

--
Maxim Kuvyrkov
CodeSourcery / Mentor Graphics


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-08-15  5:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-01 22:06 [PATCH, MIPS] 74k madd scheduler tweaks Sandra Loosemore
2012-08-04 13:48 ` Richard Sandiford
2012-08-04 20:44   ` Sandra Loosemore
2012-08-08 19:10     ` Richard Sandiford
2012-08-14  0:06       ` Maxim Kuvyrkov
2012-08-14  7:08         ` Richard Sandiford
2012-08-15  5:53           ` Maxim Kuvyrkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).