Bug 42749 - [4.5 Regression] -O2 and verify_stmts failed again
Summary: [4.5 Regression] -O2 and verify_stmts failed again
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.5.0
: P1 normal
Target Milestone: 4.5.0
Assignee: Richard Biener
URL:
Keywords: ice-checking, ice-on-valid-code
: 42923 (view as bug list)
Depends on:
Blocks: 39932 42923
  Show dependency treegraph
 
Reported: 2010-01-14 19:54 UTC by David Binderman
Modified: 2010-02-22 15:46 UTC (History)
6 users (show)

See Also:
Host: x86_64-suse-linux
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2010-01-16 10:41:54


Attachments
C source code (28.06 KB, text/plain)
2010-01-14 19:55 UTC, David Binderman
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Binderman 2010-01-14 19:54:41 UTC
I just tried to compile the package pspdftool with
the GNU C compiler version 4.5 snapshot 20100107 and the
compiler said

gcc -DHAVE_CONFIG_H -I.    -std=gnu99 -O2 -g -m64 -fmessage-length=0 -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -MT pdf_parser.o -MD -MP -MF .deps/pdf_parser.Tpo -c -o pdf_parser.o pdf_parser.c
pdf_parser.c: In function 'pdf_count_size_object':
pdf_parser.c:1030:1: error: type mismatch in binary expression
int

int

unsigned int

add_acc.43_71 = add_acc.43_57 + 96;

