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

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