From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27851 invoked by alias); 2 Jun 2011 22:28:34 -0000 Received: (qmail 27842 invoked by uid 22791); 2 Jun 2011 22:28:33 -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 mo11.iij4u.or.jp (HELO mo.iij4u.or.jp) (210.138.174.79) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 02 Jun 2011 22:28:19 +0000 Received: by mo.iij4u.or.jp (mo11) id p52MSHxI032513; Fri, 3 Jun 2011 07:28:17 +0900 Received: from localhost (238.152.138.210.bn.2iij.net [210.138.152.238]) by mbox.iij4u.or.jp (mbox10) id p52MSHKv028332; Fri, 3 Jun 2011 07:28:17 +0900 Date: Thu, 02 Jun 2011 22:28:00 -0000 Message-Id: <20110603.072816.493590850.kkojima@rr.iij4u.or.jp> To: gcc-patches@gcc.gnu.org Subject: [patch committed] Fix PR target/49163 From: Kaz Kojima Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-06/txt/msg00195.txt.bz2 Hi, The attached patch is to fix PR target/49163. The problem occurs with the unrecognizable insn like (insn 66 141 110 4 (set (reg:SI 4 r4) (sign_extend:SI (subreg:QI (mem/s/v/u/c:DI (plus:SI (reg/f:SI 7 r7 [192]) (const_int 12 [0xc])) [3 s2array[1][0].f0+0 S8 A32]) 0))) iii.c:39 164 {*extendqisi2_compact} (expr_list:REG_DEAD (reg/f:SI 7 r7 [192]) (nil))) which is an intermediate insn in reload. SH makes the memory address like (plus (reg) (const_int)) invalid for HI/QImode because SH's mov.b instruction can take only R0 as the other operand for that memory and compiler can't handle such case well. The patch makes constraints for some move insns more rigid about invalid addresses of this type so to avoid generating a problematic move insn. The patch is tested on sh4-unknown-linux-gnu with no new failures. and the new test is tested also on i686-pc-linux-gnu. Applied on trunk. Regards, kaz -- 2011-06-02 Kaz Kojima PR target/49163 * config/sh/predicates.md (general_movsrc_operand): Return 0 for memory and memory subreg of which address is an invalid indexed address for QI and HImode. (general_movdst_operand): Likewise. [testsuite] PR target/49163 * gcc.c-torture/compile/pr49163.c: New. diff -uprN ORIG/trunk/gcc/config/sh/predicates.md trunk/gcc/config/sh/predicates.md --- ORIG/trunk/gcc/config/sh/predicates.md 2010-04-12 09:52:36.000000000 +0900 +++ trunk/gcc/config/sh/predicates.md 2011-06-02 10:17:40.000000000 +0900 @@ -394,6 +394,18 @@ return 0; } + if ((mode == QImode || mode == HImode) + && (MEM_P (op) + || (GET_CODE (op) == SUBREG && MEM_P (SUBREG_REG (op))))) + { + rtx x = XEXP ((MEM_P (op) ? op : SUBREG_REG (op)), 0); + + if (GET_CODE (x) == PLUS + && REG_P (XEXP (x, 0)) + && CONST_INT_P (XEXP (x, 1))) + return sh_legitimate_index_p (mode, XEXP (x, 1)); + } + if (TARGET_SHMEDIA && (GET_CODE (op) == PARALLEL || GET_CODE (op) == CONST_VECTOR) && sh_rep_vec (op, mode)) @@ -419,6 +431,18 @@ && ! (high_life_started || reload_completed)) return 0; + if ((mode == QImode || mode == HImode) + && (MEM_P (op) + || (GET_CODE (op) == SUBREG && MEM_P (SUBREG_REG (op))))) + { + rtx x = XEXP ((MEM_P (op) ? op : SUBREG_REG (op)), 0); + + if (GET_CODE (x) == PLUS + && REG_P (XEXP (x, 0)) + && CONST_INT_P (XEXP (x, 1))) + return sh_legitimate_index_p (mode, XEXP (x, 1)); + } + return general_operand (op, mode); }) diff -uprN ORIG/trunk/gcc/testsuite/gcc.c-torture/compile/pr49163.c trunk/gcc/testsuite/gcc.c-torture/compile/pr49163.c --- ORIG/trunk/gcc/testsuite/gcc.c-torture/compile/pr49163.c 1970-01-01 09:00:00.000000000 +0900 +++ trunk/gcc/testsuite/gcc.c-torture/compile/pr49163.c 2011-06-02 20:58:31.000000000 +0900 @@ -0,0 +1,35 @@ +/* PR target/49163 */ +struct S1 +{ + unsigned f0:18; + int f1; +} __attribute__ ((packed)); + +struct S2 +{ + volatile long long f0; + int f1; +}; + +struct S1 s1; +struct S2 s2; +const struct S2 s2array[2][1] = { }; + +struct S2 **sptr; + +extern int bar (char a, long long b, int * c, long long d, long long e); +extern int baz (void); + +int i; +int *ptr; + +void +foo (int *arg) +{ + for (i = 0; i < 1; i = baz()) + { + *arg = *(int *)sptr; + *ptr = bar (*arg, s2.f1, ptr, + bar (s2array[1][0].f0, *arg, ptr, s1.f1, *ptr), *arg); + } +}