pdf_parser.c:1030:1: internal compiler error: verify_stmts failed
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 -O2 required.
Comment 1 David Binderman 2010-01-14 19:55:55 UTC
Created attachment 19601 [details]
C source code
Comment 2 H.J. Lu 2010-01-15 03:36:04 UTC
(In reply to comment #1)
> Created an attachment (id=19601) [edit]
> C source code
> 

It works for me with 4.5.0 20100114 (experimental) [trunk revision 155925]
on Linux/x86-64. 
Comment 3 David Binderman 2010-01-15 10:26:05 UTC
(In reply to comment #2)
> It works for me with 4.5.0 20100114 (experimental) [trunk revision 155925]
> on Linux/x86-64. 

I upgraded to the latest snapshot (20010114), trunk
revision 155915 and it still seems broken to me.

Either one of the ten revisions fixed it, or somethings
gone wrong for me locally.

I'll try a raw build of 20010114 and report back.

Comment 4 Richard Biener 2010-01-15 10:30:57 UTC
Confirmed.  Reducing.
Comment 5 Richard Biener 2010-01-15 10:42:14 UTC
struct pdf_object { int val; };
int pdf_count_size_object (struct pdf_object * p_obj)
{
  return pdf_count_size_object(p_obj) + 2 * sizeof(struct pdf_object);
}
Comment 6 H.J. Lu 2010-01-15 16:03:11 UTC
It is caused by revision 146831:

http://gcc.gnu.org/ml/gcc-cvs/2009-04/msg01473.html
Comment 7 Andrew Pinski 2010-01-16 06:21:18 UTC
(In reply to comment #6)
> It is caused by revision 146831:

Exposed by, not really caused in this case.  The bug was there before the extra checking was added.  I am looking into fixing tailr.  Note we do go from an overflowing being wrapping to be undefined too.  So there is more than just fixing types too.
Comment 8 Andrew Pinski 2010-01-16 06:43:35 UTC
This is harder than I thought.  CCing the original author of this part of the code.  
Comment 9 Richard Biener 2010-01-16 10:35:06 UTC
Indeed it's harder that I thought originally as well ;)  I wonder why we
re-create a simple form of the return value adjustment instead of just copying
the existing statements.
Comment 10 Zdenek Dvorak 2010-01-16 12:53:28 UTC
 /* Reject a tailcall if the type conversion might need
285 	  	          additional code.  */
286 	  	       if (gimple_assign_cast_p (stmt)
287 	  	           && TYPE_MODE (TREE_TYPE (dest)) != TYPE_MODE (TREE_TYPE (src_var)))
288 	  	         return false;

This is suspicious; replacing the weird TYPE_MODE check with useless_type_conversion_p fixes the problem.
Comment 11 rguenther@suse.de 2010-01-16 13:19:25 UTC
Subject: Re:  [4.5 Regression] -O2 and verify_stmts
 failed again

On Sat, 16 Jan 2010, rakdver at gcc dot gnu dot org wrote:

> 
> 
> ------- Comment #10 from rakdver at gcc dot gnu dot org  2010-01-16 12:53 -------
>  /* Reject a tailcall if the type conversion might need
> 285                       additional code.  */
> 286                    if (gimple_assign_cast_p (stmt)
> 287                        && TYPE_MODE (TREE_TYPE (dest)) != TYPE_MODE
> (TREE_TYPE (src_var)))
> 288                      return false;
> 
> This is suspicious; replacing the weird TYPE_MODE check with
> useless_type_conversion_p fixes the problem.

Correct, but for useless_type_conversion_p we can reject any conversions
in the IL since only !useless_type_conversion_p remain.

I suppose the code was explicitly trying to allow sign-changing
(but not precision changing as it does), or conversion to/from
pointers.

Thus, if you want to go the useless_type_conversion_p route simply
reject all conversions and only allow plain SSA name copies...

Richard.
Comment 12 rakdver@kam.mff.cuni.cz 2010-01-16 13:24:15 UTC
Subject: Re:  [4.5 Regression] -O2 and verify_stmts
	failed again

> > ------- Comment #10 from rakdver at gcc dot gnu dot org  2010-01-16 12:53 -------
> >  /* Reject a tailcall if the type conversion might need
> > 285                       additional code.  */
> > 286                    if (gimple_assign_cast_p (stmt)
> > 287                        && TYPE_MODE (TREE_TYPE (dest)) != TYPE_MODE
> > (TREE_TYPE (src_var)))
> > 288                      return false;
> > 
> > This is suspicious; replacing the weird TYPE_MODE check with
> > useless_type_conversion_p fixes the problem.
> 
> Correct, but for useless_type_conversion_p we can reject any conversions
> in the IL since only !useless_type_conversion_p remain.

right

> I suppose the code was explicitly trying to allow sign-changing
> (but not precision changing as it does), or conversion to/from
> pointers.
> 
> Thus, if you want to go the useless_type_conversion_p route simply
> reject all conversions and only allow plain SSA name copies...

this might be overly restrictive; it should be quite easy to add the
appropriate casts, instead.
Comment 13 bero 2010-01-21 11:56:41 UTC
FWIW a very similar error occurs when building mysql 5.5.1-m2, almost certainly the same bug

opt_range.cc: In member function 'int SEL_ARG::store_min_key(KEY_PART*, uchar**, uint*, uint)':
opt_range.cc:11812:42: error: type mismatch in binary expression
int

int

uint

add_acc.811_37 = add_acc.811_49 + res_15;

opt_range.cc:11812:42: internal compiler error: verify_stmts failed
Comment 14 Richard Biener 2010-02-22 12:02:16 UTC
I have a patch.
Comment 15 Richard Biener 2010-02-22 14:09:49 UTC
Subject: Bug 42749

Author: rguenth
Date: Mon Feb 22 14:09:26 2010
New Revision: 156960

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=156960
Log:
2010-02-22  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/42749
	* tree-tailcall.c (adjust_return_value_with_ops): Drop update
	parameter.  Do arithmetic in the original type.
	(update_accumulator_with_ops): Likewise.
	(adjust_accumulator_values): Adjust.

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

Added:
    trunk/gcc/testsuite/gcc.c-torture/compile/pr42749.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-tailcall.c

Comment 16 Richard Biener 2010-02-22 15:44:59 UTC
Fixed.
Comment 17 Richard Biener 2010-02-22 15:46:08 UTC
*** Bug 42923 has been marked as a duplicate of this bug. ***
Comment 18 hjl@gcc.gnu.org 2010-02-23 17:04:26 UTC
Subject: Bug 42749

Author: hjl
Date: Tue Feb 23 17:02:26 2010
New Revision: 157010

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=157010
Log:
Backport testcases from mainline.

2010-02-23  H.J. Lu  <hongjiu.lu@intel.com>

	Backport from mainline:
	2010-02-22  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/42749
	* gcc.c-torture/compile/pr42749.c: New testcase.

	2010-02-21  Dodji Seketeli  <dodji@redhat.com>

	PR c++/42824
	* g++.dg/template/memclass4.C: New test.

	2010-02-20  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/43111
	* gfortran.dg/internal_pack_8.f90: New test.

	2010-02-18  Jason Merrill  <jason@redhat.com>

	PR c++/43109
	* g++.dg/parse/namespace12.C: New.

	2010-02-18  Martin Jambor  <mjambor@suse.cz>

	PR tree-optimization/43066
	* gcc.c-torture/compile/pr43066.c: New test.

	2010-02-17  Jason Merrill  <jason@redhat.com>

	PR c++/43069
	* g++.dg/parse/namespace11.C: New.

	PR c++/43093
	* g++.dg/ext/attrib37.C: New.

	PR c++/43079
	* g++.dg/template/ptrmem20.C: New.

	2010-02-16  Jason Merrill  <jason@redhat.com>

	PR c++/43031
	* g++.dg/ext/attrib36.C: New.

	2010-02-15  Richard Guenther  <rguenther@suse.de>

	PR middle-end/43068
	* g++.dg/torture/pr43068.C: New testcase.

	2010-02-11  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/42998
	* gcc.c-torture/compile/pr42998.c: New testcase.

	2010-02-10  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/43017
	* gcc.dg/torture/pr43017.c: New testcase.

	2010-02-10  Richard Guenther  <rguenther@suse.de>

	PR c/43007
	* gcc.c-torture/execute/20100209-1.c: New testcase.
	* gcc.dg/fold-div-3.c: Likewise.

	2010-02-09  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/42999
	* gfortran.dg/array_constructor_35.f90: New test.

	2010-02-09  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/43008
	* gcc.c-torture/execute/pr43008.c: New testcase.

	2010-02-09  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/43000
	* gcc.dg/torture/pr43000.c: New testcase.
	* gcc.dg/torture/pr43002.c: Likewise.

	2010-02-06  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/42742
	* gfortran.dg/fmt_cache_2.f: New test.

	2010-02-03  Jason Merrill  <jason@redhat.com>

	PR c++/42870
	* g++.dg/ext/dllexport3.C: New.

Added:
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/ext/attrib36.C
      - copied unchanged from r157009, trunk/gcc/testsuite/g++.dg/ext/attrib36.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/ext/attrib37.C
      - copied unchanged from r157009, trunk/gcc/testsuite/g++.dg/ext/attrib37.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/ext/dllexport3.C
      - copied unchanged from r157009, trunk/gcc/testsuite/g++.dg/ext/dllexport3.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/parse/namespace11.C
      - copied unchanged from r157009, trunk/gcc/testsuite/g++.dg/parse/namespace11.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/parse/namespace12.C
      - copied unchanged from r157009, trunk/gcc/testsuite/g++.dg/parse/namespace12.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/template/memclass4.C
      - copied unchanged from r157009, trunk/gcc/testsuite/g++.dg/template/memclass4.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/template/ptrmem20.C
      - copied unchanged from r157009, trunk/gcc/testsuite/g++.dg/template/ptrmem20.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/torture/pr43068.C
      - copied unchanged from r157009, trunk/gcc/testsuite/g++.dg/torture/pr43068.C
    branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/compile/pr42749.c
      - copied unchanged from r157009, trunk/gcc/testsuite/gcc.c-torture/compile/pr42749.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/compile/pr42998.c
      - copied unchanged from r157009, trunk/gcc/testsuite/gcc.c-torture/compile/pr42998.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/compile/pr43066.c
      - copied unchanged from r157009, trunk/gcc/testsuite/gcc.c-torture/compile/pr43066.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/execute/20100209-1.c
      - copied unchanged from r157009, trunk/gcc/testsuite/gcc.c-torture/execute/20100209-1.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/execute/pr43008.c
      - copied unchanged from r157009, trunk/gcc/testsuite/gcc.c-torture/execute/pr43008.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/fold-div-3.c
      - copied unchanged from r157009, trunk/gcc/testsuite/gcc.dg/fold-div-3.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/torture/pr43000.c
      - copied unchanged from r157009, trunk/gcc/testsuite/gcc.dg/torture/pr43000.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/torture/pr43002.c
      - copied unchanged from r157009, trunk/gcc/testsuite/gcc.dg/torture/pr43002.c
    branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/array_constructor_35.f90
      - copied unchanged from r157009, trunk/gcc/testsuite/gfortran.dg/array_constructor_35.f90
    branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/fmt_cache_2.f
      - copied unchanged from r157009, trunk/gcc/testsuite/gfortran.dg/fmt_cache_2.f
    branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/internal_pack_8.f90
      - copied unchanged from r157009, trunk/gcc/testsuite/gfortran.dg/internal_pack_8.f90
Modified:
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog