public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Ignore debug insns with CONCAT and CONCATN for insn scheduling
@ 2022-09-02 14:36 H.J. Lu
  2022-09-07 17:02 ` Jeff Law
  0 siblings, 1 reply; 8+ messages in thread
From: H.J. Lu @ 2022-09-02 14:36 UTC (permalink / raw)
  To: gcc-patches

CONCAT and CONCATN never appear in the insn chain.  They are only used
in debug insn.  Ignore debug insns with CONCAT and CONCATN for insn
scheduling to avoid different insn orders with and without debug insn.

gcc/

	PR rtl-optimization/106746
	* sched-deps.cc (sched_analyze_2): Ignore debug insns with CONCAT
	and CONCATN.

gcc/testsuite/

	PR rtl-optimization/106746
	* gcc.dg/pr106746.c: New test.
---
 gcc/sched-deps.cc               | 14 ++++++++++++++
 gcc/testsuite/gcc.dg/pr106746.c | 30 ++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/pr106746.c

diff --git a/gcc/sched-deps.cc b/gcc/sched-deps.cc
index 948aa0c3b60..b472e4fbb09 100644
--- a/gcc/sched-deps.cc
+++ b/gcc/sched-deps.cc
@@ -2794,6 +2794,20 @@ sched_analyze_2 (class deps_desc *deps, rtx x, rtx_insn *insn)
 
       return;
 
+    case VAR_LOCATION:
+      if (GET_CODE (PAT_VAR_LOCATION_LOC (x)) == CONCAT
+	  || GET_CODE (PAT_VAR_LOCATION_LOC (x)) == CONCATN)
+	{
+	  /* CONCAT and CONCATN never appear in the insn chain.  They
+	     are only used in debug insn.  Ignore insns with CONCAT and
+	     CONCATN for insn scheduling to avoid different insn orders
+	     with and without debug insn.  */
+	  if (cslr_p && sched_deps_info->finish_rhs)
+	    sched_deps_info->finish_rhs ();
+	  return;
+	}
+      break;
+
     default:
       break;
     }
diff --git a/gcc/testsuite/gcc.dg/pr106746.c b/gcc/testsuite/gcc.dg/pr106746.c
new file mode 100644
index 00000000000..1fc29de28c3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr106746.c
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-options "-Wno-psabi -O2 -fsched2-use-superblocks -fcompare-debug" } */
+typedef char __attribute__((__vector_size__ (64))) U;
+typedef short __attribute__((__vector_size__ (64))) V;
+typedef int __attribute__((__vector_size__ (64))) W;
+
+char c;
+U a;
+U *r;
+W foo0_v512u32_0;
+
+void
+foo (W)
+{
+  U u;
+  V v;
+  W w = __builtin_shuffle (foo0_v512u32_0, foo0_v512u32_0);
+  u = __builtin_shufflevector (a, u, 3, 0, 4, 9, 9, 6,
+			       7, 8, 5, 0, 6, 1, 8, 1,
+			       2, 8, 6, 1, 8, 4, 9, 3,
+			       8, 4, 6, 0, 9, 0, 1, 8,
+			       2, 3, 3, 0, 4, 9, 9, 6,
+			       7, 8, 5, 0, 6, 1, 8, 1,
+			       2, 8, 6, 1, 8, 4, 9, 3,
+			       8, 4, 6, 0, 9, 0, 1, 8,
+			       2, 3);
+  v *= c;
+  w &= c;
+  *r = (U) v + (U) w;
+}
-- 
2.37.2


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

* Re: [PATCH] Ignore debug insns with CONCAT and CONCATN for insn scheduling
  2022-09-02 14:36 [PATCH] Ignore debug insns with CONCAT and CONCATN for insn scheduling H.J. Lu
@ 2022-09-07 17:02 ` Jeff Law
  2022-09-21 22:11   ` H.J. Lu
  0 siblings, 1 reply; 8+ messages in thread
From: Jeff Law @ 2022-09-07 17:02 UTC (permalink / raw)
  To: gcc-patches



On 9/2/2022 8:36 AM, H.J. Lu via Gcc-patches wrote:
> CONCAT and CONCATN never appear in the insn chain.  They are only used
> in debug insn.  Ignore debug insns with CONCAT and CONCATN for insn
> scheduling to avoid different insn orders with and without debug insn.
>
> gcc/
>
> 	PR rtl-optimization/106746
> 	* sched-deps.cc (sched_analyze_2): Ignore debug insns with CONCAT
> 	and CONCATN.
Shouldn't we be ignoring everything in a debug insn?   I don't see why 
CONCAT/CONCATN are special here.

jeff


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

* Re: [PATCH] Ignore debug insns with CONCAT and CONCATN for insn scheduling
  2022-09-07 17:02 ` Jeff Law
@ 2022-09-21 22:11   ` H.J. Lu
  2022-09-24 20:37     ` Jeff Law
  0 siblings, 1 reply; 8+ messages in thread
From: H.J. Lu @ 2022-09-21 22:11 UTC (permalink / raw)
  To: Jeff Law; +Cc: gcc-patches

On Wed, Sep 7, 2022 at 10:03 AM Jeff Law via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
>
>
> On 9/2/2022 8:36 AM, H.J. Lu via Gcc-patches wrote:
> > CONCAT and CONCATN never appear in the insn chain.  They are only used
> > in debug insn.  Ignore debug insns with CONCAT and CONCATN for insn
> > scheduling to avoid different insn orders with and without debug insn.
> >
> > gcc/
> >
> >       PR rtl-optimization/106746
> >       * sched-deps.cc (sched_analyze_2): Ignore debug insns with CONCAT
> >       and CONCATN.
> Shouldn't we be ignoring everything in a debug insn?   I don't see why
> CONCAT/CONCATN are special here.

Debug insns are processed by insn scheduling.   I think it is to improve debug
experiences.  It is just that there are no matching usages of CONCAT/CONCATN
in non-debug insns.

--
H.J.

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

* Re: [PATCH] Ignore debug insns with CONCAT and CONCATN for insn scheduling
  2022-09-21 22:11   ` H.J. Lu
@ 2022-09-24 20:37     ` Jeff Law
  2022-09-26 19:52       ` H.J. Lu
  0 siblings, 1 reply; 8+ messages in thread
From: Jeff Law @ 2022-09-24 20:37 UTC (permalink / raw)
  To: H.J. Lu; +Cc: gcc-patches


On 9/21/22 16:11, H.J. Lu wrote:
> On Wed, Sep 7, 2022 at 10:03 AM Jeff Law via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
>>
>>
>> On 9/2/2022 8:36 AM, H.J. Lu via Gcc-patches wrote:
>>> CONCAT and CONCATN never appear in the insn chain.  They are only used
>>> in debug insn.  Ignore debug insns with CONCAT and CONCATN for insn
>>> scheduling to avoid different insn orders with and without debug insn.
>>>
>>> gcc/
>>>
>>>        PR rtl-optimization/106746
>>>        * sched-deps.cc (sched_analyze_2): Ignore debug insns with CONCAT
>>>        and CONCATN.
>> Shouldn't we be ignoring everything in a debug insn?   I don't see why
>> CONCAT/CONCATN are special here.
> Debug insns are processed by insn scheduling.   I think it is to improve debug
> experiences.  It is just that there are no matching usages of CONCAT/CONCATN
> in non-debug insns.

But from a dependency standpoint ISTM all debug insn can be ignored.  I 
still don't see why concat/concatn should be special here.


jeff



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

* Re: [PATCH] Ignore debug insns with CONCAT and CONCATN for insn scheduling
  2022-09-24 20:37     ` Jeff Law
@ 2022-09-26 19:52       ` H.J. Lu
  2022-09-26 23:23         ` Jeff Law
  0 siblings, 1 reply; 8+ messages in thread
From: H.J. Lu @ 2022-09-26 19:52 UTC (permalink / raw)
  To: Jeff Law; +Cc: gcc-patches

On Sat, Sep 24, 2022 at 1:37 PM Jeff Law <jeffreyalaw@gmail.com> wrote:
>
>
> On 9/21/22 16:11, H.J. Lu wrote:
> > On Wed, Sep 7, 2022 at 10:03 AM Jeff Law via Gcc-patches
> > <gcc-patches@gcc.gnu.org> wrote:
> >>
> >>
> >> On 9/2/2022 8:36 AM, H.J. Lu via Gcc-patches wrote:
> >>> CONCAT and CONCATN never appear in the insn chain.  They are only used
> >>> in debug insn.  Ignore debug insns with CONCAT and CONCATN for insn
> >>> scheduling to avoid different insn orders with and without debug insn.
> >>>
> >>> gcc/
> >>>
> >>>        PR rtl-optimization/106746
> >>>        * sched-deps.cc (sched_analyze_2): Ignore debug insns with CONCAT
> >>>        and CONCATN.
> >> Shouldn't we be ignoring everything in a debug insn?   I don't see why
> >> CONCAT/CONCATN are special here.
> > Debug insns are processed by insn scheduling.   I think it is to improve debug
> > experiences.  It is just that there are no matching usages of CONCAT/CONCATN
> > in non-debug insns.
>
> But from a dependency standpoint ISTM all debug insn can be ignored.  I
> still don't see why concat/concatn should be special here.
>

