Bug 36172 - [4.4 Regression] ice for legal code with -O3
Summary: [4.4 Regression] ice for legal code with -O3
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: 4.4.0
Assignee: Richard Biener
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2008-05-07 17:09 UTC by David Binderman
Modified: 2008-05-08 08:30 UTC (History)
3 users (show)

See Also:
Host: x86_64-suse-linux
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-05-07 21:54:03


Attachments
C source code (30.62 KB, text/plain)
2008-05-07 17:10 UTC, David Binderman
Details
somehwat reduced testcase (514 bytes, text/plain)
2008-05-07 20:45 UTC, Richard Biener
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Binderman 2008-05-07 17:09:16 UTC
I just tried to compile the Suse Linux package
fontconfig-2.4.2-83 with the GNU C compiler  
version 4.4 snapshot 20080502

The compiler said

fccharset.c:1174: internal compiler error: in compare_values_warnv, at tree-vrp.c:892
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

Preprocessed source code attached. Flag -O3 required.
Comment 1 David Binderman 2008-05-07 17:10:21 UTC
Created attachment 15591 [details]
C source code
Comment 2 Andrew Pinski 2008-05-07 19:58:42 UTC
This worked with 20080325.
Comment 3 Andrew Pinski 2008-05-07 20:00:07 UTC
  gcc_assert (POINTER_TYPE_P (TREE_TYPE (val1))
              == POINTER_TYPE_P (TREE_TYPE (val2)));

:)
Comment 4 Richard Biener 2008-05-07 20:08:37 UTC
Reducing.
Comment 5 Andrew Pinski 2008-05-07 20:30:58 UTC
  # prephitmp.1564_417 = PHI <prephitmp.1561_268(20), pretmp.1563_427(4)>


  long unsigned int pretmp.1563;


prephitmp.1561 is a pointer.

Comment 6 Richard Biener 2008-05-07 20:45:29 UTC
Created attachment 15614 [details]
somehwat reduced testcase

It's probably PPRE that messes up (-O3 -fno-tree-pre is fine, -O2 -finline-functions as well).
Comment 7 Andrew Pinski 2008-05-07 21:10:57 UTC
Better reduced testcase:
typedef unsigned long int uintptr_t;
typedef struct _FcCharLeaf { } FcCharLeaf;
struct _FcCharLeafEnt {
  unsigned int hash;
  int leaf;
};
struct _FcCharSetFreezer
{
  int orig_hash_table[67];
};
struct _FcCharLeafEnt *ent;
int a, f(FcCharLeaf * );
void FcCharSetFreeze (struct _FcCharSetFreezer *freezer, int *fcs)
{
  int i;
  for (i = 0;  i < *fcs;  i++)
  {
    FcCharLeaf *leaf = (FcCharLeaf *)fcs;
    unsigned int hash = f (leaf);
    if (ent->hash == hash)
      a = ent->leaf;
    if (!a)
      return;
  }
  freezer->orig_hash_table[((uintptr_t) fcs) & 67] = 0;
}


PRE is creating the mismatched PHI nodes.
Comment 8 Richard Biener 2008-05-07 21:37:43 UTC
More reduced:

int f(float * );
__SIZE_TYPE__ FcCharSetFreeze (int *fcs, int b)
{
  int i;
  int a = 0;
  for (i = 0; i < *fcs; i++)
  {
    float *leaf = (float *)fcs;
    int hash = f (leaf);
    if (hash)
      a = b;
    if (!a)
      return;
  }
  return (__SIZE_TYPE__) fcs;
}
Comment 9 Richard Biener 2008-05-07 21:47:18 UTC
PA_IN/OUT computes different for s/(unsigned long)/(long)/ in the following
testcase (long works):

int f(float * );
unsigned long FcCharSetFreeze (int *fcs, int b)
{
  int i;
  int a = 0;
  for (i = 0; i < *fcs; i++)
  {
    float *leaf = (float *)fcs;
    int hash = f (leaf);
    if (hash)
      a = b;
    if (!a)
      return;
  }
  return (unsigned long) fcs;
}
Comment 10 Richard Biener 2008-05-07 21:50:39 UTC
operand_equal_p returns true for (float *) VH.11 and (long unsigned int) VH.11.
Comment 11 Richard Biener 2008-05-07 21:54:03 UTC
I have a patch.
Comment 12 Richard Biener 2008-05-08 08:20:06 UTC
Subject: Bug 36172

Author: rguenth
Date: Thu May  8 08:19:16 2008
New Revision: 135070

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=135070
Log:
2008-05-08  Richard Guenther  <rguenther@suse.de>

	PR middle-end/36172
	* fold-const.c (operand_equal_p): Two objects which types
	differ in pointerness are not equal.

	* gcc.c-torture/compile/pr36172.c: New testcase.

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

Comment 13 Richard Biener 2008-05-08 08:24:50 UTC
Subject: Bug 36172

Author: rguenth
Date: Thu May  8 08:23:59 2008
New Revision: 135072

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=135072
Log:
2008-05-08  Richard Guenther  <rguenther@suse.de>

	PR middle-end/36154
	* tree-ssa-structalias.c (push_fields_onto_fieldstack): Make
	sure to create a representative for trailing arrays for PTA.

	* gcc.c-torture/compile/pr36154.c: New testcase.

2008-05-08  Richard Guenther  <rguenther@suse.de>

	PR middle-end/36172
	* fold-const.c (operand_equal_p): Two objects which types
	differ in pointerness are not equal.

	* gcc.c-torture/compile/pr36172.c: New testcase.

Added:
    branches/gcc-4_3-branch/gcc/testsuite/gcc.c-torture/compile/pr36154.c
      - copied unchanged from r135071, trunk/gcc/testsuite/gcc.c-torture/compile/pr36154.c
    branches/gcc-4_3-branch/gcc/testsuite/gcc.c-torture/compile/pr36172.c
      - copied unchanged from r135071, trunk/gcc/testsuite/gcc.c-torture/compile/pr36172.c
Modified:
    branches/gcc-4_3-branch/gcc/ChangeLog
    branches/gcc-4_3-branch/gcc/fold-const.c
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_3-branch/gcc/tree-ssa-structalias.c

Comment 14 Richard Biener 2008-05-08 08:30:09 UTC
Fixed.