public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/48774] New: gcc-4.6.0 optimization regression on x86_64-unknown-linux-gnu
@ 2011-04-26 15:55 mariah.lenox at gmail dot com
  2011-04-27  9:57 ` [Bug rtl-optimization/48774] [4.6/4.7 Regression] " rguenth at gcc dot gnu.org
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: mariah.lenox at gmail dot com @ 2011-04-26 15:55 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48774

           Summary: gcc-4.6.0 optimization regression on
                    x86_64-unknown-linux-gnu
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: mariah.lenox@gmail.com


/* gcc-4.6.0 optimization regression on x86_64-unknown-linux-gnu:

% gcc  -O1  -funroll-loops -o foo foo.c
foo
order= 11
%
% gcc  -O2  -funroll-loops -o foo foo.c
foo  # hangs
make: *** [bad] Interrupt
%
% gcc-4.5.1 -O2  -funroll-loops -o foo foo.c
foo
order=11
%
% gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/gcc-4.6.0/x86_64-Linux-core2-fc/libexec/gcc/x86_64-unknown-linux-gnu/4.6.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /usr/local/gcc-4.6.0/src/gcc-4.6.0/configure
--enable-languages=c,c++,fortran --with-gnu-as
--with-gnu-as=/usr/local/binutils-2.21/x86_64-Linux-core2-fc-gcc-4.5.1-rh/bin/as
--with-gnu-ld
--with-ld=/usr/local/binutils-2.21/x86_64-Linux-core2-fc-gcc-4.5.1-rh/bin/ld
--with-gmp=/usr/local/mpir-2.3.0/x86_64-Linux-core2-fc-gcc-4.5.1-rh
--with-mpfr=/usr/local/mpfr-3.0.0/x86_64-Linux-core2-fc-mpir-2.3.0-gcc-4.5.1-rh
--with-mpc=/usr/local/mpc-0.9/x86_64-Linux-core2-fc-mpir-2.3.0-mpfr-3.0.0-gcc-4.5.1-rh
--prefix=/usr/local/gcc-4.6.0/x86_64-Linux-core2-fc
Thread model: posix
gcc version 4.6.0 (GCC) 
%

Apologies that this code is so long, but I can not find any way
to shorten it further and still demonstrate the bug.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define SIZE 12

unsigned long int ss[SIZE][2];

#define SET_BIT_MASK(x) ((unsigned long)1<<(x))

#define SET_ELEMENT_CONTAINS(e,v)   ((e)&SET_BIT_MASK(v))

#define SET_CONTAINS_FAST(s,a) (SET_ELEMENT_CONTAINS((s)[0], (a)))

#define SET_CONTAINS(s,a) (((a)<SET_MAX_SIZE(s))?SET_CONTAINS_FAST(s,a):0)

#define SET_MAX_SIZE(s) ((s)[-1])

typedef struct graph graph_t;
struct graph {
        int n;           
        unsigned long *edges[SIZE];
} gg;


#define GRAPH_IS_EDGE(g,i,j) \
    (((j)<(((g)->edges[(0)]))[-1])?SET_CONTAINS_FAST((g)->edges[(i)],j):0)
/*
  SET_CONTAINS((g)->edges[(i)], (j))
*/

int bar(graph_t *g) {
  int i,j,v;
  int tmp_used[SIZE];
  int degree[SIZE];
  int order[SIZE];
  int maxdegree,maxvertex=0;
  int samecolor;

  for (i = 0; i < SIZE; i++) {
    order[i] = 0;
    degree[i] = 0;
  }

  for (i=0; i < g->n; i++) {
    for (j=0; j < g->n; j++) {
      if ((i==j) && GRAPH_IS_EDGE(g,i,j)) {
        exit(0);;
      } 
      if (GRAPH_IS_EDGE(g,i,j)) degree[i]++;
    }
  }

  v=0;
  while (v < SIZE) {
    memset(tmp_used,0,SIZE * sizeof(int));

    do {
      maxdegree=0;
      samecolor=0;
      for (i=0; i < SIZE; i++) {
        if (!tmp_used[i] && degree[i] >= maxdegree) {
          maxvertex=i;
          maxdegree=degree[i];
          samecolor=1;
        }
      }
      if (samecolor) {
        order[v]=maxvertex;
        degree[maxvertex]=-1;
        v++;
        for (i=0; i < SIZE; i++) {
          if (GRAPH_IS_EDGE(g,maxvertex,i)) {
            tmp_used[i]=1;
            degree[i]--;
          }
        }
      }
    } while (samecolor);
  }

  return order[0];
}


graph_t *make_graph() {
  graph_t *g;
  int i;

  for (i=0; i < SIZE; i++) {
    ss[i][0] = SIZE;
  }
  ss[0][1] = 2114;
  ss[1][1] = 37;
  ss[2][1] = 1034;
  ss[3][1] = 532;
  ss[4][1] = 296;
  ss[5][1] = 82;
  ss[6][1] = 161;
  ss[7][1] = 2368;
  ss[8][1] = 656;
  ss[9][1] = 1288;
  ss[10][1] = 2564;
  ss[11][1] = 1153;

  g = &gg;
  g->n=SIZE;
  for (i=0; i < SIZE; i++) {
    g->edges[i]=&(ss[i][1]);
  }

  return g;
}



int main(int argc, char **argv) {

  graph_t *g;
  int order;

  g = make_graph();
  order = bar(g);
  printf("order= %d\n", order);

  return 0;
}


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

* [Bug rtl-optimization/48774] [4.6/4.7 Regression] gcc-4.6.0 optimization regression on x86_64-unknown-linux-gnu
  2011-04-26 15:55 [Bug rtl-optimization/48774] New: gcc-4.6.0 optimization regression on x86_64-unknown-linux-gnu mariah.lenox at gmail dot com
@ 2011-04-27  9:57 ` rguenth at gcc dot gnu.org
  2011-04-27 12:47 ` hjl.tools at gmail dot com
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-04-27  9:57 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48774

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011.04.27 09:49:15
   Target Milestone|---                         |4.6.1
            Summary|gcc-4.6.0 optimization      |[4.6/4.7 Regression]
                   |regression on               |gcc-4.6.0 optimization
                   |x86_64-unknown-linux-gnu    |regression on
                   |                            |x86_64-unknown-linux-gnu
     Ever Confirmed|0                           |1
      Known to fail|                            |4.7.0

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-04-27 09:49:15 UTC ---
Confirmed.  -fno-ivopts works around the issue (I didn't yet investigate
whether it causes the issue).


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

* [Bug rtl-optimization/48774] [4.6/4.7 Regression] gcc-4.6.0 optimization regression on x86_64-unknown-linux-gnu
  2011-04-26 15:55 [Bug rtl-optimization/48774] New: gcc-4.6.0 optimization regression on x86_64-unknown-linux-gnu mariah.lenox at gmail dot com
  2011-04-27  9:57 ` [Bug rtl-optimization/48774] [4.6/4.7 Regression] " rguenth at gcc dot gnu.org