I tried to ignore everything in a debug insn.  It caused many regressions in
the GCC testsuite.

-- 
H.J.

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

* Re: [PATCH] Ignore debug insns with CONCAT and CONCATN for insn scheduling
  2022-09-26 19:52       ` H.J. Lu
@ 2022-09-26 23:23         ` Jeff Law
  2022-09-26 23:43           ` Jakub Jelinek
  0 siblings, 1 reply; 8+ messages in thread
From: Jeff Law @ 2022-09-26 23:23 UTC (permalink / raw)
  To: H.J. Lu; +Cc: gcc-patches


On 9/26/22 13:52, H.J. Lu wrote:
> On Sat, Sep 24, 2022 at 1:37 PM Jeff Law <jeffreyalaw@gmail.com> wrote:
>>
>> On 9/21/22 16:11, H.J. Lu wrote:
>>> On Wed, Sep 7, 2022 at 10:03 AM Jeff Law via Gcc-patches
>>> <gcc-patches@gcc.gnu.org> wrote:
>>>>
>>>> On 9/2/2022 8:36 AM, H.J. Lu via Gcc-patches wrote:
>>>>> CONCAT and CONCATN never appear in the insn chain.  They are only used
>>>>> in debug insn.  Ignore debug insns with CONCAT and CONCATN for insn
>>>>> scheduling to avoid different insn orders with and without debug insn.
>>>>>
>>>>> gcc/
>>>>>
>>>>>         PR rtl-optimization/106746
>>>>>         * sched-deps.cc (sched_analyze_2): Ignore debug insns with CONCAT
>>>>>         and CONCATN.
>>>> Shouldn't we be ignoring everything in a debug insn?   I don't see why
>>>> CONCAT/CONCATN are special here.
>>> Debug insns are processed by insn scheduling.   I think it is to improve debug
>>> experiences.  It is just that there are no matching usages of CONCAT/CONCATN
>>> in non-debug insns.
>> But from a dependency standpoint ISTM all debug insn can be ignored.  I
>> still don't see why concat/concatn should be special here.
>>
> I tried to ignore everything in a debug insn.  It caused many regressions in
> the GCC testsuite.
Not terribly useful -- what failed and why?

jeff

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

* Re: [PATCH] Ignore debug insns with CONCAT and CONCATN for insn scheduling
  2022-09-26 23:23         ` Jeff Law
@ 2022-09-26 23:43           ` Jakub Jelinek
  2022-09-27  1:40             ` Jeff Law
  0 siblings, 1 reply; 8+ messages in thread
From: Jakub Jelinek @ 2022-09-26 23:43 UTC (permalink / raw)
  To: Jeff Law; +Cc: H.J. Lu, gcc-patches

On Mon, Sep 26, 2022 at 05:23:45PM -0600, Jeff Law via Gcc-patches wrote:
> 
> On 9/26/22 13:52, H.J. Lu wrote:
> > On Sat, Sep 24, 2022 at 1:37 PM Jeff Law <jeffreyalaw@gmail.com> wrote:
> > > 
> > > On 9/21/22 16:11, H.J. Lu wrote:
> > > > On Wed, Sep 7, 2022 at 10:03 AM Jeff Law via Gcc-patches
> > > > <gcc-patches@gcc.gnu.org> wrote:
> > > > > 
> > > > > On 9/2/2022 8:36 AM, H.J. Lu via Gcc-patches wrote:
> > > > > > CONCAT and CONCATN never appear in the insn chain.  They are only used
> > > > > > in debug insn.  Ignore debug insns with CONCAT and CONCATN for insn
> > > > > > scheduling to avoid different insn orders with and without debug insn.
> > > > > > 
> > > > > > gcc/
> > > > > > 
> > > > > >         PR rtl-optimization/106746
> > > > > >         * sched-deps.cc (sched_analyze_2): Ignore debug insns with CONCAT
> > > > > >         and CONCATN.
> > > > > Shouldn't we be ignoring everything in a debug insn?   I don't see why
> > > > > CONCAT/CONCATN are special here.
> > > > Debug insns are processed by insn scheduling.   I think it is to improve debug
> > > > experiences.  It is just that there are no matching usages of CONCAT/CONCATN
> > > > in non-debug insns.
> > > But from a dependency standpoint ISTM all debug insn can be ignored.  I
> > > still don't see why concat/concatn should be special here.
> > > 
> > I tried to ignore everything in a debug insn.  It caused many regressions in
> > the GCC testsuite.
> Not terribly useful -- what failed and why?

