From patchwork Mon Sep 20 10:36:52 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 65197 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 D3428B6EEC for ; Mon, 20 Sep 2010 20:36:03 +1000 (EST) Received: (qmail 26753 invoked by alias); 20 Sep 2010 10:36:00 -0000 Received: (qmail 26639 invoked by uid 22791); 20 Sep 2010 10:35:59 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 20 Sep 2010 10:35:53 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o8KAZq70018804 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 20 Sep 2010 06:35:52 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o8KAZpwd017879 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 20 Sep 2010 06:35:52 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id o8KAavTM005794 for ; Mon, 20 Sep 2010 12:36:57 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id o8KAaq7w005792 for gcc-patches@gcc.gnu.org; Mon, 20 Sep 2010 12:36:52 +0200 Date: Mon, 20 Sep 2010 12:36:52 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix ICE on VCE expansion (PR rtl-optimization/45728) Message-ID: <20100920103652.GK1269@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) 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! On this testcase, the operand of VCE is expanded as symbol_ref:DI, and mode is DFmode. Neither of them is BLKmode and they are even the same size, so expand_expr_real_1 uses gen_lowpart on them. Unfortunately, gen_lowpart_general doesn't handle all possible cases, in particular it calls gen_lowpart_common to attempt to handle a bunch of common cases, and if that fails, assumes that the operand is REG/MEM/SUBREG, but nothing else. The following patch fixes it by forcing it to REG if gen_lowpart wouldn't be able to handle it. As gen_lowpart_common can handle a bunch of cases even when op0 isn't REG/SUBREG/MEM (e.g. ZERO_EXTEND/SIGN_EXTEND/CONCAT and various constants, but not all of cases for them), calling force_reg immediately could pessimize the code. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/4.5/4.4? 2010-09-20 Jakub Jelinek PR rtl-optimization/45728 * expr.c (expand_expr_real_1): If op0 isn't REG or MEM, try gen_lowpart_common first and if that fails, force_reg first before calling gen_lowpart. * gcc.c-torture/compile/pr45728.c: New test. Jakub --- gcc/expr.c.jj 2010-09-17 14:11:11.000000000 +0200 +++ gcc/expr.c 2010-09-20 09:12:38.000000000 +0200 @@ -9381,7 +9381,15 @@ expand_expr_real_1 (tree exp, rtx target { if (GET_CODE (op0) == SUBREG) op0 = force_reg (GET_MODE (op0), op0); - op0 = gen_lowpart (mode, op0); + temp = gen_lowpart_common (mode, op0); + if (temp) + op0 = temp; + else + { + if (!REG_P (op0) && !MEM_P (op0)) + op0 = force_reg (GET_MODE (op0), op0); + op0 = gen_lowpart (mode, op0); + } } /* If both types are integral, convert from one mode to the other. */ else if (INTEGRAL_TYPE_P (type) && INTEGRAL_TYPE_P (TREE_TYPE (treeop0))) --- gcc/testsuite/gcc.c-torture/compile/pr45728.c.jj 2010-09-20 09:20:38.000000000 +0200 +++ gcc/testsuite/gcc.c-torture/compile/pr45728.c 2010-09-20 09:20:09.000000000 +0200 @@ -0,0 +1,17 @@ +/* PR rtl-optimization/45728 */ + +union U +{ + int *m; + double d; +}; + +int i; +union U u; + +int +foo (void) +{ + union U v = { &i }; + return u.d == v.d; +}