Bug 22398 - [4.1 Regression] ICE in compare_values, at tree-vrp.c:445
Summary: [4.1 Regression] ICE in compare_values, at tree-vrp.c:445
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.1.0
: P2 normal
Target Milestone: 4.1.0
Assignee: Andrew Pinski
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: ice-on-valid-code, patch
Depends on:
Blocks: 22368
  Show dependency treegraph
 
Reported: 2005-07-11 01:49 UTC by dank
Modified: 2005-07-15 23:13 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-07-11 02:00:01


Attachments
Patch which should fix this (354 bytes, patch)
2005-07-11 05:24 UTC, Andrew Pinski
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description dank 2005-07-11 01:49:39 UTC
Compiling arch/sparc/kernel/process.c from linux-2.6.11.3
with gcc-4.1-20050709 fails with

arch/sparc/kernel/process.c: In function '__show_backtrace':
arch/sparc/kernel/process.c:204: internal compiler error: in compare_values, at
tree-vrp.c:445

Here's the command I use to reproduce:

sparc-unknown-linux-gnu-gcc \
-fno-strict-aliasing -fno-common -ffreestanding \
-O2     -fomit-frame-pointer -m32 -mno-fpu -fcall-used-g5 \
-fcall-used-g7 -c process.i

I haven't reduced process.i; it's 250KB.  You can download it
from http://kegel.com/gcc/process.i.txt
Comment 1 Andrew Pinski 2005-07-11 02:00:01 UTC
Confirmed, reduced testcase:
void __show_backtrace(void *rw)
{
  while(rw && (((unsigned long) rw) >= 0xf0000000) ) {}
}

looks like a fold bug with respect of type issues.  This is target independent.
Comment 2 Andrew Pinski 2005-07-11 02:12:47 UTC
And here is a testcase which fails on LP64 targets:

void __show_backtrace(void *rw)
{
  while(rw && (((unsigned long) rw) >= 0xf000000000000000) ) {}
}
Comment 3 Andrew Pinski 2005-07-11 05:14:45 UTC
I have a fix.
Comment 4 dank 2005-07-11 05:20:32 UTC
Deity on a crutch!  That was fast.
Thanks; I can test if you like, or just wait for the next snapshot.
Comment 5 Andrew Pinski 2005-07-11 05:24:35 UTC
Created attachment 9244 [details]
Patch which should fix this

(In reply to comment #4)
> Deity on a crutch!  That was fast.
I have been look into type mismatch lately and this just one of those cases. 
The problem is in build_range_check which forgets to call fold_convert in a
couple cases.
Comment 6 Andrew Pinski 2005-07-11 19:38:04 UTC
Patch posted here: <http://gcc.gnu.org/ml/gcc-patches/2005-07/msg00771.html>.
Comment 7 Andrew Pinski 2005-07-14 01:47:04 UTC
A testcase which is exposed by PR 22368's second patch:
int __show_backtrace(void *rw)
{
  return (rw && (((unsigned long) rw) >= 0xf0000000) );
}
Comment 8 Andrew Pinski 2005-07-15 23:13:33 UTC
Fixed.
Comment 9 GCC Commits 2005-07-15 23:14:13 UTC
Subject: Bug 22398

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	pinskia@gcc.gnu.org	2005-07-15 23:14:07

Modified files:
	gcc            : ChangeLog fold-const.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.c-torture/compile: pr22398.c 

Log message:
	2005-07-15  Andrew Pinski  <pinskia@physics.uc.edu>
	
	PR middle-end/22398
	* gcc.c-torture/compile/pr22398.c: New test.
	
	2005-07-11  Andrew Pinski  <pinskia@physics.uc.edu>
	
	PR middle-end/22398
	* fold-const.c (build_range_check): Convert high/low to etype
	if we are only comparing against exp.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9453&r2=2.9454
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fold-const.c.diff?cvsroot=gcc&r1=1.602&r2=1.603
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5772&r2=1.5773
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/compile/pr22398.c.diff?cvsroot=gcc&r1=NONE&r2=1.1