@ 2011-04-27 12:47 ` hjl.tools at gmail dot com
  2011-04-27 19:08 ` xinliangli at gmail dot com
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: hjl.tools at gmail dot com @ 2011-04-27 12:47 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48774

H.J. Lu <hjl.tools at gmail dot com> changed:

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

--- Comment #2 from H.J. Lu <hjl.tools at gmail dot com> 2011-04-27 12:40:54 UTC ---
It is caused by revision 162653:

http://gcc.gnu.org/ml/gcc-cvs/2010-07/msg01007.html


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

* [Bug rtl-optimization/48774] [4.6/4.7 Regression] gcc-4.6.0 optimization regression on x86_64-unknown-linux-gnu
  2011-04-26 15:55 [Bug rtl-optimization/48774] New: gcc-4.6.0 optimization regression on x86_64-unknown-linux-gnu mariah.lenox at gmail dot com
  2011-04-27  9:57 ` [Bug rtl-optimization/48774] [4.6/4.7 Regression] " rguenth at gcc dot gnu.org
  2011-04-27 12:47 ` hjl.tools at gmail dot com
@ 2011-04-27 19:08 ` xinliangli at gmail dot com
  2011-04-28 10:03 ` rguenth at gcc dot gnu.org
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: xinliangli at gmail dot com @ 2011-04-27 19:08 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48774

davidxl <xinliangli at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |xinliangli at gmail dot com

