Bug 38774 - [4.4 Regression] ice in df_refs_verify, at df-scan.c:4307
Summary: [4.4 Regression] ice in df_refs_verify, at df-scan.c:4307
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.4.0
: P2 normal
Target Milestone: 4.4.0
Assignee: Jakub Jelinek
URL:
Keywords: ice-checking, ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2009-01-09 03:31 UTC by John Regehr
Modified: 2009-01-13 22:38 UTC (History)
3 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2009-01-09 10:33:26


Attachments
patch to cause df to verify after every patch (889 bytes, patch)
2009-01-10 01:57 UTC, Kenneth Zadeck
Details | Diff
gcc44-pr38774.patch (761 bytes, patch)
2009-01-13 20:57 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John Regehr 2009-01-09 03:31:28 UTC
This is seen using r143187 on Ubuntu Hardy on x86.

PR 32431 reports a similar failure but at a different line number, and for the 68HC11 target.

regehr@john-home:~/volatile/tmp117$ current-gcc -c -O2 -march=i686 small.c
small.c: In function ‘foo’:
small.c:17: internal compiler error: in df_refs_verify, at df-scan.c:4307
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

regehr@john-home:~/volatile/tmp117$ cat small.c

int safe_add_func_int64_t_s_s (int _si1, int _si2)
{
  return 1 > 9223372036854775807LL - _si2 && 1 - _si2 ? : 1 + _si2;
}

volatile int g_55;

void func_42 (int p_43, int p_44, int p_46, int p_47)
{
  p_44 & 1 && g_55, !1;
}

void foo (int p_38)
{
  int l_84 = 0;
  func_42 (1, safe_add_func_int64_t_s_s (p_38, 1 >= safe (1)), l_84, 1);
}

regehr@john-home:~/volatile/tmp117$ current-gcc -v

Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../configure --program-prefix=current- --enable-languages=c,c++ --prefix=/home/regehr : (reconfigured) ../configure --program-prefix=current- --enable-languages=c,c++ --prefix=/home/regehr : (reconfigured) ../configure --program-prefix=current- --enable-languages=c,c++ --prefix=/home/regehr : (reconfigured) ../configure --program-prefix=current- --prefix=/home/regehr --enable-languages=c,c++ --no-create --no-recursion : (reconfigured) ../configure --program-prefix=current- --prefix=/home/regehr --enable-languages=c,c++ --no-create --no-recursion : (reconfigured) ../configure --program-prefix=current- --prefix=/home/regehr --enable-languages=c,c++ --no-create --no-recursion : (reconfigured) ../configure --program-prefix=current- --prefix=/home/regehr --enable-languages=c,c++ --no-create --no-recursion : (reconfigured) ../configure --program-prefix=current- --prefix=/home/regehr --enable-languages=c,c++ --no-create --no-recursion
Thread model: posix
gcc version 4.4.0 20090108 (experimental) (GCC)
Comment 1 Richard Biener 2009-01-09 10:33:25 UTC
Confirmed.
Comment 2 Kenneth Zadeck 2009-01-09 12:41:02 UTC
i will have my best people work on it.

Comment 3 Kenneth Zadeck 2009-01-10 01:57:26 UTC
Created attachment 17068 [details]
patch to cause df to verify after every patch

this is a combine bug.  The df verification fails after combine makes some modification to the cc arg of insn 28 in the foo function that bypasses the implicit and explicit calls to mark the insn as being changed. 

I am looking into trying to figure out what path thru combine is doing this.   However, if some combine expert (or just someone who wants to prove that they have better skill with the debugger than I do) wants to get there first, be my guest.   I have attached a patch that improves some of the debugging and causes df to verify after every pass.   This patch causes the failure to move from being in ira, to the start of if conversion after combine.
Comment 4 Jakub Jelinek 2009-01-13 18:07:03 UTC
Simplified testcase:
extern int bar (void);
volatile int g;

int
foo (void)
{
  int a = 1 >= bar ();
  if ((1 > 9223372036854775807LL - a && 1 - a ? : 1 + a) & 1)
    return g;
  return 0;
}
Comment 5 Jakub Jelinek 2009-01-13 20:39:30 UTC
The single CC user is modified, then those changes are reverted, but unfortunately they aren't reverted by putting back the old content, but instead
tweaking the new comparison with PUT_CODE.
          SUBST (*cc_use, gen_rtx_fmt_ee (new_code, GET_MODE (*cc_use),
                                          dest, const0_rtx));   
          other_changed = 1;
...
              if ((recog_for_combine (&pat, other_insn, &note) < 0
                   && ! check_asm_operands (pat)))
                {
                  PUT_CODE (*cc_use, old_code);
                  other_changed = 0;

We should insert put there the old *cc_use rtx.  I'll test a patch.
Comment 6 Jakub Jelinek 2009-01-13 20:57:14 UTC
Created attachment 17094 [details]
gcc44-pr38774.patch

Patch I'm going to bootstrap/regtest.  Fixes the testcase on both i686-linux and x86_64-linux.
Comment 7 Andrew Pinski 2009-01-13 20:59:13 UTC
(In reply to comment #6)
> Created an attachment (id=17094) [edit]
> gcc44-pr38774.patch
> 
> Patch I'm going to bootstrap/regtest.  Fixes the testcase on both i686-linux
> and x86_64-linux.

Do you think the testcase could go into gcc.dg/torture/ instead of just gcc.dg and remove the -O2 part of dg-options ?
Comment 8 Jakub Jelinek 2009-01-13 22:36:18 UTC
Subject: Bug 38774

Author: jakub
Date: Tue Jan 13 22:36:06 2009
New Revision: 143355

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=143355
Log:
	PR rtl-optimization/38774
	* combine.c (simplify_set): When undoing cc_use change, don't do
	PUT_CODE on the newly created comparison, but instead put back the
	old comparison.

	* gcc.dg/torture/pr38774.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/torture/pr38774.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/combine.c
    trunk/gcc/testsuite/ChangeLog

Comment 9 Jakub Jelinek 2009-01-13 22:38:18 UTC
Fixed.