I think the design for debug insns in the scheduler is that they do affect
scheduling decisions, but what is in debug insns should only affect actual
scheduling of the debug insns and not the rest.
So it wouldn't surprise me if ignoring everything in a debug insn broke a
lot.  But I admit I never fully understood how it works, hopefully Alex or
Vlad do.

	Jakub


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

* Re: [PATCH] Ignore debug insns with CONCAT and CONCATN for insn scheduling
  2022-09-26 23:43           ` Jakub Jelinek
@ 2022-09-27  1:40             ` Jeff Law
  0 siblings, 0 replies; 8+ messages in thread
From: Jeff Law @ 2022-09-27  1:40 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: H.J. Lu, gcc-patches


On 9/26/22 17:43, Jakub Jelinek wrote:
> On Mon, Sep 26, 2022 at 05:23:45PM -0600, Jeff Law via Gcc-patches wrote:
>> On 9/26/22 13:52, H.J. Lu wrote:
>>> On Sat, Sep 24, 2022 at 1:37 PM Jeff Law <jeffreyalaw@gmail.com> wrote:
>>>> On 9/21/22 16:11, H.J. Lu wrote:
>>>>> On Wed, Sep 7, 2022 at 10:03 AM Jeff Law via Gcc-patches
>>>>> <gcc-patches@gcc.gnu.org> wrote:
>>>>>> On 9/2/2022 8:36 AM, H.J. Lu via Gcc-patches wrote:
>>>>>>> CONCAT and CONCATN never appear in the insn chain.  They are only used
>>>>>>> in debug insn.  Ignore debug insns with CONCAT and CONCATN for insn
>>>>>>> scheduling to avoid different insn orders with and without debug insn.
>>>>>>>
>>>>>>> gcc/
>>>>>>>
>>>>>>>          PR rtl-optimization/106746
>>>>>>>          * sched-deps.cc (sched_analyze_2): Ignore debug insns with CONCAT
>>>>>>>          and CONCATN.
>>>>>> Shouldn't we be ignoring everything in a debug insn?   I don't see why
>>>>>> CONCAT/CONCATN are special here.
>>>>> Debug insns are processed by insn scheduling.   I think it is to improve debug
>>>>> experiences.  It is just that there are no matching usages of CONCAT/CONCATN
>>>>> in non-debug insns.
>>>> But from a dependency standpoint ISTM all debug insn can be ignored.  I
>>>> still don't see why concat/concatn should be special here.
>>>>
>>> I tried to ignore everything in a debug insn.  It caused many regressions in
>>> the GCC testsuite.
>> Not terribly useful -- what failed and why?
> I think the design for debug insns in the scheduler is that they do affect
> scheduling decisions, but what is in debug insns should only affect actual
> scheduling of the debug insns and not the rest.
> So it wouldn't surprise me if ignoring everything in a debug insn broke a
> lot.  But I admit I never fully understood how it works, hopefully Alex or
> Vlad do.

But if we  look at debug insns in scheduling decisions, wouldn't that 
likely trigger a variety of compare-debug failures. Something here 
doesn't make sense.


jeff


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

end of thread, other threads:[~2022-09-27  1:40 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-02 14:36 [PATCH] Ignore debug insns with CONCAT and CONCATN for insn scheduling H.J. Lu
2022-09-07 17:02 ` Jeff Law
2022-09-21 22:11   ` H.J. Lu
2022-09-24 20:37     ` Jeff Law
2022-09-26 19:52       ` H.J. Lu
2022-09-26 23:23         ` Jeff Law
2022-09-26 23:43           ` Jakub Jelinek
2022-09-27  1:40             ` Jeff Law

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