From patchwork Wed Dec 7 16:14:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Dapp X-Patchwork-Id: 87131 Delivered-To: patch@linaro.org Received: by 10.182.112.6 with SMTP id im6csp395581obb; Wed, 7 Dec 2016 08:16:24 -0800 (PST) X-Received: by 10.99.66.198 with SMTP id p189mr123251646pga.30.1481127384217; Wed, 07 Dec 2016 08:16:24 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id x70si24717116pfj.101.2016.12.07.08.16.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Dec 2016 08:16:24 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-443706-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-443706-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-443706-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:date:mime-version:in-reply-to :content-type:message-id; q=dns; s=default; b=iMgl+9+9jzzHXVEQz7 R8MITJg+3ncKpumr9VucMbFzKGaTIhm1TVlqB30TZKVMU00MNu+8j+dsawRpRfqe pdGscH44bs2eVstCmDPGu2YdiPvASjcwbYrZk+lpeOSLC49BpLKA+zkPpbhtASrg NaZz4jg/3rIc/MjuZm9WwChS4= 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:to:references:cc:from:date:mime-version:in-reply-to :content-type:message-id; s=default; bh=BH/5thEBgECpfF7a1m8z/UNV TjE=; b=YMrHfopnD30fR0PP0+VUvhAMI2rSxGcgkgFTp7sOHpn8SmqgxMpV/h5i /T08ckt9ixFwGJMxbTdmEbtLhhzRgv5g8Eu7GGr8OzpYtoEORnOpKQ6araSSvICW PBPPze/c2uVjCpgyXrahhlRMLj1164KOhUVuKmVuDxsW/DI5m7o= Received: (qmail 19406 invoked by alias); 7 Dec 2016 16:15:27 -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 15608 invoked by uid 89); 7 Dec 2016 16:15:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW, RCVD_IN_SEMBACKSCATTER autolearn=no version=3.3.2 spammy=anti, Were, We're, bal X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 07 Dec 2016 16:15:00 +0000 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id uB7G8Vqf038158 for ; Wed, 7 Dec 2016 11:14:57 -0500 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0b-001b2d01.pphosted.com with ESMTP id 276mqfm1yw-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 07 Dec 2016 11:14:57 -0500 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 7 Dec 2016 16:14:55 -0000 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 7 Dec 2016 16:14:53 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 6D75A219005F; Wed, 7 Dec 2016 16:14:03 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id uB7GEqBi262596; Wed, 7 Dec 2016 16:14:52 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 48AD84204C; Wed, 7 Dec 2016 15:13:00 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 065BE42042; Wed, 7 Dec 2016 15:13:00 +0000 (GMT) Received: from oc6142347168.ibm.com (unknown [9.152.212.102]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 7 Dec 2016 15:12:59 +0000 (GMT) Subject: Re: [PATCH] Tree-level fix for PR 69526 To: Richard Biener References: <5790A709.4060804@linux.vnet.ibm.com> <6bc1abab-9b54-fb67-fe98-9aaf993859dd@linux.vnet.ibm.com> <27be603c-4499-ca96-f252-40934d3e420d@linux.vnet.ibm.com> Cc: GCC Patches From: Robin Dapp Date: Wed, 7 Dec 2016 17:14:52 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16120716-0008-0000-0000-000003B9702F X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16120716-0009-0000-0000-00001BB2568C Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-12-07_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1612070252 > So we have (uint64_t)(uint32 + -1U) + 1 and using TYPE_SIGN (inner_type) > produces (uint64_t)uint32 + -1U + 1. This simply means that we cannot ignore > overflow of the inner operation and for some reason your change > to extract_range_from_binary_expr didn't catch this. That is _8 + 4294967295 > overflows but we ignored that. In this case the range of _8 was [1,1] so no overflow. I think the problem is rather about the interpretation of the inner constant. I tried discerning two cases now, a range split (i.e. when the single range of a binop variable becomes an anti range or two ranges after combining it with the binop's other range) and an overflow of the range's min and max. If the range didn't split, we can perform the simplification. If there was a min and max overflow, we have to interpret the inner constant as signed and perform a sign extension before converting it to the outer type. Without overflow we can use TYPE_SIGN (inner_type). Does this make sense? Included the remarks and attached the new version. Regards Robin diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c index fbe7e13..110587d 100644 --- a/gcc/tree-ssa-propagate.c +++ b/gcc/tree-ssa-propagate.c @@ -1065,13 +1065,15 @@ substitute_and_fold_dom_walker::before_dom_children (basic_block bb) /* Replace real uses in the statement. */ did_replace |= replace_uses_in (stmt, get_value_fn); + if (did_replace) + gimple_set_modified (stmt, true); /* If we made a replacement, fold the statement. */ - if (did_replace) + if (fold_stmt (&i, follow_single_use_edges)) { - fold_stmt (&i, follow_single_use_edges); stmt = gsi_stmt (i); gimple_set_modified (stmt, true); + did_replace = true; } /* Some statements may be simplified using propagator