--- Comment #3 from davidxl <xinliangli at gmail dot com> 2011-04-27 19:04:12 UTC ---
(In reply to comment #2)
> It is caused by revision 162653:
> 
> http://gcc.gnu.org/ml/gcc-cvs/2010-07/msg01007.html


Looked at IVOPT transformation -- seems ok.

The program passes with the following options:


 -O2 -funroll-loops regression.c -fno-tree-vrp -fno-tree-dominator-opts
-fno-gcse

Removing any of the -fno-xxx options, the program fail. -fno-gcse makes
difference indicates tree level transformations are fine -- possibly bad
aliasing?

David


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

* [Bug rtl-optimization/48774] [4.6/4.7 Regression] gcc-4.6.0 optimization regression on x86_64-unknown-linux-gnu
  2011-04-26 15:55 [Bug rtl-optimization/48774] New: gcc-4.6.0 optimization regression on x86_64-unknown-linux-gnu mariah.lenox at gmail dot com
                   ` (2 preceding siblings ...)
  2011-04-27 19:08 ` xinliangli at gmail dot com
@ 2011-04-28 10:03 ` rguenth at gcc dot gnu.org
  2011-04-29 18:58 ` jakub at gcc dot gnu.org
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-04-28 10:03 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48774

--- Comment #4 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-04-28 10:02:22 UTC ---
The code is fine with -fno-strict-aliasing, so I doubt that.  Just -fno-gcse
also doesn't fix it (nor does -fno-schedule-insns2, the usual RTL alias
related miscompiler).


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

* [Bug rtl-optimization/48774] [4.6/4.7 Regression] gcc-4.6.0 optimization regression on x86_64-unknown-linux-gnu
  2011-04-26 15:55 [Bug rtl-optimization/48774] New: gcc-4.6.0 optimization regression on x86_64-unknown-linux-gnu mariah.lenox at gmail dot com
                   ` (3 preceding siblings ...)
  2011-04-28 10:03 ` rguenth at gcc dot gnu.org
@ 2011-04-29 18:58 ` jakub at gcc dot gnu.org
  2011-04-30 16:15 ` jakub at gcc dot gnu.org
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-04-29 18:58 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48774

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

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

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-04-29 18:55:48 UTC ---
Slightly reduced testcase, fails with -O2 -funroll-loops on x86_64-linux,
succeeds with -O2:

unsigned long int s[12][2]
  = { { 12, 2114 }, { 12, 37 }, { 12, 1034 }, { 12, 532 },
      { 12, 296 }, { 12, 82 }, { 12, 161 }, { 12, 2368 },
      { 12, 656 }, { 12, 1288 }, { 12, 2564 }, { 12, 1153 } };
struct { int n; unsigned long *edges[12]; } g
  = { 12, { &s[0][1], &s[1][1], &s[2][1], &s[3][1],
        &s[4][1], &s[5][1], &s[6][1], &s[7][1],
        &s[8][1], &s[9][1], &s[10][1], &s[11][1] } };
#define SET_BIT_MASK(x) ((unsigned long)1<<(x))
#define SET_ELEMENT_CONTAINS(e,v)   ((e)&SET_BIT_MASK(v))
#define SET_CONTAINS_FAST(s,a) (SET_ELEMENT_CONTAINS((s)[0], (a)))
#define GRAPH_IS_EDGE(g,i,j) \
    (((j)<(((g)->edges[(0)]))[-1])?SET_CONTAINS_FAST((g)->edges[(i)],j):0)

int
main ()
{
  int i, j, v, a[12], c[12], e = 0;

  for (i = 0; i < 12; i++)
    c[i] = 0;
  for (i = 0; i < g.n; i++)
    for (j = 0; j < g.n; j++)
      {
    if (i == j && GRAPH_IS_EDGE (&g, i, j))
      __builtin_exit (0);
    if (GRAPH_IS_EDGE (&g, i, j))
      c[i]++;
      }
  for (i = 0; i < 12; i++)
    if (c[i] != 3)
      __builtin_abort ();
  for (v = 0; v < 2; v++)
    {
      __builtin_memset (a, 0, 12 * sizeof (int));
      for (i = 0; i < 12; i++)
    if (a[i])
      e = i;
      v++;
    }
  return e;
}


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

* [Bug rtl-optimization/48774] [4.6/4.7 Regression] gcc-4.6.0 optimization regression on x86_64-unknown-linux-gnu
  2011-04-26 15:55 [Bug rtl-optimization/48774] New: gcc-4.6.0 optimization regression on x86_64-unknown-linux-gnu mariah.lenox at gmail dot com
                   ` (4 preceding siblings ...)
  2011-04-29 18:58 ` jakub at gcc dot gnu.org
