Bug 23714 - [4.1 Regression] ICE in expand_assignment
Summary: [4.1 Regression] ICE in expand_assignment
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.1.0
: P2 minor
Target Milestone: 4.1.0
Assignee: Richard Henderson
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2005-09-03 09:09 UTC by Kazumoto Kojima
Modified: 2005-10-16 02:24 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-10-14 21:40:33


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kazumoto Kojima 2005-09-03 09:09:54 UTC
cc1plus -O2 -fnon-call-exceptions fails with

  internal compiler error: in expand_assignment, at expr.c:3929

for

void run (void) {
  float stack[1];
  float *sp = stack;
  try
  {
    float value2 = ((float) *(--sp));
    float value1 = ((float) *(--sp));
    *(sp++) = (value1 - value2);
  }
  catch (int *ex)
  {
  }
}

which is a testcase for PR 23706 written by Andrew Pinski.
It passes on 3.4 and 4.0.
Comment 1 Andrew Pinski 2005-09-03 12:02:26 UTC
I should mention this really undefined code, I did not mean it to be used for any good example at 
higher optimization than -O0.

Anyways confirmed.  This has been failing since at least 20050822.
Comment 2 Paolo Bonzini 2005-09-12 12:35:58 UTC
reduced testcase, also failing with -O2 -fnon-call-exceptions

void run (void) {
  float stack[1];
  *(stack - 1) = 0.0;
}
Comment 3 Paolo Bonzini 2005-09-12 12:41:55 UTC
The problem is that the array is mapped to a single SFmode register.

One could probably replace the assert with a run-time invocation of abort().
Comment 4 Andrew Pinski 2005-09-16 23:17:14 UTC
(In reply to comment #3)
> One could probably replace the assert with a run-time invocation of abort().
Or really __builtin_trap() which is better.
Comment 5 janis187 2005-09-28 16:27:07 UTC
A regression hunt identified this patch from steven:

  http://gcc.gnu.org/ml/gcc-cvs/2005-06/msg00294.html
Comment 6 GCC Commits 2005-10-06 00:03:01 UTC
Subject: Bug 23714

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	rth@gcc.gnu.org	2005-10-06 00:02:58

Modified files:
	gcc            : ChangeLog tree-cfg.c tree-flow.h 
	                 tree-optimize.c 
Added files:
	gcc/testsuite/g++.dg/opt: pr23714.C 

Log message:
	PR 23714
	* tree-cfg.c (mark_array_ref_addressable_1): New.
	(mark_array_ref_addressable): New.
	* tree-flow.h (mark_array_ref_addressable): Declare.
	* tree-optimize.c (execute_cleanup_cfg_post_optimizing): Use it.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.10095&r2=2.10096
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-cfg.c.diff?cvsroot=gcc&r1=2.221&r2=2.222
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-flow.h.diff?cvsroot=gcc&r1=2.136&r2=2.137
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-optimize.c.diff?cvsroot=gcc&r1=2.123&r2=2.124
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/opt/pr23714.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 7 Richard Henderson 2005-10-06 00:08:20 UTC
Fixed.
Comment 8 Richard Henderson 2005-10-07 21:03:48 UTC
Steven's complaining about the solution...
Comment 9 Richard Henderson 2005-10-07 21:04:20 UTC
... so it's his.  Revert the patch and do what you like.
Comment 10 Andrew Pinski 2005-10-07 21:05:21 UTC
Steven is not the only one who is complaining about it.
Comment 11 Steven Bosscher 2005-10-07 21:11:10 UTC
I think I have every right to complain after what happened to
e.g. the CD-DCE patch, thank you very much.  FY.
Comment 12 Steven Bosscher 2005-10-07 21:12:16 UTC
Oh, and for the record, if you don't care about compile time, fine, but SAY SO and say it in public so people know that even the top gcc hacker doesn't give shit about compile time, and so that I can stop wasting my time trying to find places where the compiler is dog slow.
Comment 13 Steven Bosscher 2005-10-07 21:57:00 UTC
.
Comment 14 Richard Henderson 2005-10-14 21:40:14 UTC
Open to...
Comment 15 Richard Henderson 2005-10-14 21:40:33 UTC
... work on a better solution.
Comment 16 GCC Commits 2005-10-16 00:07:23 UTC
Subject: Bug 23714

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	rth@gcc.gnu.org	2005-10-16 00:07:18

Modified files:
	gcc            : ChangeLog builtins.c expr.c expr.h tree-cfg.c 
	                 tree-flow.h tree-optimize.c 

Log message:
	PR 23714
	* builtins.c (expand_builtin_trap): Export.
	* expr.h (expand_builtin_trap): Declare.
	* expr.c (expand_assignment): Emit a trap for integral offsets
	from registers that weren't reduced to bitpos.
	
	* tree-cfg.c (mark_array_ref_addressable_1): Remove.
	(mark_array_ref_addressable): Remove.
	* tree-flow.h (mark_array_ref_addressable): Remove.
	* tree-optimize.c (execute_cleanup_cfg_post_optimizing): Don't call it.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.10162&r2=2.10163
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/builtins.c.diff?cvsroot=gcc&r1=1.479&r2=1.480
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/expr.c.diff?cvsroot=gcc&r1=1.818&r2=1.819
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/expr.h.diff?cvsroot=gcc&r1=1.192&r2=1.193
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-cfg.c.diff?cvsroot=gcc&r1=2.223&r2=2.224
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-flow.h.diff?cvsroot=gcc&r1=2.138&r2=2.139
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-optimize.c.diff?cvsroot=gcc&r1=2.124&r2=2.125

Comment 17 Richard Henderson 2005-10-16 02:24:26 UTC
Fixed.