Bug 27865 - [4.2 Regression] tree check failure building FreePOOMA
Summary: [4.2 Regression] tree check failure building FreePOOMA
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.2.0
: P1 normal
Target Milestone: 4.2.0
Assignee: Zdenek Dvorak
URL:
Keywords: ice-on-valid-code, monitored
Depends on:
Blocks:
 
Reported: 2006-06-01 17:44 UTC by Janis Johnson
Modified: 2006-08-17 14:58 UTC (History)
6 users (show)

See Also:
Host:
Target: powerpc-linux
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-08-01 15:34:59


Attachments
minimized testcase (1000 bytes, text/plain)
2006-06-01 17:45 UTC, Janis Johnson
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Janis Johnson 2006-06-01 17:44:43 UTC
FreePOOMA 2.4.1 fails to build on powerpc-linux with beginning with this patch:

    http://gcc.gnu.org/viewcvs?view=rev&rev=114057

    r114057 | rakdver | 2006-05-24 22:55:15 +0000 (Wed, 24 May 2006)

Output with a minimized testcase:

elm3b145% /opt/gcc-nightly/trunk/bin/g++ -c -O2 poomabug.cc
poomabug.cc: In constructor ‘GLD<Dim>::GLD(const II<Dim>&, const PP&, const CM<Dim>&) [with PP = GP<2> ()(), int Dim = 2]’:
poomabug.cc:117: internal compiler error: tree check: expected integer_type or enumeral_type or boolean_type or real_type, have pointer_type in adjust_range_with_scev, at tree-vrp.c:2079
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Comment 1 Janis Johnson 2006-06-01 17:45:17 UTC
Created attachment 11574 [details]
minimized testcase
Comment 2 Volker Reichelt 2006-06-02 22:03:44 UTC
Confirmed.

Shorter testcase (fails with C or C++ frontend):

=============================================
static int* foo(int *q, int j) { return q + j; }

int* r;

void bar(int *p)
{
  int i;
  for (i=0; i<2; ++i)
    r = i ? foo(p,i-1) : 0;
}
=============================================
Comment 3 Andrew Pinski 2006-06-03 03:42:58 UTC
Here is a testcase without inline functions:
void bar(int *p, int t1)
{
    int i;
    static int *tt;
    for (i=0; i<2; ++i)
	if (i)
	{
	    int t = i - 1;
	    tt = p+t;
	}
}
Comment 4 Andrew Pinski 2006-06-03 03:46:06 UTC
The code to do:
2098                  /* If we just created an invalid range with the minimum
2099                     greater than the maximum, take the maximum all the
2100                     way to +INF.  */
2101                  if (compare_values (min, max) == 1)
2102                    max = TYPE_MAX_VALUE (TREE_TYPE (max));


Was added by:
http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=110261
Comment 5 Jeffrey A. Law 2006-06-04 22:32:24 UTC
Someone who understands SCEV really needs to fix it.  It's been a consistent source of problems for VRP -- whether it's giving us bogus ranges (ranges outside the given type) or claiming variables do not wrap when in fact they do wrap (IIRC there's still an outstanding PR due to this problem).

If someone were to fix the SCEV problem touched by pr 25900, then the offending VRP code could be eliminated.

Jeff
Comment 6 Zdenek Dvorak 2006-06-05 11:04:35 UTC
Subject: Re:  [4.2 Regression] tree check failure building FreePOOMA

> Someone who understands SCEV really needs to fix it.

On this particular piece of code SCEV seems to behave just fine; you ask
for the evolution of a pointer, and then use TYPE_MAX_VALUE on its type --
that's not going to work.

> It's been a consistent
> source of problems for VRP -- whether it's giving us bogus ranges (ranges
> outside the given type) or claiming variables do not wrap when in fact they do
> wrap (IIRC there's still an outstanding PR due to this problem).
> 
> If someone were to fix the SCEV problem touched by pr 25900, then the offending
> VRP code could be eliminated.

I will have a look.
Comment 7 Zdenek Dvorak 2006-08-01 15:34:59 UTC
After a closer investigation, there indeed seems to be a problem in chrec_convert, I am preparing a patch.

Nevertheless, the code in VRP still needs fixing -- the problem might still be reproduced even with a completely correct scev, when part of the compiled code is unreachable (and we are not able to determine this in compile time), or for invalid programs.
Comment 8 Zdenek Dvorak 2006-08-17 08:22:17 UTC
Subject: Bug 27865

Author: rakdver
Date: Thu Aug 17 08:22:05 2006
New Revision: 116213

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116213
Log:
	PR tree-optimization/27865
	* tree-vrp.c (adjust_range_with_scev): Do not use TYPE_{MIN,MAX}_VALUE
	for pointer types.
	* tree-scalar-evolution.c (fold_used_pointer_cast, pointer_offset_p,
	fold_used_pointer, pointer_used_p): New functions.
	(analyze_scalar_evolution_1): Use fold_used_pointer.
	* tree-chrec.c (convert_affine_scev): Convert no-op casts correctly.
	* tree-ssa-loop-ivopts.c (generic_type_for): Return integral type
	for pointers.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-chrec.c
    trunk/gcc/tree-scalar-evolution.c
    trunk/gcc/tree-ssa-loop-ivopts.c
    trunk/gcc/tree-vrp.c

Comment 9 Jan Hubicka 2006-08-17 09:44:19 UTC
Subject: Bug 27865

Author: hubicka
Date: Thu Aug 17 09:44:12 2006
New Revision: 116220

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116220
Log:
	PR tree-optimization/27865
	* reload1.c (forget_marked_reloads): New function.
	(forget_old_reloads_1): When data are passed, just mark the registers
	for later removal.
	(reload_as_needed): Use the new mechanizm.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/reload1.c

Comment 10 Andrew Pinski 2006-08-17 14:58:35 UTC
Fixed.