@ 2011-04-30 16:15 ` jakub at gcc dot gnu.org
  2011-05-02  8:53 ` jakub at gcc dot gnu.org
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-04-30 16:15 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48774

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-04-30 16:14:52 UTC ---
Tiny bit more simplified, without the GRAPH_IS_EDGE and related macros:

unsigned long int s[12][2]
  = { { 12, 2114 }, { 12, 37 }, { 12, 1034 }, { 12, 532 },
      { 12, 296 }, { 12, 82 }, { 12, 161 }, { 12, 2368 },
      { 12, 656 }, { 12, 1288 }, { 12, 2564 }, { 12, 1153 } };
struct { int n; unsigned long *edges[12]; } g
  = { 12, { &s[0][1], &s[1][1], &s[2][1], &s[3][1],
        &s[4][1], &s[5][1], &s[6][1], &s[7][1],
        &s[8][1], &s[9][1], &s[10][1], &s[11][1] } };

int
main ()
{
  int i, j, v, a[12], c[12], e = 0;

  for (i = 0; i < 12; i++)
    c[i] = 0;
  for (i = 0; i < g.n; i++)
    for (j = 0; j < g.n; j++)
      {
    if (i == j && j < g.edges[0][-1] && (g.edges[i][0] & (1UL << j)))
      __builtin_exit (0);
    if (j < g.edges[0][-1] && (g.edges[i][0] & (1UL << j)))
      c[i]++;
      }
  for (i = 0; i < 12; i++)
    if (c[i] != 3)
      __builtin_abort ();
  for (v = 0; v < 2; v++)
    {
      __builtin_memset (a, 0, 12 * sizeof (int));
      for (i = 0; i < 12; i++)
    if (a[i])
      e = i;
    }
  return e;
}


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

* [Bug rtl-optimization/48774] [4.6/4.7 Regression] gcc-4.6.0 optimization regression on x86_64-unknown-linux-gnu
  2011-04-26 15:55 [Bug rtl-optimization/48774] New: gcc-4.6.0 optimization regression on x86_64-unknown-linux-gnu mariah.lenox at gmail dot com
                   ` (5 preceding siblings ...)
  2011-04-30 16:15 ` jakub at gcc dot gnu.org
@ 2011-05-02  8:53 ` jakub at gcc dot gnu.org
  2011-05-02  9:13 ` jakub at gcc dot gnu.org
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-05-02  8:53 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48774

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-05-02 08:52:44 UTC ---
unsigned long int s[12][2]
  = { { 12, ~1 }, { 12, ~2 }, { 12, ~4 }, { 12, ~8 },
      { 12, ~16 }, { 12, ~32 }, { 12, ~64 }, { 12, ~128 },
      { 12, ~256 }, { 12, ~512 }, { 12, ~1024 }, { 12, ~2048 } };
struct { int n; unsigned long *e[12]; } g
  = { 12, { &s[0][1], &s[1][1], &s[2][1], &s[3][1],
    &s[4][1], &s[5][1], &s[6][1], &s[7][1],
    &s[8][1], &s[9][1], &s[10][1], &s[11][1] } };

int
main ()
{
  int i, j, c[12];
  for (i = 0; i < 12; i++)
    c[i] = 0;
  for (i = 0; i < g.n; i++)
    for (j = 0; j < g.n; j++)
      {
        if (i == j && j < g.e[0][-1] && (g.e[i][0] & (1UL << j)))
          __builtin_exit (0);
        if (j < g.e[0][-1] && (g.e[i][0] & (1UL << j)))
          c[i]++;
      }
  for (i = 0; i < 12; i++)
    if (c[i] != 11)
      __builtin_abort ();
  return 0;
}

Slightly more reduced.  This one shows clearly on which iteration of the inner
unrolled loop there is some problem, as c during abort is { 10, 11, 10 ... },
which means & 1 testing is performed, & 2 is wrong and & 4 and higher works
too.


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

* [Bug rtl-optimization/48774] [4.6/4.7 Regression] gcc-4.6.0 optimization regression on x86_64-unknown-linux-gnu
  2011-04-26 15:55 [Bug rtl-optimization/48774] New: gcc-4.6.0 optimization regression on x86_64-unknown-linux-gnu mariah.lenox at gmail dot com
                   ` (6 preceding siblings ...)
  2011-05-02  8:53 ` jakub at gcc dot gnu.org
