From patchwork Fri Jan 8 20:13:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 565060 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id BAE7F140BAB for ; Sat, 9 Jan 2016 07:13:32 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=B+vBu2qG; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=i68FaOIiZaBEsNPhx7LW3eMBH0Q06 GRZJQz3E7F3OzkXSW+nJ0/7230a8sJTSoc9S44x8z+A6WPh2upeGSARBR/xkRjoV 87Ap2h5iVYdJOpbbrPWDUzQTLEreXrbUNFWo76zP8iSmdV4pDTOSnduuegXamYTk 6Q3Q3FtO85RBDg= 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:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; s=default; bh=ZXCaNae7SlWztoKmHx6giIkryR0=; b=B+v Bu2qGFmGX2ug1aMF+h7BYWHm3j8CzsaHlqu9RP1XxGww1Y5Fm5wbwdUsX6opm/bw D+e4de4sXm99Q09BbPpaDLXgSE5YYS69aL1fatndMPWJPosssU9txTGhQd6PNWl4 YiPeGkps8htZAmmdHC4M/M+zBF31q7gv+rEqh46A= Received: (qmail 104082 invoked by alias); 8 Jan 2016 20:13:25 -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 104054 invoked by uid 89); 8 Jan 2016 20:13:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=PLUS, cst, x_mode, 50000000000 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 08 Jan 2016 20:13:23 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 20A4891FCC for ; Fri, 8 Jan 2016 20:13:22 +0000 (UTC) Received: from tucnak.zalov.cz ([10.3.113.3]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u08KDKPh018759 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 8 Jan 2016 15:13:21 -0500 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id u08KDIj4010889; Fri, 8 Jan 2016 21:13:19 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id u08KDHVQ010888; Fri, 8 Jan 2016 21:13:17 +0100 Date: Fri, 8 Jan 2016 21:13:17 +0100 From: Jakub Jelinek To: Vladimir Makarov Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix ICE due to invalid CONST_INT in DEBUG_INSN (PR target/69071) Message-ID: <20160108201317.GE18720@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes Hi! The following testcase ICEs, because move_plus_up attempts to optimize (subreg:HI (plus:SI (...) (const_int 0xff78)) 0) into (plus:HI (subreg:HI (...) 0) (const_int 0xff78)) which is incorrect, HImode CONST_INT with MSB set should be (const_int -136) instead. The patch also punts if the second operand of PLUS is some CONSTANT_P that can't be simplified into a CONSTANT_P in the narrower mode. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2016-01-08 Jakub Jelinek PR target/69071 * lra-eliminations.c (move_plus_up): Only move plus up if subreg of the constant can be simplified into constant and use the simplified subreg of the constant instead of the original constant. * gcc.dg/pr69071.c: New test. Jakub --- gcc/lra-eliminations.c.jj 2016-01-04 14:55:50.000000000 +0100 +++ gcc/lra-eliminations.c 2016-01-08 10:28:39.954706210 +0100 @@ -296,9 +296,14 @@ move_plus_up (rtx x) if (GET_CODE (x) == SUBREG && GET_CODE (subreg_reg) == PLUS && GET_MODE_SIZE (x_mode) <= GET_MODE_SIZE (subreg_reg_mode) && CONSTANT_P (XEXP (subreg_reg, 1))) - return gen_rtx_PLUS (x_mode, lowpart_subreg (x_mode, subreg_reg, - subreg_reg_mode), - XEXP (subreg_reg, 1)); + { + rtx cst = simplify_subreg (x_mode, XEXP (subreg_reg, 1), subreg_reg_mode, + subreg_lowpart_offset (x_mode, + subreg_reg_mode)); + if (cst && CONSTANT_P (cst)) + return gen_rtx_PLUS (x_mode, lowpart_subreg (x_mode, subreg_reg, + subreg_reg_mode), cst); + } return x; } --- gcc/testsuite/gcc.dg/pr69071.c.jj 2016-01-08 10:24:50.029922989 +0100 +++ gcc/testsuite/gcc.dg/pr69071.c 2016-01-08 10:24:34.000000000 +0100 @@ -0,0 +1,22 @@ +/* PR target/69071 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g" } */ + +void *bar (void *); + +void +foo (int c) +{ + unsigned char bf[65400]; + unsigned char *p2 = bar (bf); + unsigned char *p3 = bar (bf); + for (; *p2; p2++, c++) + { + if (c) + { + short of = p2 - bf - 6; + unsigned ofu = of; + __builtin_memcpy (p3, &ofu, sizeof (ofu)); + } + } +}