Bug 31632 - [4.1 regression] ICE in compare_values
Summary: [4.1 regression] ICE in compare_values
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.1.3
: P3 normal
Target Milestone: 4.1.3
Assignee: Jakub Jelinek
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2007-04-19 12:39 UTC by Jakub Jelinek
Modified: 2007-09-26 19:11 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.4.6 4.2.0 4.3.0
Known to fail: 4.1.3
Last reconfirmed: 2007-04-19 14:58:05


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Jelinek 2007-04-19 12:39:20 UTC
 
Comment 1 Jakub Jelinek 2007-04-19 12:40:33 UTC
struct S
{
  long int l;
  void *m;
};

int
foo (struct S *x)
{
  unsigned long a;
  a = x->l;
  if (a <= ((void *) 0))
    x->m = 0;
  return 0;
}

ICEs at -O2 on both x86_64-linux and ppc-linux.
Comment 2 Jakub Jelinek 2007-04-19 12:56:24 UTC
I'd say this is a frontend bug (in all of 4.1/4.2/4.3 at least), it shouldn't
have created
 <eq_expr 0x2aaaadff85a0
    type <boolean_type 0x2aaaae0018f0 _Bool public unsigned QI
        size <integer_cst 0x2aaaadff2660 constant invariant 8>
        unit size <integer_cst 0x2aaaadff2690 constant invariant 1>
        align 8 symtab 0 alias set -1 precision 1 min <integer_cst 0x2aaaadff2e40 0> max <integer_cst 0x2aaaadff2ea0 1>>
   
    arg 0 <ssa_name 0x2aaaae1bd700
        type <integer_type 0x2aaaae0016e0 long unsigned int sizes-gimplified public unsigned DI
            size <integer_cst 0x2aaaadff2c00 constant invariant 64>
            unit size <integer_cst 0x2aaaadff2c30 constant invariant 8>
            align 64 symtab 0 alias set -1 precision 64 min <integer_cst 0x2aaaadff2d20 0> max <integer_cst 0x2aaaadff2cf0 18446744073709551615>>
        var <var_decl 0x2aaaae1a8b00 a> def_stmt <modify_expr 0x2aaaadff8550>
        version 3>
    arg 1 <integer_cst 0x2aaaae00c7e0 type <pointer_type 0x2aaaae011160> constant invariant 0>
    A.c:12>

i.e. a comparison with integral type on one size and pointer on another one.
In 4.2+ forwprop1 fixes this up to comparison against 0L, but in 4.1 it makes
it through that up to vrp which asserts this is not the case.
Comment 3 Jakub Jelinek 2007-04-19 14:58:05 UTC
Actually a bug in fold-const.
Comment 4 Jakub Jelinek 2007-04-20 12:40:59 UTC
Subject: Bug 31632

Author: jakub
Date: Fri Apr 20 12:40:47 2007
New Revision: 123988

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123988
Log:
	PR tree-optimization/31632
	* fold-const.c (fold_binary): Use op0 and op1 instead of arg0
	and arg1 for optimizations of comparison against min/max values.
	Fold arg0 to arg1's type for optimizations of comparison against
	min+1 and max-1 values.

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

Added:
    trunk/gcc/testsuite/gcc.c-torture/compile/20070419-1.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/fold-const.c
    trunk/gcc/testsuite/ChangeLog

Comment 5 Jakub Jelinek 2007-04-20 12:46:21 UTC
Subject: Bug 31632

Author: jakub
Date: Fri Apr 20 12:46:06 2007
New Revision: 123990

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123990
Log:
	PR tree-optimization/31632
	* fold-const.c (fold_binary): Use op0 and op1 instead of arg0
	and arg1 for optimizations of comparison against min/max values.
	Fold arg0 to arg1's type for optimizations of comparison against
	min+1 and max-1 values.

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

Added:
    branches/gcc-4_2-branch/gcc/testsuite/gcc.c-torture/compile/20070419-1.c
Modified:
    branches/gcc-4_2-branch/gcc/ChangeLog
    branches/gcc-4_2-branch/gcc/fold-const.c
    branches/gcc-4_2-branch/gcc/testsuite/ChangeLog

Comment 6 Jakub Jelinek 2007-04-20 12:49:48 UTC
Subject: Bug 31632

Author: jakub
Date: Fri Apr 20 12:49:37 2007
New Revision: 123992

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123992
Log:
	PR tree-optimization/31632
	* fold-const.c (fold_binary): Use op0 and op1 instead of arg0
	and arg1 for optimizations of comparison against min/max values.
	Fold arg0 to arg1's type for optimizations of comparison against
	min+1 and max-1 values.

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

Added:
    branches/gcc-4_1-branch/gcc/testsuite/gcc.c-torture/compile/20070419-1.c
Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/fold-const.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog

Comment 7 Andrew Pinski 2007-09-26 19:11:24 UTC
Fixed.