@ 2011-05-02  9:13 ` jakub at gcc dot gnu.org
  2011-05-02 14:16 ` jakub at gcc dot gnu.org
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-05-02  9:13 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48774

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-05-02 09:10:23 UTC ---
/* PR rtl-optimization/48774 */
/* { dg-do run } */
/* { dg-options "-O2 -funroll-loops" } */

extern void abort (void);
unsigned long int s[24]
  = { 12, ~1, 12, ~2, 12, ~4, 12, ~8, 12, ~16, 12, ~32,
      12, ~64, 12, ~128, 12, ~256, 12, ~512, 12, ~1024, 12, ~2048 };
struct { int n; unsigned long *e[12]; } g
  = { 12, { &s[0], &s[2], &s[4], &s[6], &s[8], &s[10], &s[12], &s[14],
    &s[16], &s[18], &s[20], &s[22] } };
int c[12];

__attribute__((noinline, noclone)) void
foo (void)
{
  int i, j;
  for (i = 0; i < g.n; i++)
    for (j = 0; j < g.n; j++)
      {
        if (i == j && j < g.e[0][0] && (g.e[i][1] & (1UL << j)))
          abort ();
        if (j < g.e[0][0] && (g.e[i][1] & (1UL << j)))
          c[i]++;
      }
}

int
main ()
{
  int i;
  asm volatile ("" : "+m" (s), "+m" (g), "+m" (c));
  foo ();
  for (i = 0; i < 12; i++)
    if (c[i] != 11)
      abort ();
  return 0;
}

Apparently the [0][-1] didn't matter, and this testcase also decreases the size
of the miscompiled routine.


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

* [Bug rtl-optimization/48774] [4.6/4.7 Regression] gcc-4.6.0 optimization regression on x86_64-unknown-linux-gnu
  2011-04-26 15:55 [Bug rtl-optimization/48774] New: gcc-4.6.0 optimization regression on x86_64-unknown-linux-gnu mariah.lenox at gmail dot com
                   ` (7 preceding siblings ...)
  2011-05-02  9:13 ` jakub at gcc dot gnu.org
@ 2011-05-02 14:16 ` jakub at gcc dot gnu.org
  2011-05-02 14:16 ` jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-05-02 14:16 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48774

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |jakub at gcc dot gnu.org
                   |gnu.org                     |


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

* [Bug rtl-optimization/48774] [4.6/4.7 Regression] gcc-4.6.0 optimization regression on x86_64-unknown-linux-gnu
  2011-04-26 15:55 [Bug rtl-optimization/48774] New: gcc-4.6.0 optimization regression on x86_64-unknown-linux-gnu mariah.lenox at gmail dot com
                   ` (8 preceding siblings ...)
  2011-05-02 14:16 ` jakub at gcc dot gnu.org
@ 2011-05-02 14:16 ` jakub at gcc dot gnu.org
  2011-05-02 17:32 ` [Bug target/48774] " jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-05-02 14:16 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48774

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-05-02 13:58:28 UTC ---
This looks like a target bug to me
in *.postreload we have:
(insn 615 177 616 32 (set (reg:CCC 17 flags)
        (compare:CCC (zero_extract:DI (reg:DI 5 di [orig:129 prephitmp.8 ]
[129])
                (const_int 1 [0x1])
                (const_int 1 [0x1]))
            (const_int 0 [0]))) pr48774-6.c:23 377 {*testqi_ext_3_rex64}
     (nil))

