From patchwork Tue Sep 10 17:12:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Greenhalgh X-Patchwork-Id: 273940 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id DDFC12C00D3 for ; Wed, 11 Sep 2013 03:12:56 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; q=dns; s=default; b=PS73mVpbVRL5KJSk O0KrCmKuneZWgTOQdoz0mPqttIwfcDGisc5g7d0HfYfvmHeXHzbKNN6FNSmziZw1 QC5bBgMbSxLRh2prwBEqlF3QbwJhYZrpQXh/uzGNqQn4gGV8xbsILlKIW0UKM0cc od/G6sPGLeeLqhqUVj/LwmuoCqI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=default; bh=s8oMVw19FFcqD3eGdesw3q KYFe4=; b=WViinrpzoc0O+Ss/UZtzmZjmfe78NJsLJxPoC8B89/5ZlwelSN6gKZ /wftFNednMIVhMZZUZrRr1B4D0/41v6dFx0wEVMYt9ifu25H4p/QF/ur2juLLFOv g8E8p0hbcWDyohN+yh8rmtRtL9Mw6mw7hk/jWUeD3FJc96C3N5CgQ= Received: (qmail 2232 invoked by alias); 10 Sep 2013 17:12:49 -0000 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 Received: (qmail 2219 invoked by uid 89); 10 Sep 2013 17:12:48 -0000 Received: from service87.mimecast.com (HELO service87.mimecast.com) (91.220.42.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 10 Sep 2013 17:12:48 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.8 required=5.0 tests=AWL, BAYES_00, KHOP_THREADED, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_NO, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: service87.mimecast.com Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Tue, 10 Sep 2013 18:12:45 +0100 Received: from e106375-lin.cambridge.arm.com ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.0); Tue, 10 Sep 2013 18:12:44 +0100 From: James Greenhalgh To: gcc-patches@gcc.gnu.org Cc: rdsandiford@googlemail.com, richard.guenther@gmail.com Subject: Re: [1/4] Using gen_int_mode instead of GEN_INT Date: Tue, 10 Sep 2013 18:12:37 +0100 Message-Id: <1378833157-11511-1-git-send-email-james.greenhalgh@arm.com> In-Reply-To: References: MIME-Version: 1.0 X-MC-Unique: 113091018124501501 X-IsSubscribed: yes Hi, This seems to have caused PR58373. The bug occurs where GEN_INT would previously have then been used to build a constant of vector mode. These pop in a few places when building for AArch64, though I did the debugging using gcc.target/aarch64/vect-fcm-eq-d.c Here we could get in to the situation where simplify_unary_expression_1 would see (V2DI: NOT (NEG X)) and try to generate (V2DI: PLUS (X - 1)). In turn, we would reach the call in plus_constant to gen_int_mode (-1, v2di), followed by trunc_int_for_mode (-1, v2di) and this assert would trigger: /* You want to truncate to a _what_? */ gcc_assert (SCALAR_INT_MODE_P (mode)); In this fix I catch the case where gen_int_mode has been asked to build a vector mode, and call trunc_int_for_mode on the inner mode of that vector. A similar fix could sit in trunc_int_for_mode if you would prefer. Bootstrapped on x86_64-unknown-linux-gnu with no issues and regression tested for aarch64-none-elf with the expected benefits and no regressions. Thanks, James --- gcc/ 2013-09-10 James Greenhalgh PR rtl-optimization/58383 * emit-rtl.c (gen_int_mode): Handle vector modes. diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index 8a7b8a5..cf26bf1 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -417,7 +417,13 @@ gen_rtx_CONST_INT (enum machine_mode mode ATTRIBUTE_UNUSED, HOST_WIDE_INT arg) rtx gen_int_mode (HOST_WIDE_INT c, enum machine_mode mode) { - return GEN_INT (trunc_int_for_mode (c, mode)); + HOST_WIDE_INT c1; + if (SCALAR_INT_MODE_P (mode)) + c1 = trunc_int_for_mode (c, mode); + else + c1 = trunc_int_for_mode (c, GET_MODE_INNER (mode)); + + return GEN_INT (c1); } /* CONST_DOUBLEs might be created from pairs of integers, or from