public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, middle-end]: Introduce TARGET_LEGITIMATE_COMBINED_INSN target hook
@ 2012-08-26  9:01 Uros Bizjak
  2012-08-26 10:26 ` Georg-Johann Lay
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Uros Bizjak @ 2012-08-26  9:01 UTC (permalink / raw)
  To: gcc-patches

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

Hello!

Actually a v3 of TARGET_REJECT_COMBINED_INSN target hook.

Changes:
- rename the hook and reverse the return value

2012-08-25  Uros Bizjak  <ubizjak@gmail.com>

	* target.def (legitimate_combined_insn): New target hook.
	* doc/tm.texi.in (TARGET_LEGITIMATE_COMBINED_INSN): New hook.
	* doc/tm.texi: Regenerated.
	* combine.c (recog_for_combine): Call targetm.legitimate_combined_insn
	to allow targets to reject combined insn.
	* hooks.h (hook_bool_rtx_true): New.
	* hooks.c (hook_bool_rtx_true): Ditto.

Bootstrapped and regression tested on x86_64-pc-linux-gnu {,-m32},
also with target-dependant x86 patch that implements the hook.

Uros.

[-- Attachment #2: p.diff.txt --]
[-- Type: text/plain, Size: 4932 bytes --]

Index: target.def
===================================================================
--- target.def	(revision 190665)
+++ target.def	(working copy)
@@ -1984,7 +1984,16 @@ DEFHOOK
  const char *, (const_rtx insn),
  default_invalid_within_doloop)
 
+/* Returns true for a legitimate combined insn.  */
 DEFHOOK
+(legitimate_combined_insn,
+"Take an instruction in @var{insn} and return @code{false} if the instruction\
+ is not appropriate as a combination of two or more instructions.  The\
+ default is to accept all instructions.",
+ bool, (rtx insn),
+ hook_bool_rtx_true)
+
+DEFHOOK
 (valid_dllimport_attribute_p,
 "@var{decl} is a variable or function with @code{__attribute__((dllimport))}\
  specified.  Use this hook if the target needs to add extra validation\
Index: hooks.c
===================================================================
--- hooks.c	(revision 190665)
+++ hooks.c	(working copy)
@@ -269,6 +269,12 @@ hook_bool_tree_bool_false (tree a ATTRIBUTE_UNUSED
 }
 
 bool
+hook_bool_rtx_true (rtx a ATTRIBUTE_UNUSED)
+{
+  return true;
+}
+
+bool
 hook_bool_rtx_false (rtx a ATTRIBUTE_UNUSED)
 {
   return false;
Index: hooks.h
===================================================================
--- hooks.h	(revision 190665)
+++ hooks.h	(working copy)
@@ -50,6 +50,7 @@ extern bool hook_bool_const_tree_hwi_hwi_const_tre
 							  HOST_WIDE_INT,
 							  HOST_WIDE_INT,
 							  const_tree);
+extern bool hook_bool_rtx_true (rtx);
 extern bool hook_bool_rtx_false (rtx);
 extern bool hook_bool_rtx_int_false (rtx, int);
 extern bool hook_bool_uintp_uintp_false (unsigned int *, unsigned int *);
Index: doc/tm.texi
===================================================================
--- doc/tm.texi	(revision 190665)
+++ doc/tm.texi	(working copy)
@@ -10938,6 +10938,10 @@ By default, the RTL loop optimizer does not use a
 loops containing function calls or branch on table instructions.
 @end deftypefn
 
+@deftypefn {Target Hook} bool TARGET_LEGITIMATE_COMBINED_INSN (rtx @var{insn})
+Take an instruction in @var{insn} and return @code{false} if the instruction is not appropriate as a combination of two or more instructions.  The default is to accept all instructions.
+@end deftypefn
+
 @defmac MD_CAN_REDIRECT_BRANCH (@var{branch1}, @var{branch2})
 
 Take a branch insn in @var{branch1} and another in @var{branch2}.
Index: doc/tm.texi.in
===================================================================
--- doc/tm.texi.in	(revision 190665)
+++ doc/tm.texi.in	(working copy)
@@ -10796,6 +10796,8 @@ By default, the RTL loop optimizer does not use a
 loops containing function calls or branch on table instructions.
 @end deftypefn
 
+@hook TARGET_LEGITIMATE_COMBINED_INSN
+
 @defmac MD_CAN_REDIRECT_BRANCH (@var{branch1}, @var{branch2})
 
 Take a branch insn in @var{branch1} and another in @var{branch2}.
Index: combine.c
===================================================================
--- combine.c	(revision 190665)
+++ combine.c	(working copy)
@@ -10500,11 +10500,13 @@ static int
 recog_for_combine (rtx *pnewpat, rtx insn, rtx *pnotes)
 {
   rtx pat = *pnewpat;
+  rtx pat_without_clobbers;
   int insn_code_number;
   int num_clobbers_to_add = 0;
   int i;
-  rtx notes = 0;
+  rtx notes = NULL_RTX;
   rtx old_notes, old_pat;
+  int old_icode;
 
   /* If PAT is a PARALLEL, check to see if it contains the CLOBBER
      we use to indicate that something didn't match.  If we find such a
@@ -10518,7 +10520,7 @@ recog_for_combine (rtx *pnewpat, rtx insn, rtx *pn
   old_pat = PATTERN (insn);
   old_notes = REG_NOTES (insn);
   PATTERN (insn) = pat;
-  REG_NOTES (insn) = 0;
+  REG_NOTES (insn) = NULL_RTX;
 
   insn_code_number = recog (pat, insn, &num_clobbers_to_add);
   if (dump_file && (dump_flags & TDF_DETAILS))
@@ -10564,6 +10566,9 @@ recog_for_combine (rtx *pnewpat, rtx insn, rtx *pn
 	  print_rtl_single (dump_file, pat);
 	}
     }
+
+  pat_without_clobbers = pat;
+
   PATTERN (insn) = old_pat;
   REG_NOTES (insn) = old_notes;
 
@@ -10605,6 +10610,35 @@ recog_for_combine (rtx *pnewpat, rtx insn, rtx *pn
       pat = newpat;
     }
 
+  if (insn_code_number >= 0
+      && insn_code_number != NOOP_MOVE_INSN_CODE)
+    {
+      old_pat = PATTERN (insn);
+      old_notes = REG_NOTES (insn);
+      old_icode = INSN_CODE (insn);
+      PATTERN (insn) = pat;
+      REG_NOTES (insn) = notes;
+
+      /* Allow targets to reject combined insn.  */
+      if (!targetm.legitimate_combined_insn (insn))
+	{
+	  if (dump_file && (dump_flags & TDF_DETAILS))
+	    fputs ("Instruction not appropriate for target.",
+		   dump_file);
+
+	  /* Callers expect recog_for_combine to strip
+	     clobbers from the pattern on failure.  */
+	  pat = pat_without_clobbers;
+	  notes = NULL_RTX;
+
+	  insn_code_number = -1;
+	}
+
+      PATTERN (insn) = old_pat;
+      REG_NOTES (insn) = old_notes;
+      INSN_CODE (insn) = old_icode;
+    }
+
   *pnewpat = pat;
   *pnotes = notes;
 

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

* Re: [PATCH, middle-end]: Introduce TARGET_LEGITIMATE_COMBINED_INSN target hook
  2012-08-26  9:01 [PATCH, middle-end]: Introduce TARGET_LEGITIMATE_COMBINED_INSN target hook Uros Bizjak
@ 2012-08-26 10:26 ` Georg-Johann Lay
  2012-08-26 18:02   ` Uros Bizjak
  2012-08-31  9:49 ` [PATCH ping, " Uros Bizjak
  2012-09-01 14:32 ` [PATCH, " Uros Bizjak
  2 siblings, 1 reply; 7+ messages in thread
From: Georg-Johann Lay @ 2012-08-26 10:26 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: gcc-patches

Uros Bizjak schrieb:
> Hello!
> 
> Actually a v3 of TARGET_REJECT_COMBINED_INSN target hook.
> 
> Changes:
> - rename the hook and reverse the return value
> 
> 2012-08-25  Uros Bizjak  <ubizjak@gmail.com>
> 
> 	* target.def (legitimate_combined_insn): New target hook.
> 	* doc/tm.texi.in (TARGET_LEGITIMATE_COMBINED_INSN): New hook.
> 	* doc/tm.texi: Regenerated.
> 	* combine.c (recog_for_combine): Call targetm.legitimate_combined_insn
> 	to allow targets to reject combined insn.
> 	* hooks.h (hook_bool_rtx_true): New.
> 	* hooks.c (hook_bool_rtx_true): Ditto.
> 
> Bootstrapped and regression tested on x86_64-pc-linux-gnu {,-m32},
> also with target-dependant x86 patch that implements the hook.
> 
> Uros.

Sorry for yet another question.

I had the situation where the decision depends on the values held in the
registers (not for x86) like zeroed bits.

Is that information available at the time the hook is called and could
it be passed down to the backend?

What I mean is information like nonzero_bits
   "what we know about the nonzero bits of a register, specifically
    which bits are known to be zero."

It would be great if the backend was supplied with such informations
if they are readily available.  It's merely impossible for the
backend to reconstruct that knowledge, e.g. if a value is know to
always be 0 or 1.

Thanks for your patience.

Johann

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

* Re: [PATCH, middle-end]: Introduce TARGET_LEGITIMATE_COMBINED_INSN target hook
  2012-08-26 10:26 ` Georg-Johann Lay
@ 2012-08-26 18:02   ` Uros Bizjak
  0 siblings, 0 replies; 7+ messages in thread
From: Uros Bizjak @ 2012-08-26 18:02 UTC (permalink / raw)
  To: Georg-Johann Lay; +Cc: gcc-patches

On Sun, Aug 26, 2012 at 12:24 PM, Georg-Johann Lay <gjl@gcc.gnu.org> wrote:
>
>> Actually a v3 of TARGET_REJECT_COMBINED_INSN target hook.
>>
>> Changes:
>> - rename the hook and reverse the return value
>>
>> 2012-08-25  Uros Bizjak  <ubizjak@gmail.com>
>>
>>         * target.def (legitimate_combined_insn): New target hook.
>>         * doc/tm.texi.in (TARGET_LEGITIMATE_COMBINED_INSN): New hook.
>>         * doc/tm.texi: Regenerated.
>>         * combine.c (recog_for_combine): Call
>> targetm.legitimate_combined_insn
>>         to allow targets to reject combined insn.
>>         * hooks.h (hook_bool_rtx_true): New.
>>         * hooks.c (hook_bool_rtx_true): Ditto.
>>
>> Bootstrapped and regression tested on x86_64-pc-linux-gnu {,-m32},
>> also with target-dependant x86 patch that implements the hook.
>
> Sorry for yet another question.
>
> I had the situation where the decision depends on the values held in the
> registers (not for x86) like zeroed bits.
>
> Is that information available at the time the hook is called and could
> it be passed down to the backend?

No, it is not yet available. You can get const_int there as an
operand, but values in registers are not known.

Uros.

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

* [PATCH ping, middle-end]: Introduce TARGET_LEGITIMATE_COMBINED_INSN target hook
  2012-08-26  9:01 [PATCH, middle-end]: Introduce TARGET_LEGITIMATE_COMBINED_INSN target hook Uros Bizjak
  2012-08-26 10:26 ` Georg-Johann Lay
@ 2012-08-31  9:49 ` Uros Bizjak
  2012-09-01 14:32 ` [PATCH, " Uros Bizjak
  2 siblings, 0 replies; 7+ messages in thread
From: Uros Bizjak @ 2012-08-31  9:49 UTC (permalink / raw)
  To: gcc-patches

On Sun, Aug 26, 2012 at 11:00 AM, Uros Bizjak <ubizjak@gmail.com> wrote:

> Actually a v3 of TARGET_REJECT_COMBINED_INSN target hook.
>
> Changes:
> - rename the hook and reverse the return value
>
> 2012-08-25  Uros Bizjak  <ubizjak@gmail.com>
>
>         * target.def (legitimate_combined_insn): New target hook.
>         * doc/tm.texi.in (TARGET_LEGITIMATE_COMBINED_INSN): New hook.
>         * doc/tm.texi: Regenerated.
>         * combine.c (recog_for_combine): Call targetm.legitimate_combined_insn
>         to allow targets to reject combined insn.
>         * hooks.h (hook_bool_rtx_true): New.
>         * hooks.c (hook_bool_rtx_true): Ditto.
>
> Bootstrapped and regression tested on x86_64-pc-linux-gnu {,-m32},
> also with target-dependant x86 patch that implements the hook.

Ping.

This pstch will really help reload for x86 and its dedicated registers [1].

[1] http://gcc.gnu.org/ml/gcc-patches/2012-08/msg01598.html

Uros.

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

* Re: [PATCH, middle-end]: Introduce TARGET_LEGITIMATE_COMBINED_INSN target hook
  2012-08-26  9:01 [PATCH, middle-end]: Introduce TARGET_LEGITIMATE_COMBINED_INSN target hook Uros Bizjak
  2012-08-26 10:26 ` Georg-Johann Lay
  2012-08-31  9:49 ` [PATCH ping, " Uros Bizjak
@ 2012-09-01 14:32 ` Uros Bizjak
  2012-09-01 17:33   ` H.J. Lu
  2 siblings, 1 reply; 7+ messages in thread
From: Uros Bizjak @ 2012-09-01 14:32 UTC (permalink / raw)
  To: gcc-patches

On Sun, Aug 26, 2012 at 11:00 AM, Uros Bizjak <ubizjak@gmail.com> wrote:

> Actually a v3 of TARGET_REJECT_COMBINED_INSN target hook.
>
> Changes:
> - rename the hook and reverse the return value
>
> 2012-08-25  Uros Bizjak  <ubizjak@gmail.com>
>
>         * target.def (legitimate_combined_insn): New target hook.
>         * doc/tm.texi.in (TARGET_LEGITIMATE_COMBINED_INSN): New hook.
>         * doc/tm.texi: Regenerated.
>         * combine.c (recog_for_combine): Call targetm.legitimate_combined_insn
>         to allow targets to reject combined insn.
>         * hooks.h (hook_bool_rtx_true): New.
>         * hooks.c (hook_bool_rtx_true): Ditto.
>
> Bootstrapped and regression tested on x86_64-pc-linux-gnu {,-m32},
> also with target-dependant x86 patch that implements the hook.

I have committed the patch to mainline SVN, since the patch is
non-algorithmic and has no impact on non-x86 targets.

Uros.

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

* Re: [PATCH, middle-end]: Introduce TARGET_LEGITIMATE_COMBINED_INSN target hook
  2012-09-01 14:32 ` [PATCH, " Uros Bizjak
@ 2012-09-01 17:33   ` H.J. Lu
  2012-09-01 18:08     ` Uros Bizjak
  0 siblings, 1 reply; 7+ messages in thread
From: H.J. Lu @ 2012-09-01 17:33 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: gcc-patches

On Sat, Sep 1, 2012 at 7:32 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
> On Sun, Aug 26, 2012 at 11:00 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
>
>> Actually a v3 of TARGET_REJECT_COMBINED_INSN target hook.
>>
>> Changes:
>> - rename the hook and reverse the return value
>>
>> 2012-08-25  Uros Bizjak  <ubizjak@gmail.com>
>>
>>         * target.def (legitimate_combined_insn): New target hook.
>>         * doc/tm.texi.in (TARGET_LEGITIMATE_COMBINED_INSN): New hook.
>>         * doc/tm.texi: Regenerated.
>>         * combine.c (recog_for_combine): Call targetm.legitimate_combined_insn
>>         to allow targets to reject combined insn.
>>         * hooks.h (hook_bool_rtx_true): New.
>>         * hooks.c (hook_bool_rtx_true): Ditto.
>>
>> Bootstrapped and regression tested on x86_64-pc-linux-gnu {,-m32},
>> also with target-dependant x86 patch that implements the hook.
>
> I have committed the patch to mainline SVN, since the patch is
> non-algorithmic and has no impact on non-x86 targets.
>
> Uros.

I think it caused:

FAIL: gcc.dg/pr14475.c (internal compiler error)
FAIL: gcc.dg/pr14475.c forward ref (test for errors, line 6)
FAIL: gcc.dg/pr14475.c extension (test for errors, line 6)
FAIL: gcc.dg/pr14475.c narrower (test for warnings, line 6)
FAIL: gcc.dg/pr14475.c incomplete (test for errors, line 6)
FAIL: gcc.dg/pr14475.c (test for excess errors)

on Linux/x86-64.

-- 
H.J.

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

* Re: [PATCH, middle-end]: Introduce TARGET_LEGITIMATE_COMBINED_INSN target hook
  2012-09-01 17:33   ` H.J. Lu
@ 2012-09-01 18:08     ` Uros Bizjak
  0 siblings, 0 replies; 7+ messages in thread
From: Uros Bizjak @ 2012-09-01 18:08 UTC (permalink / raw)
  To: H.J. Lu; +Cc: gcc-patches

On Sat, Sep 1, 2012 at 7:32 PM, H.J. Lu <hjl.tools@gmail.com> wrote:

>>> Actually a v3 of TARGET_REJECT_COMBINED_INSN target hook.
>>>
>>> Changes:
>>> - rename the hook and reverse the return value
>>>
>>> 2012-08-25  Uros Bizjak  <ubizjak@gmail.com>
>>>
>>>         * target.def (legitimate_combined_insn): New target hook.
>>>         * doc/tm.texi.in (TARGET_LEGITIMATE_COMBINED_INSN): New hook.
>>>         * doc/tm.texi: Regenerated.
>>>         * combine.c (recog_for_combine): Call targetm.legitimate_combined_insn
>>>         to allow targets to reject combined insn.
>>>         * hooks.h (hook_bool_rtx_true): New.
>>>         * hooks.c (hook_bool_rtx_true): Ditto.
>>>
>>> Bootstrapped and regression tested on x86_64-pc-linux-gnu {,-m32},
>>> also with target-dependant x86 patch that implements the hook.
>>
>> I have committed the patch to mainline SVN, since the patch is
>> non-algorithmic and has no impact on non-x86 targets.
>>
>> Uros.
>
> I think it caused:
>
> FAIL: gcc.dg/pr14475.c (internal compiler error)
> FAIL: gcc.dg/pr14475.c forward ref (test for errors, line 6)
> FAIL: gcc.dg/pr14475.c extension (test for errors, line 6)
> FAIL: gcc.dg/pr14475.c narrower (test for warnings, line 6)
> FAIL: gcc.dg/pr14475.c incomplete (test for errors, line 6)
> FAIL: gcc.dg/pr14475.c (test for excess errors)
>
> on Linux/x86-64.

The test compiles OK for me.

Uros.

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

end of thread, other threads:[~2012-09-01 18:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-26  9:01 [PATCH, middle-end]: Introduce TARGET_LEGITIMATE_COMBINED_INSN target hook Uros Bizjak
2012-08-26 10:26 ` Georg-Johann Lay
2012-08-26 18:02   ` Uros Bizjak
2012-08-31  9:49 ` [PATCH ping, " Uros Bizjak
2012-09-01 14:32 ` [PATCH, " Uros Bizjak
2012-09-01 17:33   ` H.J. Lu
2012-09-01 18:08     ` Uros Bizjak

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).