From patchwork Wed Sep 20 12:12:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 113109 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp691160qgf; Wed, 20 Sep 2017 05:12:49 -0700 (PDT) X-Received: by 10.99.151.73 with SMTP id d9mr1954547pgo.13.1505909569690; Wed, 20 Sep 2017 05:12:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505909569; cv=none; d=google.com; s=arc-20160816; b=oY8Y20XEVcLZ2maB63CpJ+jtLQ9YEkW2n/VBKbbDigeddmJf6RzrIrnJkxdiGNzfJG RXQuBfCsz/mrzwc64YFcu42KmDLpzsqrUJno2nvsVsthDWolBVeJUyXJVRtGI6QxCC+W GWtSY9zT7TjpAkLkIuehbYLWi5s3ZbLf5xLcM17jL+BHSfARihwWsA89RcF2mK9fJhPy 7Z1tw6+Hl1yyJRE2UyzxrcpfnPBBeUp1O2+ytMnnsDIZ15kAyZcUcOwLCCTNH+wMKA2i APBOBgM9puenwQEc3vfeP0g1jaAICc+XP7HQXXfJCxqIshCqMzsx4nTesMMXB+uDSdIx VTAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:date:subject:mail-followup-to:to :from:delivered-to:sender:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=8AqXixXmjdlUNermQpYMsencmfeajT/M7A7CDBBSENk=; b=M+fe0f5bcBsxWwVYuRUcdiYJjfgqbjUyQa7drDA1kmMkFzUasj6fj7NFofUfkdOnF0 rPjlNqlXWKK1i4gR5AQSsqaOYr34zrFy9/GWOIcFEiJNulo6TEesNxY1wNu7weS2V5GK q+oKi6L+h4JWp7JxkQfqlMQJObL3DdmfQKh0B5QDBdYZ7xnI8I6FpOcEBZQ05heHSaay npqurtAX9TcBDxylHQhzjg8tY/QorbI7l9Fxi7FiNLwH+RCro2caIPD6R7uSMosS9NRM K+fRBO4o/snM5pr5FB3/JhAgqnume1yjCbQpiSEVP6vLhpiK8b93RZ153EhWEkbPDeac 04KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=bF5JacDI; spf=pass (google.com: domain of gcc-patches-return-462578-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-462578-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id w76si2852498pfi.609.2017.09.20.05.12.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Sep 2017 05:12:49 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-462578-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 header.s=default header.b=bF5JacDI; spf=pass (google.com: domain of gcc-patches-return-462578-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-462578-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=MKvQawnIKVt/KHFC93e9BbQIQTLIi+tM7Aof1vkt894OkUKIh9XbV wQg3K+5RnzcZB1UkdXF4tHUYlEBtEPLMgTuVloxnzIevHOPQUmNie0YKsh4Ll3QY o4gwVoyhfMg3fbeyozMmHaJ935L1PsenUd+oam7+YnvFHz5SbZvGCU= 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:subject:date:message-id:mime-version:content-type; s= default; bh=U8VGlh//Let1BxpA1SPghIJ7ImQ=; b=bF5JacDI5HQBt3VrisFC XBW8Lba/jkZ5IN0qahmfHZsSQY9mXjix2KS241l9OZd9wYImq3IU4Luum27yR3TM /13Mzgai2equWSx44hGtAdlXPHcDshOoH6TXaRqxmoyhQzBkpvnjcJu+ruoSZsXm y1M0WlMTN6xKFGflLluJ2Ys= Received: (qmail 49437 invoked by alias); 20 Sep 2017 12:12:34 -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 49425 invoked by uid 89); 20 Sep 2017 12:12:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=(unknown) X-HELO: mail-wm0-f42.google.com Received: from mail-wm0-f42.google.com (HELO mail-wm0-f42.google.com) (74.125.82.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 20 Sep 2017 12:12:32 +0000 Received: by mail-wm0-f42.google.com with SMTP id g206so6619789wme.0 for ; Wed, 20 Sep 2017 05:12:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:mail-followup-to:subject:date:message-id :user-agent:mime-version; bh=8AqXixXmjdlUNermQpYMsencmfeajT/M7A7CDBBSENk=; b=TOiKTB2J+gMB5BtHP1FNVUE8oLjBKn9tTQJ7AljdipyWOx8j1ii15yG4HRZwThB4FN Jyqv4pTb5tbzakZm+Y6OMqZDv5ffZICjxSjc4VD8E1w+2hM1D2gzGPyrkhRu19/pzwmA yHKwL0ACHL9yvAy7JxeVza+e6hkCA6uOEcWeOCwuASZXcUtLgrtYOFfK5qKq4Z0LIv2g g7vk2KKd0KrBE4GD5MNMzzo7G0iXXug+XiR3kZ28QFXaLKuDbsaRX4Nux/O2fNF+sutZ D5y+NtE/xLM+lIJnQqlGSKrituKYl95krfyQhJtrjX751TQqPTtfoeIs0q+K36yRNTP1 z4rQ== X-Gm-Message-State: AHPjjUg0SP9knPLPcjpo8XMOBlXkPUAPUMH8+7Ap4B2tl/ZciF74Z/5f plWNl/FnwIO4tNQkIfiD1as56R1H5lY= X-Google-Smtp-Source: AOwi7QB3OoMcmp0QRWlKA58LXZpa1ljaYa2SO5Wbmx8G8gzeW2i+YpNvPHfidKjc9EfleKC26qY03w== X-Received: by 10.28.158.208 with SMTP id h199mr3609411wme.47.1505909550311; Wed, 20 Sep 2017 05:12:30 -0700 (PDT) Received: from localhost (92.40.248.127.threembb.co.uk. [92.40.248.127]) by smtp.gmail.com with ESMTPSA id y84sm1466545wmg.43.2017.09.20.05.12.28 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Sep 2017 05:12:29 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: Tighten tree-ssa-ccp.c:get_value_for_expr condition Date: Wed, 20 Sep 2017 13:12:27 +0100 Message-ID: <87lgl91sd0.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 bit_value_unop and bit_value_binop require constant values to be INTEGER_CSTs: gcc_assert ((rval.lattice_val == CONSTANT && TREE_CODE (rval.value) == INTEGER_CST) || wi::sext (rval.mask, TYPE_PRECISION (TREE_TYPE (rhs))) == -1); However, when deciding whether to record a constant value, the for_bits_p handling in get_value_for_expr used a negative test for ADDR_EXPR: else if (is_gimple_min_invariant (expr) && (!for_bits_p || TREE_CODE (expr) != ADDR_EXPR)) This patch uses a positive test for INTEGER_CST instead. Existing tests showed the need for this once polynomial constants are added. Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64le-linus-gnu. OK to install? Richard 2017-09-20 Richard Sandiford Alan Hayward David Sherwood gcc/ * tree-ssa-ccp.c (get_value_for_expr): Use a positive test for INTEGER_CST rather than a negative test for ADDR_EXPR. Index: gcc/tree-ssa-ccp.c =================================================================== --- gcc/tree-ssa-ccp.c 2017-08-10 14:36:07.842479033 +0100 +++ gcc/tree-ssa-ccp.c 2017-09-20 13:10:31.466004578 +0100 @@ -617,7 +617,7 @@ get_value_for_expr (tree expr, bool for_ } } else if (is_gimple_min_invariant (expr) - && (!for_bits_p || TREE_CODE (expr) != ADDR_EXPR)) + && (!for_bits_p || TREE_CODE (expr) == INTEGER_CST)) { val.lattice_val = CONSTANT; val.value = expr;