Bug 25180

Summary: [4.1 Regression] ICE during kernel build.
Product: gcc Reporter: Pawel Sikora <pawel_sikora>
Component: targetAssignee: Paolo Bonzini <bonzini>
Status: RESOLVED FIXED    
Severity: normal CC: aj, bonzini, dje, gcc-bugs, pinskia, rguenth
Priority: P3 Keywords: ice-on-valid-code, patch
Version: 4.1.0   
Target Milestone: 4.1.0   
URL: http://gcc.gnu.org/ml/gcc-patches/2005-12/msg00136.html
Host: ppc-linux Target: ppc-linux
Build: ppc-linux Known to work: 4.0.3 4.2.0
Known to fail: 4.1.0 Last reconfirmed: 2005-12-18 15:55:36
Attachments: testcase
reduced testcase
proposed patch

Description Pawel Sikora 2005-11-30 12:55:03 UTC
gcc-4.1.0-20051126 rev 107546

[builder2@forge linux-2.6.14.3]$ gcc attrib.i -c -O2
fs/ntfs/attrib.c: In function 'ntfs_attr_lookup':
fs/ntfs/attrib.c:1025: internal compiler error: Segmentation fault

$ gcc -v
Reading specs from /usr/lib/gcc/ppc-pld-linux/4.1.0/specs
Target: ppc-pld-linux
Configured with: ../configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --infodir=/usr/share/info --mandir=/usr/share/man --x-libraries=/usr/X11R6/lib --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-languages=c,c++,f95,objc,obj-c++,ada,java --enable-c99 --enable-long-long --disable-multilib --enable-nls --disable-werror --with-gnu-as --with-gnu-ld --with-demangler-in-ld --with-system-zlib --with-slibdir=/lib --without-x --enable-cmath --enable-libgcj --enable-libgcj-multifile --enable-libgcj-database --enable-gtk-peer --enable-gtk-cairo --enable-jni --enable-xmlj --enable-alsa --enable-dssi ppc-pld-linux
Thread model: posix
gcc version 4.1.0 20051126 (prerelease)
Comment 1 Pawel Sikora 2005-11-30 13:03:01 UTC
Created attachment 10365 [details]
testcase
Comment 2 Pawel Sikora 2005-11-30 13:10:04 UTC
Program received signal SIGSEGV, Segmentation fault.

(gdb) bt
#0  gen_peephole2_993 (curr_insn=Variable "curr_insn" is not available.)
    at rs6000.md:10847
#1  0x1020341c in peephole2_insns (x0=Variable "x0" is not available.)
    at rs6000.md:10838
#2  0x1026ac90 in peephole2_optimize (dump_file=Variable "dump_file"
    is not available.) at recog.c:3108
#3  0x102d5db4 in execute_one_pass (pass=0x1055f584) at passes.c:828
#4  0x102d5ebc in execute_pass_list (pass=0x1055f584) at passes.c:860
#5  0x102d5ed4 in execute_pass_list (pass=0x1055fda4) at passes.c:861
#6  0x102d5ed4 in execute_pass_list (pass=0x1055fd70) at passes.c:861
#7  0x1006a424 in tree_rest_of_compilation (fndecl=0x3057bb00)
    at tree-optimize.c:419
#8  0x1000b2bc in c_expand_body (fndecl=0x3057bb00) at c-decl.c:6641
#9  0x103199f0 in cgraph_expand_function (node=0x306148c0)
    at cgraphunit.c:1055
#10 0x1031a344 in cgraph_optimize () at cgraphunit.c:1121
#11 0x100115cc in c_write_global_declarations () at c-decl.c:7649
#12 0x102b0958 in toplev_main (argc=Variable "argc" is not available.)
    at toplev.c:1003
#13 0x100581d8 in main (argc=Variable "argc" is not available.)
    at main.c:35
Comment 3 Richard Biener 2005-11-30 13:44:11 UTC
Confirmed.
Comment 4 Richard Biener 2005-11-30 13:49:36 UTC
(reducing)
Comment 5 Richard Biener 2005-11-30 14:10:22 UTC
Created attachment 10367 [details]
reduced testcase

reduced testcase.
Comment 6 Andrew Pinski 2005-11-30 15:29:02 UTC
Caused by:
2005-08-23  Paolo Bonzini  <bonzini@gnu.org>

        * config/rs6000/predicates.md (equality_operator): New.
        * config/rs6000/rs6000.md: Rewrite as a peephole2 the split for
        comparison with a large constant.
Comment 7 Andrew Pinski 2005-11-30 15:31:06 UTC
The peephole2 has logical_operand which means it accepts register so
simplify_const_binary_operation will fail as we have a register here and not just an int.
Comment 8 Paolo Bonzini 2005-11-30 16:11:45 UTC
Reduced testcase:

typedef unsigned long long u64;
extern u64 f (u64 x);
int g (unsigned x, u64 *z)
{
  u64 w = *z;
  u64 h = f (w) << 32;
  u64 l = f (w);
  u64 g = h | l;
  unsigned p = g;
  if (p == x)
    f (*z);
}
Comment 9 Paolo Bonzini 2005-11-30 17:36:03 UTC
Created attachment 10369 [details]
proposed patch

This patch enables the peephole2 only if operands[1] and operands[2] are constant.  

An alternative patch would add a check for CONSTANT_P (operands[1]) && CONSTANT_P (operands[2]) in the peephole's C code.
Comment 10 Richard Biener 2005-12-01 15:54:07 UTC
Assigning to bonzini by request.
Comment 11 Paolo Bonzini 2005-12-05 17:21:41 UTC
Patch applied to mainline.  I will ask for 4.1 approval in a few days, most likely at the beginning of next week.
Comment 12 Steven Bosscher 2005-12-18 15:55:36 UTC
Paolo, are you going to ask for approval for GCC 4.1 too?
Comment 13 Paolo Bonzini 2005-12-19 14:24:15 UTC
David, ok to commit to 4.1 now?
Comment 14 David Edelsohn 2005-12-19 15:32:10 UTC
Subject: Re:  [4.1 Regression] ICE during kernel build. 

Okay.
Comment 15 Paolo Bonzini 2005-12-19 17:46:19 UTC
patch committed to 4.1 branch as well.
Comment 16 Paolo Bonzini 2005-12-19 17:46:19 UTC
Subject: Bug 25180

Author: bonzini
Date: Mon Dec 19 17:46:15 2005
New Revision: 108799

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=108799
Log:
2005-12-19  Paolo Bonzini  <bonzini@gnu.org>

	PR target/25180
        * config/rs6000/predicates.md (logical_const_operand): Split
        out of logical_operand.
        (logical_operand): Use it.
        * config/rs6000/rs6000.md (cmp -> xor peephole2): Use
        logical_const_operand.


Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/config/rs6000/predicates.md
    branches/gcc-4_1-branch/gcc/config/rs6000/rs6000.md