(jump_insn 616 615 184 32 (set (pc)
        (if_then_else (ne (reg:CCC 17 flags)
                (const_int 0 [0]))
            (label_ref 214)
            (pc))) pr48774-6.c:23 589 {*jcc_1}
     (expr_list:REG_BR_PROB (const_int 5000 [0x1388])
        (nil))

which comes from jcc_bt* splitter, where the second const1_rtx still was a
register at the time of the split, but IRA materialized it into a constant.
The CCC mode is fine for bt insn.  Unfortunately split2 pass splits this into:

(insn 626 177 616 32 (set (reg:CCC 17 flags)
        (compare:CCC (and:QI (reg:QI 5 di [orig:129 prephitmp.8 ] [129])
                (const_int 2 [0x2]))
            (const_int 0 [0]))) pr48774-6.c:23 369 {*testqi_1_maybe_si}
     (nil))

(jump_insn 616 626 184 32 (set (pc)
        (if_then_else (ne (reg:CCC 17 flags)
                (const_int 0 [0]))
            (label_ref 214)
            (pc))) pr48774-6.c:23 589 {*jcc_1}
     (expr_list:REG_BR_PROB (const_int 5000 [0x1388])
        (nil))
 -> 214)

which is already incorrect, if we want to replace bt-ish test, we'd need to
update the mode to CCmode or similar and update the user(s).
The generated assembly then has:
        andl    $2, %edi
        jnc     .L21
whereas it should have been either
        btl     $1, %edi
        jnc     .L21
or
        andl    $2, %edi
        je      .L21


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

* [Bug target/48774] [4.6/4.7 Regression] gcc-4.6.0 optimization regression on x86_64-unknown-linux-gnu
  2011-04-26 15:55 [Bug rtl-optimization/48774] New: gcc-4.6.0 optimization regression on x86_64-unknown-linux-gnu mariah.lenox at gmail dot com
                   ` (9 preceding siblings ...)
  2011-05-02 14:16 ` jakub at gcc dot gnu.org
@ 2011-05-02 17:32 ` jakub at gcc dot gnu.org
  2011-05-03 13:08 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-05-02 17:32 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48774

--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-05-02 17:31:17 UTC ---
Created attachment 24169
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24169
gcc47-pr48774.patch

Untested fix.  The additional condition could be changed to just CCCmode check,
or on the other side have:
 || !(TARGET_USE_BT || optimize_function_for_size_p (cfun))
in as well.  Or *bt<mode> would need to be represented in RTL in some different
way, where the setting of Carry is natural to the operation and couldn't be
confused with testqi.


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

* [Bug target/48774] [4.6/4.7 Regression] gcc-4.6.0 optimization regression on x86_64-unknown-linux-gnu
  2011-04-26 15:55 [Bug rtl-optimization/48774] New: gcc-4.6.0 optimization regression on x86_64-unknown-linux-gnu mariah.lenox at gmail dot com
                   ` (10 preceding siblings ...)
  2011-05-02 17:32 ` [Bug target/48774] " jakub at gcc dot gnu.org
@ 2011-05-03 13:08 ` jakub at gcc dot gnu.org
  2011-05-03 13:18 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-05-03 13:08 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48774

--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-05-03 13:01:17 UTC ---
Author: jakub
Date: Tue May  3 13:01:12 2011
New Revision: 173301

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=173301
Log:
    PR target/48774
    * config/i386/i386.c (ix86_match_ccmode): For CC{A,C,O,S}mode
    only succeed if req_mode is the same as set_mode.

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

Added:
    trunk/gcc/testsuite/gcc.dg/pr48774.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug target/48774] [4.6/4.7 Regression] gcc-4.6.0 optimization regression on x86_64-unknown-linux-gnu
  2011-04-26 15:55 [Bug rtl-optimization/48774] New: gcc-4.6.0 optimization regression on x86_64-unknown-linux-gnu mariah.lenox at gmail dot com
                   ` (11 preceding siblings ...)
  2011-05-03 13:08 ` jakub at gcc dot gnu.org
@ 2011-05-03 13:18 ` jakub at gcc dot gnu.org
  2011-05-03 13:26 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-05-03 13:18 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48774

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

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

--- Comment #13 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-05-03 13:07:20 UTC ---
Fixed.


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

* [Bug target/48774] [4.6/4.7 Regression] gcc-4.6.0 optimization regression on x86_64-unknown-linux-gnu
  2011-04-26 15:55 [Bug rtl-optimization/48774] New: gcc-4.6.0 optimization regression on x86_64-unknown-linux-gnu mariah.lenox at gmail dot com
                   ` (12 preceding siblings ...)
  2011-05-03 13:18 ` jakub at gcc dot gnu.org
@ 2011-05-03 13:26 ` jakub at gcc dot gnu.org
  2011-05-03 16:46 ` jakub at gcc dot gnu.org
  2011-05-04  9:24 ` jakub at gcc dot gnu.org
  15 siblings, 0 replies; 17+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-05-03 13:26 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48774

--- Comment #12 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-05-03 13:06:14 UTC ---
Author: jakub
Date: Tue May  3 13:06:06 2011
New Revision: 173302

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=173302
Log:
    PR target/48774
    * config/i386/i386.c (ix86_match_ccmode): For CC{A,C,O,S}mode
    only succeed if req_mode is the same as set_mode.

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

