Bug 33148 - [4.2 Regression] ICE in trunc_int_for_mode, at explow.c:56 during combine
Summary: [4.2 Regression] ICE in trunc_int_for_mode, at explow.c:56 during combine
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.2.2
: P3 major
Target Milestone: 4.2.2
Assignee: Jakub Jelinek
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2007-08-22 12:59 UTC by Richard Biener
Modified: 2007-12-02 22:41 UTC (History)
3 users (show)

See Also:
Host:
Target: powerpc64-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2007-08-27 10:14:50


Attachments
unreduced testcase (12.88 KB, text/plain)
2007-08-22 13:07 UTC, Richard Biener
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2007-08-22 12:59:46 UTC
typedef struct _IO_FILE FILE;
typedef unsigned long potrace_word;
struct potrace_bitmap_s {
    int dy;
    potrace_word *map;
};
typedef struct potrace_bitmap_s potrace_bitmap_t;
struct bmp_info_s {
    unsigned int w;
    unsigned int h;
    unsigned int bits;
    unsigned int comp;
};
typedef struct bmp_info_s bmp_info_t;
static int bm_readbody_bmp(FILE *f, double threshold, potrace_bitmap_t **bmp)
{
    bmp_info_t bmpinfo;
    unsigned int b;
    unsigned int i;
    potrace_bitmap_t *bm;
    int mask;
    unsigned int y;
    int col1[2];
    if (col1[0] < col1[1])
        mask = 0xff;
    else
        mask = 0;
    for (y=0; y<bmpinfo.h; y++)
        for (i=0; i<bmpinfo.w; i++)
        {
            b ^= mask;
            *(bm->map + y*bm->dy) |= (potrace_word)b << i;
        }
    return -1;
}
int bm_read(FILE *f, double threshold, potrace_bitmap_t **bmp, int *magic)
{
    if (magic[0] == 'B' && magic[1] == 'M')
        return bm_readbody_bmp(f, threshold, bmp);
    return 0;
}

ICEs with

./cc1 -quiet bitmap_io.min.i -O
bitmap_io.min.i: In function 'bm_read':
bitmap_io.min.i:41: internal compiler error: in trunc_int_for_mode, at explow.c:56
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

56        gcc_assert (SCALAR_INT_MODE_P (mode));

#1  0x00000000005c0bd3 in trunc_int_for_mode (c=255, mode=CCmode)
    at /space/rguenther/src/svn/gcc-4_2-branch/gcc/explow.c:56
#2  0x00000000005ae2b0 in gen_int_mode (c=255, mode=CCmode)
    at /space/rguenther/src/svn/gcc-4_2-branch/gcc/emit-rtl.c:404
#3  0x000000000079e4e7 in simplify_binary_operation_1 (code=AND, mode=DImode, 
    op0=0x2b2c79301190, op1=0x2b2c78e6cae0, trueop0=0x2b2c79301190, 
    trueop1=0x2b2c78e6cae0)
    at /space/rguenther/src/svn/gcc-4_2-branch/gcc/simplify-rtx.c:2224
#4  0x000000000079b76d in simplify_binary_operation (code=AND, mode=DImode, 
    op0=0x2b2c79301190, op1=0x2b2c78e6cae0)
    at /space/rguenther/src/svn/gcc-4_2-branch/gcc/simplify-rtx.c:1473
#5  0x0000000000797e7f in simplify_gen_binary (code=AND, mode=DImode, 
    op0=0x2b2c79301190, op1=0x2b2c78e6cae0)
    at /space/rguenther/src/svn/gcc-4_2-branch/gcc/simplify-rtx.c:119
#6  0x00000000008bac56 in simplify_and_const_int (x=0x0, mode=DImode, 
    varop=0x2b2c79301190, constop=255)
    at /space/rguenther/src/svn/gcc-4_2-branch/gcc/combine.c:8247
#7  0x00000000008bd00e in simplify_shift_const_1 (code=LSHIFTRT, 
    result_mode=DImode, varop=0x2b2c79301190, orig_count=56)
#8  0x00000000008bd0e4 in simplify_shift_const (x=0x0, code=LSHIFTRT, 
    result_mode=DImode, varop=0x2b2c79300d60, count=56)
    at /space/rguenther/src/svn/gcc-4_2-branch/gcc/combine.c:9275
#9  0x00000000008b44f3 in expand_compound_operation (x=0x2b2c79301180)
    at /space/rguenther/src/svn/gcc-4_2-branch/gcc/combine.c:5779
