public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/64536] New: [4.9/5 Regression] Undefined .L* symbol starting with jump2 on s390x
@ 2015-01-08 10:05 jakub at gcc dot gnu.org
  2015-01-08 10:06 ` [Bug rtl-optimization/64536] " jakub at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-01-08 10:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64536

            Bug ID: 64536
           Summary: [4.9/5 Regression] Undefined .L* symbol starting with
                    jump2 on s390x
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jakub at gcc dot gnu.org
                CC: krebbel at gcc dot gnu.org, vmakarov at gcc dot gnu.org
            Target: s390x-linux

struct S { long q; } *h;
long a, b, g, j, k, *c, *d, *e, *f, *i;
long *baz (void)
{
  asm volatile ("" : : : "memory");
  return e;
}

void
bar (int x)
{
  int y;
  for (y = 0; y < x; y++)
    {
      switch (b)
        {
        case 0:
        case 2:
          a++;
          break;
        case 3:
          a++;
          break;
        case 1:
          a++;
        }
      if (d)
        {
          f = baz ();
          g = k++;
          if (&h->q)
            {
              j = *f;
              h->q = *f;
            }
          else
            i = (long *) (h->q = *f);
          *c++ = (long) f;
          e += 6;
        }
      else
        {
          f = baz ();
          g = k++;
          if (&h->q)
            {
              j = *f;
              h->q = *f;
            }
          else
            i = (long *) (h->q = *f);
          *c++ = (long) f;
          e += 6;
        }
    }
}

int
main ()
{
  return 0;
}

fails to link on s390x-linux with -O2 -m64 -fPIC, starting with r199754.
For a tablejump, we load of the jump_table_data label is hoisted before the
loop, then RA decides to spill it to stack (seems both with reload and lra),
and then jump2 goes wild and deletes the casesi_jump instruction (and lots of
other instructions it supposedly should not delete), but keeps the load of
jump_table_data label (but the jump_table_data is gone).


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

* [Bug rtl-optimization/64536] [4.9/5 Regression] Undefined .L* symbol starting with jump2 on s390x
  2015-01-08 10:05 [Bug rtl-optimization/64536] New: [4.9/5 Regression] Undefined .L* symbol starting with jump2 on s390x jakub at gcc dot gnu.org
@ 2015-01-08 10:06 ` jakub at gcc dot gnu.org
  2015-01-08 15:12 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-01-08 10:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64536

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-01-08
   Target Milestone|---                         |4.9.3
     Ever confirmed|0                           |1


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

