From patchwork Mon Aug 8 11:11:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georg-Johann Lay X-Patchwork-Id: 656654 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 3s7F962Nm1z9sdg for ; Mon, 8 Aug 2016 21:11:38 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=HDwT5bMC; 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 :subject:references:cc:to:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; q=dns; s= default; b=XecGLw+baOypXioIQ8jSlWQzuN99JQ3ET0qJRhDrhwl8+QzIc6DAw tpy9RbL1XMB8D/cFwdjPnSqJAbBTaimH/V4lBOATZFg5aK0hjoY39J/irK0pa5qS VgYgTGeUNBfpi/jemV18bf8yBATgRLQY/WxbJtijph9FZPAN0uQmZg= 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 :subject:references:cc:to:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=default; bh=7qP55hzf473gOfZl1tUjESL7kIU=; b=HDwT5bMCHxGWFMruak65x2M6btzE OzRsJgOuvzVeClPhJfsKbCJZGCgkIKDIT6ALiSRq9mKKw1pdGFnZvahMQFJf5qug DHG5z/GS9wx94f5Pf4qgqo9Wy9mFVjXz9TC8LtxU3VCCsNAhbDaem2lOeEYdSJL5 jmG+mp4rbMJ40uo= Received: (qmail 72953 invoked by alias); 8 Aug 2016 11:11:31 -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 72942 invoked by uid 89); 8 Aug 2016 11:11:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=Hx-languages-length:1703 X-HELO: mo4-p00-ob.smtp.rzone.de Received: from mo4-p00-ob.smtp.rzone.de (HELO mo4-p00-ob.smtp.rzone.de) (81.169.146.161) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 08 Aug 2016 11:11:20 +0000 X-RZG-AUTH: :LXoWVUeid/7A29J/hMvvT3ol15ykJcYwR/bcHRirORRW3yMcVao= X-RZG-CLASS-ID: mo00 Received: from [192.168.0.143] (mail.hightec-rt.com [213.135.1.215]) by smtp.strato.de (RZmta 38.13 DYNA|AUTH) with ESMTPSA id q07798s78BBDS2a (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Mon, 8 Aug 2016 13:11:13 +0200 (CEST) Subject: [backported,v5,v6] Fix PR71976 in combine.c:get_last_value() References: <20160729091917.GE28169@gate.crashing.org> Cc: Segher Boessenkool To: gcc-patches From: Georg-Johann Lay Message-ID: <4767bd39-f99b-cc6b-90f6-117fc4aefcc2@gjlay.de> Date: Mon, 8 Aug 2016 13:11:13 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <20160729091917.GE28169@gate.crashing.org> X-IsSubscribed: yes Applied to v5: https://gcc.gnu.org/r239239 v6: https://gcc.gnu.org/r239238 Johann Backport from 2016-07-29 trunk r238863. PR rtl-optimization/71976 * combine.c (get_last_value): Return 0 if the argument for which the function is called has a wider mode than the recorded value. On 29.07.2016 11:19, Segher Boessenkool wrote: > On Fri, Jul 29, 2016 at 10:56:22AM +0200, Georg-Johann Lay wrote: >> The issue with wrong-code bug PR71976 is that combine.c:get_last_value was >> called for a hard register in a wider mode (DImode) than the stored value >> had (QImode). The patch introduces a test of the mode precision and only >> returns the recorded value if the according mode is not smaller than the >> mode for which get_last_value is called. >> >> Segher already tested the patch on 32 different (sub-)architectures of >> Linux without any regression, cf. >> >> https://gcc.gnu.org/ml/gcc/2016-07/msg00215.html >> >> Ok for trunk and to backport? > > Okay for trunk, okay for backport after a week or so. > > Thanks! > > > Segher Index: combine.c =================================================================== --- combine.c (revision 238849) +++ combine.c (working copy) @@ -13210,6 +13210,12 @@ get_last_value (const_rtx x) && DF_INSN_LUID (rsp->last_set) >= subst_low_luid) return 0; + /* If fewer bits were set than what we are asked for now, we cannot use + the value. */ + if (GET_MODE_PRECISION (rsp->last_set_mode) + < GET_MODE_PRECISION (GET_MODE (x))) + return 0; + /* If the value has all its registers valid, return it. */ if (get_last_value_validate (&value, rsp->last_set, rsp->last_set_label, 0)) return value;