From patchwork Wed Jun 1 22:38:04 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaz Kojima X-Patchwork-Id: 98286 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 369FDB6F84 for ; Thu, 2 Jun 2011 08:38:36 +1000 (EST) Received: (qmail 9616 invoked by alias); 1 Jun 2011 22:38:35 -0000 Received: (qmail 9607 invoked by uid 22791); 1 Jun 2011 22:38:34 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mo10.iij4u.or.jp (HELO mo.iij4u.or.jp) (210.138.174.78) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 01 Jun 2011 22:38:20 +0000 Received: by mo.iij4u.or.jp (mo10) id p51McIGS007474; Thu, 2 Jun 2011 07:38:18 +0900 Received: from localhost (238.152.138.210.bn.2iij.net [210.138.152.238]) by mbox.iij4u.or.jp (mbox10) id p51Mc5WV021669; Thu, 2 Jun 2011 07:38:18 +0900 Date: Thu, 02 Jun 2011 07:38:04 +0900 (JST) Message-Id: <20110602.073804.221358034.kkojima@rr.iij4u.or.jp> To: gcc-patches@gcc.gnu.org Subject: [patch committed] Fix PR target/49238 From: Kaz Kojima Mime-Version: 1.0 X-IsSubscribed: yes 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 Hi, The attached patch is to fix PR 49238 which is an ice-on-valid-code with an unrecognizable insn like: (insn 61 60 62 3 (set (reg:SI 147 t) (geu:SI (reg:SI 3 r3) (const_int -1 [0xffffffffffffffff]))) (nil)) SH has GEU comparison only with register operands and we used a scratch register in that case after reload. expand_cbranchdi4 forgot it in the problematic situation. The patch is tested on sh4-unknown-linux-gnu with no new failures. The testsuite hunk is tested also on i686-pc-linux-gnu. Applied on trunk. Since this PR is a 4.5/4.6 regression, I'll backport it on those branches later. Regards, kaz --- 2011-06-01 Kaz Kojima PR target/49238 * config/sh/sh.c (expand_cbranchdi4): Use a scratch register if needed when original operands are used for msw_skip comparison. [testsuite] * gcc.c-torture/compile/pr49238.c: New. diff -uprN ORIG/trunk/gcc/config/sh/sh.c trunk/gcc/config/sh/sh.c --- ORIG/trunk/gcc/config/sh/sh.c 2011-05-31 12:06:18.000000000 +0900 +++ trunk/gcc/config/sh/sh.c 2011-05-31 23:14:33.000000000 +0900 @@ -2199,6 +2199,13 @@ expand_cbranchdi4 (rtx *operands, enum r { operands[1] = op1h; operands[2] = op2h; + if (reload_completed + && ! arith_reg_or_0_operand (op2h, SImode) + && (true_regnum (op1h) || (comparison != EQ && comparison != NE))) + { + emit_move_insn (scratch, operands[2]); + operands[2] = scratch; + } } operands[3] = skip_label = gen_label_rtx (); diff -uprN ORIG/trunk/gcc/testsuite/gcc.c-torture/compile/pr49238.c trunk/gcc/testsuite/gcc.c-torture/compile/pr49238.c --- ORIG/trunk/gcc/testsuite/gcc.c-torture/compile/pr49238.c 1970-01-01 09:00:00.000000000 +0900 +++ trunk/gcc/testsuite/gcc.c-torture/compile/pr49238.c 2011-06-01 08:19:03.000000000 +0900 @@ -0,0 +1,18 @@ +/* PR target/49238 */ +extern int bar (void); + +void +foo (unsigned long long a, int b) +{ + int i; + + if (b) + for (a = -12; a >= 10; a = bar ()) + break; + else + return; + + for (i = 0; i < 10; i += 10) + if ((i == bar ()) | (bar () >= a)) + bar (); +}