* [Bug rtl-optimization/64536] [4.9/5 Regression] Undefined .L* symbol starting with jump2 on s390x
  2015-01-08 10:05 [Bug rtl-optimization/64536] New: [4.9/5 Regression] Undefined .L* symbol starting with jump2 on s390x jakub at gcc dot gnu.org
  2015-01-08 10:06 ` [Bug rtl-optimization/64536] " jakub at gcc dot gnu.org
@ 2015-01-08 15:12 ` jakub at gcc dot gnu.org
  2015-01-08 15:22 ` ebotcazou at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-01-08 15:12 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64536

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ebotcazou at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
So, we have bb 6:
(note 180 23 24 6 [bb 6] NOTE_INSN_BASIC_BLOCK)
(insn 24 180 25 6 (set (reg:DI 1 %r1 [orig:88 b ] [88])
        (zero_extend:DI (reg:SI 1 %r1 [orig:85 b+4 ] [85]))) method-to-ir3.i:15
184 {*zero_extendsidi2}
     (nil))
(insn 25 24 289 6 (set (reg:DI 1 %r1 [orig:88 b ] [88])
        (ashift:DI (reg:DI 1 %r1 [orig:88 b ] [88])
            (const_int 3 [0x3]))) method-to-ir3.i:15 570 {*ashldi3}
     (nil))
(insn 289 25 27 6 (set (reg/f:DI 2 %r2 [158])
        (mem/c:DI (plus:DI (reg/f:DI 15 %r15)
                (const_int 184 [0xb8])) [5 %sfp+-8 S8 A64])) method-to-ir3.i:15
63 {*movdi_64}
     (nil))
(insn 27 289 28 6 (set (reg:DI 1 %r1 [87])
        (mem/u/c:DI (plus:DI (reg/f:DI 2 %r2 [158])
                (reg:DI 1 %r1 [orig:88 b ] [88])) [0  S8 A8]))
method-to-ir3.i:15 63 {*movdi_64}
     (expr_list:REG_EQUAL (mem/u/c:DI (plus:DI (reg:DI 1 %r1 [orig:88 b ] [88])
                (label_ref:DI 29)) [0  S8 A8])
        (nil)))
(jump_insn 28 27 29 6 (parallel [
            (set (pc)
                (plus:DI (reg/f:DI 2 %r2 [158])
                    (reg:DI 1 %r1 [87])))
            (use (label_ref 29))
        ]) method-to-ir3.i:15 626 {casesi_jump}
     (expr_list:REG_DEAD (reg/f:DI 2 %r2 [158])
        (expr_list:REG_DEAD (reg:DI 1 %r1 [87])
            (nil)))
 -> 29)
with:
(code_label 29 28 30 7 "" [2 uses])
(jump_table_data 30 29 31 (addr_diff_vec:DI (label_ref:DI 29)
         [
            (label_ref:DI 50)
            (label_ref:DI 50)
            (label_ref:DI 50)
            (label_ref:DI 50)
        ]
        (const_int 0 [0])
        (const_int 0 [0])))
after it (outside of bb) (as all the case labels do the same thing, they have
been jump threaded, but unfortunately not at GIMPLE, but only at RTL level) and
post_order_compute calls tidy_fallthru_edges which calls tidy_fallthru_edge
on the only successor edge from bb 6 (6 -> 9, bb 9 is the bb starting with
code_label 50).  When all the jump_table_data labels point to the same
destination, it is reasonable to optimize that to direct jump, but I guess we
need to take care about making sure that the code_label before the
jump_table_data is only removed when it has zero LABEL_NUSES.


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

* [Bug rtl-optimization/64536] [4.9/5 Regression] Undefined .L* symbol starting with jump2 on s390x
  2015-01-08 10:05 [Bug rtl-optimization/64536] New: [4.9/5 Regression] Undefined .L* symbol starting with jump2 on s390x jakub at gcc dot gnu.org
  2015-01-08 10:06 ` [Bug rtl-optimization/64536] " jakub at gcc dot gnu.org
  2015-01-08 15:12 ` jakub at gcc dot gnu.org
@ 2015-01-08 15:22 ` ebotcazou at gcc dot gnu.org
  2015-01-08 16:46 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2015-01-08 15:22 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64536

--- Comment #2 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
> When all the jump_table_data labels point to the same destination, it is 
> reasonable to optimize that to direct jump, but I guess we need to take care
> about making sure that the code_label before the jump_table_data is only 
> removed when it has zero LABEL_NUSES.

Very likely indeed (delete_related_insns does something like that).


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

* [Bug rtl-optimization/64536] [4.9/5 Regression] Undefined .L* symbol starting with jump2 on s390x
  2015-01-08 10:05 [Bug rtl-optimization/64536] New: [4.9/5 Regression] Undefined .L* symbol starting with jump2 on s390x jakub at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2015-01-08 15:22 ` ebotcazou at gcc dot gnu.org
@ 2015-01-08 16:46 ` jakub at gcc dot gnu.org
  2015-01-09 21:17 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-01-08 16:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64536

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 34404
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34404&action=edit
gcc5-pr64536.patch

Given that tidy_fallthru_edge seems to be called only rarely, I think adding
too much code to handle tablejumps with single successor is not a good idea.

So I think we should just give up on tablejumps there.  And perhaps make sure
we optimize single successor tablejumps somewhere else, where it is run often
enough that it will be actually beneficial.