Added:
    branches/gcc-4_6-branch/gcc/testsuite/gcc.dg/pr48774.c
Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/config/i386/i386.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog


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

* [Bug target/48774] [4.6/4.7 Regression] gcc-4.6.0 optimization regression on x86_64-unknown-linux-gnu
  2011-04-26 15:55 [Bug rtl-optimization/48774] New: gcc-4.6.0 optimization regression on x86_64-unknown-linux-gnu mariah.lenox at gmail dot com
                   ` (13 preceding siblings ...)
  2011-05-03 13:26 ` jakub at gcc dot gnu.org
@ 2011-05-03 16:46 ` jakub at gcc dot gnu.org
  2011-05-04  9:24 ` jakub at gcc dot gnu.org
  15 siblings, 0 replies; 17+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-05-03 16:46 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48774

--- Comment #14 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-05-03 16:38:34 UTC ---
Author: jakub
Date: Tue May  3 16:38:25 2011
New Revision: 173329

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=173329
Log:
    PR target/48774
    * config/i386/i386.c (ix86_match_ccmode): For CC{A,C,O,S}mode
    only succeed if req_mode is the same as set_mode.

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

Added:
    branches/gcc-4_5-branch/gcc/testsuite/gcc.dg/pr48774.c
Modified:
    branches/gcc-4_5-branch/gcc/ChangeLog
    branches/gcc-4_5-branch/gcc/config/i386/i386.c
    branches/gcc-4_5-branch/gcc/testsuite/ChangeLog


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

* [Bug target/48774] [4.6/4.7 Regression] gcc-4.6.0 optimization regression on x86_64-unknown-linux-gnu
  2011-04-26 15:55 [Bug rtl-optimization/48774] New: gcc-4.6.0 optimization regression on x86_64-unknown-linux-gnu mariah.lenox at gmail dot com
                   ` (14 preceding siblings ...)
  2011-05-03 16:46 ` jakub at gcc dot gnu.org
@ 2011-05-04  9:24 ` jakub at gcc dot gnu.org
  15 siblings, 0 replies; 17+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-05-04  9:24 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48774

--- Comment #15 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-05-04 09:21:15 UTC ---
Author: jakub
Date: Wed May  4 09:21:09 2011
New Revision: 173359

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=173359
Log:
    Backported from mainline
    2011-05-03  Uros Bizjak  <ubizjak@gmail.com>
            Jakub Jelinek  <jakub@redhat.com>

    PR target/48774
    * config/i386/i386.c (ix86_match_ccmode): For CC{A,C,O,S}mode
    only succeed if req_mode is the same as set_mode.

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

Added:
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/pr48774.c
Modified:
    branches/gcc-4_4-branch/gcc/ChangeLog
    branches/gcc-4_4-branch/gcc/config/i386/i386.c
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog


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

end of thread, other threads:[~2011-05-04  9:24 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-26 15:55 [Bug rtl-optimization/48774] New: gcc-4.6.0 optimization regression on x86_64-unknown-linux-gnu mariah.lenox at gmail dot com
2011-04-27  9:57 ` [Bug rtl-optimization/48774] [4.6/4.7 Regression] " rguenth at gcc dot gnu.org
2011-04-27 12:47 ` hjl.tools at gmail dot com
2011-04-27 19:08 ` xinliangli at gmail dot com
2011-04-28 10:03 ` rguenth at gcc dot gnu.org
2011-04-29 18:58 ` jakub at gcc dot gnu.org
2011-04-30 16:15 ` jakub at gcc dot gnu.org
2011-05-02  8:53 ` jakub at gcc dot gnu.org
2011-05-02  9:13 ` jakub at gcc dot gnu.org
2011-05-02 14:16 ` jakub at gcc dot gnu.org
2011-05-02 14:16 ` jakub at gcc dot gnu.org
2011-05-02 17:32 ` [Bug target/48774] " jakub at gcc dot gnu.org
2011-05-03 13:08 ` jakub at gcc dot gnu.org
2011-05-03 13:18 ` jakub at gcc dot gnu.org
2011-05-03 13:26 ` jakub at gcc dot gnu.org
2011-05-03 16:46 ` jakub at gcc dot gnu.org
2011-05-04  9:24 ` 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).