* [PATCH] Fix shrink-wrapping with vDRAP (PR target/55940)
@ 2013-01-15 22:39 Jakub Jelinek
2013-01-15 22:53 ` Richard Henderson
2013-01-16 16:29 ` H.J. Lu
0 siblings, 2 replies; 4+ messages in thread
From: Jakub Jelinek @ 2013-01-15 22:39 UTC (permalink / raw)
To: Richard Henderson, Bernd Schmidt; +Cc: gcc-patches, H.J. Lu
Hi!
As the following testcase shows, even when stack_realign_drap we might need
to prevent crtl->drap_reg accesses in the bbs considered for
shrink-wrapping, even if reload decides stack realignment isn't needed, the
vDRAP (in the testcase %edi) can be used by the first bbs and initialized
only later on in the prologue.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
2013-01-15 Jakub Jelinek <jakub@redhat.com>
PR target/55940
* function.c (thread_prologue_and_epilogue_insns): Always
add crtl->drap_reg to set_up_by_prologue.set, even if
stack_realign_drap is false.
* gcc.dg/pr55940.c: New test.
--- gcc/function.c.jj 2013-01-11 09:02:55.000000000 +0100
+++ gcc/function.c 2013-01-15 19:23:20.648826011 +0100
@@ -6029,7 +6029,7 @@ thread_prologue_and_epilogue_insns (void
if (pic_offset_table_rtx)
add_to_hard_reg_set (&set_up_by_prologue.set, Pmode,
PIC_OFFSET_TABLE_REGNUM);
- if (stack_realign_drap && crtl->drap_reg)
+ if (crtl->drap_reg)
add_to_hard_reg_set (&set_up_by_prologue.set,
GET_MODE (crtl->drap_reg),
REGNO (crtl->drap_reg));
--- gcc/testsuite/gcc.dg/pr55940.c.jj 2013-01-15 20:33:21.288921765 +0100
+++ gcc/testsuite/gcc.dg/pr55940.c 2013-01-15 20:33:03.000000000 +0100
@@ -0,0 +1,54 @@
+/* PR target/55940 */
+/* { dg-do run } */
+/* { dg-options "-Os" } */
+/* { dg-additional-options "-mpreferred-stack-boundary=2" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */
+
+struct S { int s; unsigned long t; };
+
+__attribute__ ((noinline, noclone)) unsigned long long
+bar (struct S *x, unsigned long y)
+{
+ asm volatile ("" : : "r" (x), "r" (y) : "memory");
+ return x->s + y;
+}
+
+__attribute__ ((noinline, noclone)) unsigned long long
+foo (struct S *x, unsigned long y)
+{
+ unsigned long a;
+ if (__builtin_expect (((__UINTPTR_TYPE__) (x) + 0x1000U < 0x2000U), 0))
+ return ~0ULL;
+ if (__builtin_expect (x->s <= 0 || x->s > 9, 0))
+ return ~0ULL;
+ a = x->t >> 12;
+ if (y == a)
+ return ~0ULL;
+ if (x->s == 3)
+ return x->t + y * 4096;
+ return bar (x, y);
+}
+
+int va, vb, vc, vd;
+
+int
+main ()
+{
+ struct S s;
+ asm volatile ("" : : : "memory");
+ int a = va, b = vb, c = vc, d = vd;
+ asm volatile ("" : : : "memory");
+ int i;
+ for (i = 0; i < 64; i++)
+ if (foo ((struct S *) 0, 0) != ~0ULL)
+ __builtin_abort ();
+ s.s = 3;
+ s.t = 2 << 12;
+ if (foo (&s, 2) != ~0ULL)
+ __builtin_abort ();
+ if (foo (&s, 3) != (2 << 12) + 3 * 4096)
+ __builtin_abort ();
+ asm volatile ("" : : : "memory");
+ va = a; vb = b; vc = c; vd = d;
+ asm volatile ("" : : : "memory");
+ return 0;
+}
Jakub
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Fix shrink-wrapping with vDRAP (PR target/55940)
2013-01-15 22:39 [PATCH] Fix shrink-wrapping with vDRAP (PR target/55940) Jakub Jelinek
@ 2013-01-15 22:53 ` Richard Henderson
2013-01-16 16:29 ` H.J. Lu
1 sibling, 0 replies; 4+ messages in thread
From: Richard Henderson @ 2013-01-15 22:53 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Bernd Schmidt, gcc-patches, H.J. Lu
On 01/15/2013 02:38 PM, Jakub Jelinek wrote:
> 2013-01-15 Jakub Jelinek<jakub@redhat.com>
>
> PR target/55940
> * function.c (thread_prologue_and_epilogue_insns): Always
> add crtl->drap_reg to set_up_by_prologue.set, even if
> stack_realign_drap is false.
>
> * gcc.dg/pr55940.c: New test.
Ok.
r~
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Fix shrink-wrapping with vDRAP (PR target/55940)
2013-01-15 22:39 [PATCH] Fix shrink-wrapping with vDRAP (PR target/55940) Jakub Jelinek
2013-01-15 22:53 ` Richard Henderson
@ 2013-01-16 16:29 ` H.J. Lu
2013-01-16 16:32 ` Jakub Jelinek
1 sibling, 1 reply; 4+ messages in thread
From: H.J. Lu @ 2013-01-16 16:29 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Richard Henderson, Bernd Schmidt, gcc-patches
On Tue, Jan 15, 2013 at 2:38 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> As the following testcase shows, even when stack_realign_drap we might need
> to prevent crtl->drap_reg accesses in the bbs considered for
> shrink-wrapping, even if reload decides stack realignment isn't needed, the
> vDRAP (in the testcase %edi) can be used by the first bbs and initialized
> only later on in the prologue.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2013-01-15 Jakub Jelinek <jakub@redhat.com>
>
> PR target/55940
> * function.c (thread_prologue_and_epilogue_insns): Always
> add crtl->drap_reg to set_up_by_prologue.set, even if
> stack_realign_drap is false.
>
> * gcc.dg/pr55940.c: New test.
>
> --- gcc/function.c.jj 2013-01-11 09:02:55.000000000 +0100
> +++ gcc/function.c 2013-01-15 19:23:20.648826011 +0100
> @@ -6029,7 +6029,7 @@ thread_prologue_and_epilogue_insns (void
> if (pic_offset_table_rtx)
> add_to_hard_reg_set (&set_up_by_prologue.set, Pmode,
> PIC_OFFSET_TABLE_REGNUM);
> - if (stack_realign_drap && crtl->drap_reg)
> + if (crtl->drap_reg)
> add_to_hard_reg_set (&set_up_by_prologue.set,
> GET_MODE (crtl->drap_reg),
> REGNO (crtl->drap_reg));
Does this cause
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56006
--
H.J.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Fix shrink-wrapping with vDRAP (PR target/55940)
2013-01-16 16:29 ` H.J. Lu
@ 2013-01-16 16:32 ` Jakub Jelinek
0 siblings, 0 replies; 4+ messages in thread
From: Jakub Jelinek @ 2013-01-16 16:32 UTC (permalink / raw)
To: H.J. Lu; +Cc: Richard Henderson, Bernd Schmidt, gcc-patches
On Wed, Jan 16, 2013 at 08:28:54AM -0800, H.J. Lu wrote:
> > --- gcc/function.c.jj 2013-01-11 09:02:55.000000000 +0100
> > +++ gcc/function.c 2013-01-15 19:23:20.648826011 +0100
> > @@ -6029,7 +6029,7 @@ thread_prologue_and_epilogue_insns (void
> > if (pic_offset_table_rtx)
> > add_to_hard_reg_set (&set_up_by_prologue.set, Pmode,
> > PIC_OFFSET_TABLE_REGNUM);
> > - if (stack_realign_drap && crtl->drap_reg)
> > + if (crtl->drap_reg)
> > add_to_hard_reg_set (&set_up_by_prologue.set,
> > GET_MODE (crtl->drap_reg),
> > REGNO (crtl->drap_reg));
>
> Does this cause
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56006
No, it is caused by http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195227
See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55547#c11
Jakub
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-01-16 16:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-15 22:39 [PATCH] Fix shrink-wrapping with vDRAP (PR target/55940) Jakub Jelinek
2013-01-15 22:53 ` Richard Henderson
2013-01-16 16:29 ` H.J. Lu
2013-01-16 16:32 ` Jakub Jelinek
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).