This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

optimization/3836: ICE using -O3 but not with -O2



>Number:         3836
>Category:       optimization
>Synopsis:       ICE using -O3 but not with -O2
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          ice-on-legal-code
>Submitter-Id:   net
>Arrival-Date:   Thu Jul 26 22:06:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Uwe F. Mayer
>Release:        3.0
>Organization:
tux.org
>Environment:
System: Linux tosca 2.2.18 #2 Thu Mar 8 13:48:25 PST 2001 i686 unknown
Architecture: i686
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc-3.0/configure --disable-nls --prefix=/usr/local/gcc-3.0
>Description:
ICE when compiling code with -O3. Code compiles fine with -O2.

tosca:tmp$ gcc -v
Reading specs from /usr/local/gcc/bin/../lib/gcc-lib/i686-pc-linux-gnu/3.0/specs
Configured with: ../gcc-3.0/configure --disable-nls --prefix=/usr/local/gcc-3.0
Thread model: single
gcc version 3.0
tosca:tmp$ /usr/local/gcc/bin/gcc -Wall -O2 -c bug11.c
tosca:tmp$ /usr/local/gcc/bin/gcc -Wall -O3 -c bug11.c
bug11.c: In function `FindSubPel':
bug11.c:146: Internal error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.
>How-To-Repeat:
Run "gcc -O3 -c bug11.c", file bug11.c follows.

/**************************************************************************
 *                                                                        *
 * This code is developed by Adam Li.  This software is an                *
 * implementation of a part of one or more MPEG-4 Video tools as          *
 * specified in ISO/IEC 14496-2 standard.  Those intending to use this    *
 * software module in hardware or software products are advised that its  *
 * use may infringe existing patents or copyrights, and any such use      *
 * would be at such party's own risk.  The original developer of this     *
 * software module and his/her company, and subsequent editors and their  *
 * companies (including Project Mayo), will have no liability for use of  *
 * this software or modifications or derivatives thereof.                 *
 *                                                                        *
 * Project Mayo gives users of the Codec a license to this software       *
 * module or modifications thereof for use in hardware or software        *
 * products claiming conformance to the MPEG-4 Video Standard as          *
 * described in the Open DivX license.                                    *
 *                                                                        *
 * The complete Open DivX license can be found at                         *
 * http://www.projectmayo.com/opendivx/license.php .                      *
 *                                                                        *
 **************************************************************************/

/**************************************************************************
 *
 *  mot_est_mb.c
 *  Copyright (C) 2001  Project Mayo
 *  Adam Li
 *  DivX Advance Research Center <darc@projectmayo.com>
 *
 **************************************************************************/

/**************************************************************************
 *
 * Code extracted Thu Jul 26 21:49:17 PDT 2001 for gcc-3.0 bug report
 * Uwe F. Mayer
 * <mayer@tux.org>
 *
 **************************************************************************/

typedef struct pixpoint  {  int x;  int y;  } PixPoint;

void
FindSubPel(int x,int y,short int *prev,short int *curr,int bs_x,int bs_y,
	   int comp,int rel_x,int rel_y,int pels,int lines,int edge,
	   short int *flags,short int *curr_comp_mb,float *mvx,
	   float *mvy,int *min_error)
{
  static PixPoint search[9] =
  {
    {0, 0}, {-1, -1}, {0, -1}, {1, -1},
    {-1, 0}, {1, 0}, {-1, 1}, {0, 1}, {1, 1}
  };

  int i, m, n;
  int new_x, new_y, lx, size_x;
  int min_pos;
  int AE, AE_min;
  int flag_pos;
  short int *pRef, *pComp;

  int flag_search[9] = {1, 1, 1, 1, 1, 1, 1, 1, 1};

  int SubDimension = 2;

  lx = 2*pels;

  new_x = (int)((x + *mvx + rel_x)*(SubDimension));
  new_y = (int)((y + *mvy + rel_y)*(SubDimension));
  new_x += ((comp&1)<<3)*SubDimension;
  new_y += ((comp&2)<<2)*SubDimension;

  size_x=16;

  if (bs_x==8)
    flag_pos=4+comp*4;
  else
    flag_pos=0;

  if (((new_x/SubDimension) <= 0) || *(flags+flag_pos)) {
    flag_search[1] = flag_search[4] = flag_search[6] = 0;
  } else if (((new_x/SubDimension) >= (pels - bs_x )) || *(flags+flag_pos+1)) {
    flag_search[3] = flag_search[5] = flag_search[8] = 0;
  };

  if (((new_y/SubDimension) <= 0) || *(flags+flag_pos+2)) {
    flag_search[1] = flag_search[2] = flag_search[3] = 0;
  } else if (((new_y/SubDimension) >= (lines- bs_y)) || *(flags+flag_pos+3)) {
    flag_search[6] = flag_search[7] = flag_search[8] = 0;
  };

  AE_min = 0x2000000;
  min_pos = 0;
  for (i = 0; i < 9; i++)
    {
      if (flag_search[i])
	{
	  AE = 0;

	  pRef = prev + new_x + search[i].x + (new_y + search[i].y) * lx;
	  pComp = curr;

	  n = bs_y;
	  while (n--) {
	    m = bs_x;
	    while (m--) {
	      AE += (int)*pRef - (int)*pComp;
	      pRef += 2;
	      pComp ++;
	    }
	    pRef += 2 * lx - 2 * bs_x;
	    pComp += size_x - bs_x;
	  }

	  if (i==0 && bs_y==16 && *mvx==0 && *mvy==0)
	    AE -= (128 + 1);

	  if (AE < AE_min)
	    {
	      AE_min = AE;
	      min_pos = i;
	    }
	}
    }

  *min_error = AE_min;
  *mvx += ((float)search[min_pos].x)/(float)(SubDimension);
  *mvy += ((float)search[min_pos].y)/(float)(SubDimension);


  pRef = prev + new_x + search[min_pos].x + (new_y + search[min_pos].y) * lx;
  pComp = curr_comp_mb;

  n = bs_y;
  while (n--) {
    m = bs_x;
    while (m--) {
      *(pComp ++) = *pRef;
      pRef += 2;
    }
    pRef += 2 * lx - 2 * bs_x;
    pComp += 16 - bs_x;
  }

  return;
}


>Fix:
Use -O2.
>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]