From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3469 invoked by alias); 3 Dec 2001 20:49:37 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 3404 invoked from network); 3 Dec 2001 20:49:34 -0000 Received: from unknown (HELO taltos.codesourcery.com) (66.92.14.122) by sources.redhat.com with SMTP; 3 Dec 2001 20:49:34 -0000 Received: from zack by taltos.codesourcery.com with local (Exim 3.33 #1 (Debian)) id 16B01u-0008FS-00 for ; Mon, 03 Dec 2001 12:49:34 -0800 Date: Mon, 03 Dec 2001 12:49:00 -0000 To: gcc@gcc.gnu.org Subject: messy combine problem - PPC Message-ID: <20011203204934.GG292@codesourcery.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.24i From: Zack Weinberg X-SW-Source: 2001-12/txt/msg00078.txt.bz2 I'm looking at a nasty combine problem exposed by my PPC ABI patches. Suppose you have code like this: struct a { char hours, day, month; short year; }; extern struct a A; extern struct a ret_struct_a(); void test(void) { A = ret_struct_a(); } Right before combine, we have this RTL: (call_insn 8 48 9 (parallel[ (set (reg:DI 3 r3) (call (mem:SI (symbol_ref:SI ("ret_struct_a")) [0 S4 A32]) (const_int 0 [0x0]))) (use (const_int 0 [0x0])) (clobber (scratch:SI)) ] ) -1 (nil) (expr_list:REG_UNUSED (scratch:SI) (nil)) (nil)) (insn 9 8 11 (set (reg:SI 115) (zero_extend:SI (subreg:HI (reg:SI 3 r3) 2))) 30 {*rs6000.md:1385} (insn_list 8 (nil)) (expr_list:REG_DEAD (reg:SI 3 r3) (nil))) As far as I know this is correct RTL. Combine tries to do something (I'm not entirely sure what) with insn 9. At -O1, in the course of that it calls get_last_value for (subreg:HI (reg:SI 3 r3) 2) and get_last_value obligingly tries to return the call pattern wrapped in a SUBREG. This blows up in simplify_gen_subreg, since the call RTX has no mode. Breakpoint 1, fancy_abort ( file=0x8439ba0 "../../../gcc/ppc-eabi/gcc/simplify-rtx.c", line=2649, function=0x843a11b "simplify_gen_subreg") at ../../../gcc/ppc-eabi/gcc/diagnostic.c:1450 1450 internal_error ("Internal compiler error in %s, at %s:%d", (gdb) bt #0 fancy_abort (file=0x8439ba0 "../../../gcc/ppc-eabi/gcc/simplify-rtx.c", line=2649, function=0x843a11b "simplify_gen_subreg") at ../../../gcc/ppc-eabi/gcc/diagnostic.c:1450 #1 0x082b61a9 in simplify_gen_subreg (outermode=HImode, op=0x40174df8, innermode=VOIDmode, byte=0) at ../../../gcc/ppc-eabi/gcc/simplify-rtx.c:2649 #2 0x0834d2aa in gen_lowpart_for_combine (mode=HImode, x=0x40174df8) at ../../../gcc/ppc-eabi/gcc/combine.c:9748 #3 0x08351cc8 in get_last_value (x=0x4016ea20) at ../../../gcc/ppc-eabi/gcc/combine.c:11366 At -O2, -fexpensive-optimizations is on, and (zero_extend:SI (subreg:HI (reg:SI 3 r3) 2)) is replaced by (and:SI (reg:SI 3 r3) (const_int 65535 [0xffff])) before anything else happens; this goes through a different code path, combine asks for the last value of (reg:SI 3 r3), and simplify_gen_subreg is not asked to do anything with the CALL pattern. The $64,000 question: what's the right fix here? The incoming RTL is correct, so a fix in the machine description is inappropriate. simplify_gen_subreg is correct to abort, (subreg:HI (call ...) N) is ill-formed. I'm not familiar enough with combine to know where in between these two the fix should go. Ideas? zw