From patchwork Fri Oct 16 19:12:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1383517 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=kkx5ywK5; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CCbQS2ZyGz9sSf for ; Sat, 17 Oct 2020 06:13:03 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6209A396E814; Fri, 16 Oct 2020 19:12:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6209A396E814 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1602875579; bh=6NH7qWnqqg+0wkrvrD5F6aslw/3zhQ4yuKRiHXxZ+4o=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=kkx5ywK5dPwv8EhZqCMU/G784lr3iu0ivNGEGlwyA5vK6SBXWvlpv3A+P9pRCRqlS RvCGqL1cRq6MT33KboB2sjeLGD8ehOgu4/7HlBEAWdqaRtMqQaDsNiCC5sumnwBYYs /IVp+Y+OCSWTgpOZfP9HvKaj5wnXxLsWfbah2vUM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id 458E4384640D for ; Fri, 16 Oct 2020 19:12:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 458E4384640D Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-370-0ZvxWFEnPfGmU9gACIhkCA-1; Fri, 16 Oct 2020 15:12:54 -0400 X-MC-Unique: 0ZvxWFEnPfGmU9gACIhkCA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AC481186DD28 for ; Fri, 16 Oct 2020 19:12:53 +0000 (UTC) Received: from [10.10.118.239] (ovpn-118-239.rdu2.redhat.com [10.10.118.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5756A5B4A4 for ; Fri, 16 Oct 2020 19:12:53 +0000 (UTC) To: gcc-patches Subject: [PATCH] pointer_plus [0, 0] + const folding Message-ID: <9f6a5a21-ed26-b7bd-471d-7c98c5206cc4@redhat.com> Date: Fri, 16 Oct 2020 15:12:52 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrew MacLeod via Gcc-patches From: Andrew MacLeod Reply-To: Andrew MacLeod Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" In order to match evrp behaviour, adjust POINTER_PLUS_EXPR processing to handle a zero constant plus something to return the something. ie [0, 0]  + CONST    will now return [CONST, CONST] instead of the previous behaviour of [1, +INF]. Bootstrapped on x86_64-pc-linux-gnu, no regressions, pushed. Andrew 2020-10-16 Andrew MacLeod * range-op.cc (pointer_plus_operator::wi_fold): Make pointer_plus [0, 0] + const return a [const, const] range. diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 6108de367ad..9df08a61289 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -3063,6 +3063,14 @@ pointer_plus_operator::wi_fold (irange &r, tree type, const wide_int &rh_lb, const wide_int &rh_ub) const { + // Check for [0,0] + const, and simply return the const. + if (lh_lb == 0 && lh_ub == 0 && rh_lb == rh_ub) + { + tree val = wide_int_to_tree (type, rh_lb); + r.set (val, val); + return; + } + // For pointer types, we are really only interested in asserting // whether the expression evaluates to non-NULL. //