From patchwork Mon Jul 18 17:50:49 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 105340 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id C7BDCB6F70 for ; Tue, 19 Jul 2011 03:51:20 +1000 (EST) Received: (qmail 18862 invoked by alias); 18 Jul 2011 17:51:17 -0000 Received: (qmail 18546 invoked by uid 22791); 18 Jul 2011 17:51:16 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, TW_ZJ X-Spam-Check-By: sourceware.org Received: from mail-yw0-f47.google.com (HELO mail-yw0-f47.google.com) (209.85.213.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 18 Jul 2011 17:50:50 +0000 Received: by ywa12 with SMTP id 12so1592727ywa.20 for ; Mon, 18 Jul 2011 10:50:50 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.254.21 with SMTP id b21mr3331224wfi.249.1311011449636; Mon, 18 Jul 2011 10:50:49 -0700 (PDT) Received: by 10.142.89.19 with HTTP; Mon, 18 Jul 2011 10:50:49 -0700 (PDT) Date: Mon, 18 Jul 2011 19:50:49 +0200 Message-ID: Subject: [PATCH, i386]: FixPR47744; [x32] ICE: in reload_cse_simplify_operands, at postreload.c:403 [was: Re: PATCH [5/n] X32: Supprot 32bit address] From: Uros Bizjak To: "H.J. Lu" Cc: gcc-patches@gcc.gnu.org, Richard Henderson , jh@suse.cz, Richard Guenther , Jakub Jelinek Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hello! This alternative patch fixes the problem in ix86_decompose_address, uncovered by x32 branch. Since x32 branch generates lots of SImode subreg of DImode values to handle Pmode vs. ptr_mode restrictions, a latent bug in x86_decompose_address allowed addresses in the (invalid, see SImode subreg of DImode operation) form of: (insn 108 106 186 3 (set (reg:SI 40 r11 [207]) (plus:SI (plus:SI (mult:SI (reg:SI 1 dx [205]) (const_int 8 [0x8])) (subreg:SI (plus:DI (reg/f:DI 7 sp) (const_int 208 [0xd0])) 0)) (const_int -160 [0xffffffffffffff60]))) m.i:3 251 {*lea_1_x32} (nil)) this form later choked reload to ICE with "error: insn does not satisfy its constraints:" in reload_cse_simplify_operands, at postreload.c:403. Invalid RTX in this example was created by reload trying to eliminate frame pointer register to RSP+offset. The solution is to prevent subregs of DImode operations in PLUS address sequences. We can still allow hard registers, since we are sure that combine won't touch them and reload won't try to eliminate them to some reg+offset. Effectively, instead of above RTX, gcc generates more correct sequence that correctly handles SI and DImodes: (insn 185 87 89 3 (set (reg:DI 0 ax) (plus:DI (reg/f:DI 7 sp) (const_int 200 [0xc8]))) pr47744.c:5 248 {*lea_1} (nil)) (insn 89 185 90 3 (set (reg:SI 40 r11 [177]) (plus:SI (plus:SI (mult:SI (reg:SI 40 r11 [175]) (const_int 8 [0x8])) (reg:SI 0 ax)) (const_int -160 [0xffffffffffffff60]))) pr47744.c:5 286 {*lea_general_3} (nil)) So, there is no need for some special lea_* patterns. In addition, this simple patch removes huge amount of "problematic" kludges from current x32 branch. Also, the patch prevents invalid address RTXes for current x86 targets (32 and 64 bit). There is in fact no protection for i.e. SImode subreg of HImode operation to combine into invalid address RTX. On a related note, SImode subreg of a DImode hard register is OK also for 32bit targets, reload will choose the lower SImode register of a DImode pair. Oh, and BTW: patched gcc bootstrapped faster for me on x86_64 SNB for default configure and make -j 8: (unpached) real 28m40.314s user 154m2.612s sys 8m16.934s vs: (patched) real 27m8.057s user 142m42.522s sys 7m41.875s (see PR for details). 2011-07-18 Uros Bizjak PR target/47744 * config/i386/i386.c (ix86_decompose_address): Allow only subregs of DImode hard registers in PLUS address chains. Patch was bootstrapped on x86_64-pc-linux-gnu {,-m32}. H.J. tested it on x32 target, where the patch fixed all reported failures. Patch was committed to mainline SVN. Uros. Index: config/i386/i386.c =================================================================== --- config/i386/i386.c (revision 176386) +++ config/i386/i386.c (working copy) @@ -11149,8 +11149,13 @@ ix86_decompose_address (rtx addr, struct return 0; break; - case REG: case SUBREG: + /* Allow only subregs of DImode hard regs in PLUS chains. */ + if (!register_no_elim_operand (SUBREG_REG (op), DImode)) + return 0; + /* FALLTHRU */ + + case REG: if (!base) base = op; else if (!index)