#10 0x00000000008b7267 in force_to_mode (x=0x2b2c79301180, mode=DImode, 
    mask=18446744073709551615, just_select=0)
    at /space/rguenther/src/svn/gcc-4_2-branch/gcc/combine.c:6910
#11 0x00000000008b2969 in simplify_set (x=0x2b2c792fde20)
    at /space/rguenther/src/svn/gcc-4_2-branch/gcc/combine.c:5186
#12 0x00000000008b127e in combine_simplify_rtx (x=0x2b2c792fde20, 
    op0_mode=VOIDmode, in_dest=0)
    at /space/rguenther/src/svn/gcc-4_2-branch/gcc/combine.c:4800
#13 0x00000000008af5ad in subst (x=0x2b2c792fde20, from=0x2b2c792fc020, 
    to=0x2b2c79300b60, in_dest=0, unique_copy=0)
    at /space/rguenther/src/svn/gcc-4_2-branch/gcc/combine.c:4131
#14 0x00000000008ae6b7 in subst (x=0x2b2c793010a0, from=0x2b2c792fc020, 
    to=0x2b2c79300b60, in_dest=0, unique_copy=0)
    at /space/rguenther/src/svn/gcc-4_2-branch/gcc/combine.c:4008
#15 0x00000000008a9475 in try_combine (i3=0x2b2c792f99b0, i2=0x2b2c792f9960, 
    i1=0x2b2c792f9870, new_direct_jump_p=0x7fff31d5a7bc)
    at /space/rguenther/src/svn/gcc-4_2-branch/gcc/combine.c:2386
#16 0x00000000008a50ef in combine_instructions (f=0x2b2c792d86c0, nregs=170)
    at /space/rguenther/src/svn/gcc-4_2-branch/gcc/combine.c:845
#17 0x00000000008c5138 in rest_of_handle_combine ()
    at /space/rguenther/src/svn/gcc-4_2-branch/gcc/combine.c:12614
Comment 1 Richard Biener 2007-08-22 13:07:02 UTC
Created attachment 14094 [details]
unreduced testcase
Comment 2 Richard Biener 2007-08-22 13:07:28 UTC
trunk also fails (but only with the unreduced testcase).
Comment 3 Jakub Jelinek 2007-08-27 08:52:13 UTC
More reduced testcase, which fails both on the trunk (though just with -O1)
and on 4.2 (both -O1 and -O2):

int
foo (unsigned int *p, int *q, unsigned int w, unsigned int b)
{
  unsigned int i;
  int mask;

  if (q[0] < q[1])
    mask = 0xff;
  else
    mask = 0;

  for (i = 0; 8 * i < w; i++)
    {
      b ^= mask;
      *p++ = b;
    }
  return 0;
}
Comment 4 Jakub Jelinek 2007-08-27 10:14:50 UTC
Caused by PR25600.
Comment 5 Jakub Jelinek 2007-08-28 09:47:47 UTC
Subject: Bug 33148

Author: jakub
Date: Tue Aug 28 09:47:32 2007
New Revision: 127855

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=127855
Log:
	PR rtl-optimization/33148
	* simplify-rtx.c (simplify_unary_operation_1): Only optimize
	(neg (lt X 0)) if X has scalar int mode.

	* gcc.c-torture/compile/20070827-1.c: New test.

Added:
    trunk/gcc/testsuite/gcc.c-torture/compile/20070827-1.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/simplify-rtx.c
    trunk/gcc/testsuite/ChangeLog

Comment 6 Andrew Pinski 2007-08-30 21:19:43 UTC
Fixed.
Comment 7 Jakub Jelinek 2007-08-31 07:27:51 UTC
Subject: Bug 33148

Author: jakub
Date: Fri Aug 31 07:27:40 2007
New Revision: 127959

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=127959
Log:
	PR rtl-optimization/33148
	* simplify-rtx.c (simplify_unary_operation_1): Only optimize
	(neg (lt X 0)) if X has scalar int mode.

	* gcc.c-torture/compile/20070827-1.c: New test.

Added:
    branches/gcc-4_2-branch/gcc/testsuite/gcc.c-torture/compile/20070827-1.c
Modified:
    branches/gcc-4_2-branch/gcc/ChangeLog
    branches/gcc-4_2-branch/gcc/simplify-rtx.c
    branches/gcc-4_2-branch/gcc/testsuite/ChangeLog