E.g.
int a;
#define A(n) case n: a++; break;
#define B(n) A(n##0) A(n##1) A(n##2) A(n##3) A(n##4) \
A(n##5) A(n##6) A(n##7) A(n##8) A(n##9)
#define C(n) B(n##0) B(n##1) B(n##2) B(n##3) B(n##4) \
B(n##5) B(n##6) B(n##7) B(n##8) B(n##9)

void
foo (int x)
{
  switch (x)
    {
    C(1)
    }
}

on x86_64 with -O2 or -O2 -fpic isn't optimized, because tidy_fallthru_edges
isn't called and so we do not even attempt to do anything about it.
On the s390x testcase it is called just because some other cleanup in another
part of the function created unreachable blocks that need cleanup.
And, wonder why tree-ssa-tail-merge.c doesn't want to optimize this.  Perhaps
it gives up because of the load and store?


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

* [Bug rtl-optimization/64536] [4.9/5 Regression] Undefined .L* symbol starting with jump2 on s390x
  2015-01-08 10:05 [Bug rtl-optimization/64536] New: [4.9/5 Regression] Undefined .L* symbol starting with jump2 on s390x jakub at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2015-01-08 16:46 ` jakub at gcc dot gnu.org
@ 2015-01-09 21:17 ` jakub at gcc dot gnu.org
  2015-01-09 21:36 ` jakub at gcc dot gnu.org
  2015-01-09 22:15 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-01-09 21:17 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64536

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Fri Jan  9 21:17:10 2015
New Revision: 219405

URL: https://gcc.gnu.org/viewcvs?rev=219405&root=gcc&view=rev
Log:
    PR rtl-optimization/64536
    * cfgrtl.c (rtl_tidy_fallthru_edge): Handle removal of degenerate
    tablejumps.

    * gcc.dg/pr64536.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/pr64536.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/ada/ChangeLog
    trunk/gcc/c-family/ChangeLog
    trunk/gcc/c/ChangeLog
    trunk/gcc/cfgrtl.c
    trunk/gcc/cp/ChangeLog
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/go/ChangeLog
    trunk/gcc/java/ChangeLog
    trunk/gcc/lto/ChangeLog
    trunk/gcc/objc/ChangeLog
    trunk/gcc/objcp/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/libcc1/ChangeLog


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

* [Bug rtl-optimization/64536] [4.9/5 Regression] Undefined .L* symbol starting with jump2 on s390x
  2015-01-08 10:05 [Bug rtl-optimization/64536] New: [4.9/5 Regression] Undefined .L* symbol starting with jump2 on s390x jakub at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2015-01-09 21:17 ` jakub at gcc dot gnu.org
@ 2015-01-09 21:36 ` jakub at gcc dot gnu.org
  2015-01-09 22:15 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-01-09 21:36 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64536

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Fri Jan  9 21:36:10 2015
New Revision: 219409

URL: https://gcc.gnu.org/viewcvs?rev=219409&root=gcc&view=rev
Log:
    PR rtl-optimization/64536
    * cfgrtl.c (rtl_tidy_fallthru_edge): Handle removal of degenerate
    tablejumps.

    * gcc.dg/pr64536.c: New test.

Added:
    branches/gcc-4_9-branch/gcc/testsuite/gcc.dg/pr64536.c
Modified:
    branches/gcc-4_9-branch/gcc/ChangeLog
    branches/gcc-4_9-branch/gcc/cfgrtl.c
    branches/gcc-4_9-branch/gcc/testsuite/ChangeLog


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

* [Bug rtl-optimization/64536] [4.9/5 Regression] Undefined .L* symbol starting with jump2 on s390x
  2015-01-08 10:05 [Bug rtl-optimization/64536] New: [4.9/5 Regression] Undefined .L* symbol starting with jump2 on s390x jakub at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2015-01-09 21:36 ` jakub at gcc dot gnu.org
@ 2015-01-09 22:15 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-01-09 22:15 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64536

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Should be fixed now.


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

end of thread, other threads:[~2015-01-09 22:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-08 10:05 [Bug rtl-optimization/64536] New: [4.9/5 Regression] Undefined .L* symbol starting with jump2 on s390x jakub at gcc dot gnu.org
2015-01-08 10:06 ` [Bug rtl-optimization/64536] " jakub at gcc dot gnu.org
2015-01-08 15:12 ` jakub at gcc dot gnu.org
2015-01-08 15:22 ` ebotcazou at gcc dot gnu.org
2015-01-08 16:46 ` jakub at gcc dot gnu.org
2015-01-09 21:17 ` jakub at gcc dot gnu.org
2015-01-09 21:36 ` jakub at gcc dot gnu.org
2015-01-09 22:15 ` jakub at gcc dot gnu.org

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