From patchwork Wed Nov 3 14:39:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 46995 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ACB193858C39 for ; Wed, 3 Nov 2021 14:42:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ACB193858C39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1635950528; bh=gKg/fsAv2tjzy05ZCSk4gbkCh8OG1qqs/jtyxP/9iyE=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=mRvdbgpDA693ijnz36f3iaAD8rkRdfe+YH4sb51ee0lQehr4URYAQ1HsSL9Eb2KCi 08XAaXvdOiQ/gew3HhGnzWCC5aPNcDe3v1PT9L0pJDmt2xt+o6zaRJWO1EmhsTYLz3 Ku+/57oQ8gpf6RrlBQ/sYZ3h+F33z5O4fR3zRY5I= 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 [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 61EE0385842B for ; Wed, 3 Nov 2021 14:39:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 61EE0385842B Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-191-7exG8b0kOxmyFPYYJdNOjg-1; Wed, 03 Nov 2021 10:39:36 -0400 X-MC-Unique: 7exG8b0kOxmyFPYYJdNOjg-1 Received: by mail-qk1-f199.google.com with SMTP id q5-20020a05620a0d8500b0045edb4779dbso2526346qkl.2 for ; Wed, 03 Nov 2021 07:39:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-language; bh=gKg/fsAv2tjzy05ZCSk4gbkCh8OG1qqs/jtyxP/9iyE=; b=TP32RMIgZcBTQb5gHr+famhENJVeKbyFeDreg3ya+AfgP4jPZ3sNSGHPllXY38MLPi YFBVF1/ne98FwRvcaYHhdCw0sXOJp5KjINV/59lfYdivlmTCEcSjJtDyUMYMSngKEc1N 4NsMpq7HJab0SVX8OuuWCyE51YJKjmMcgnSRwpfWdDIdzhpHRkoa/e7kPcJOJn+SRIXE kmsuNxIMnPXrnqnm7ueB/XYho6t3ZgP0YY5cFNMtChdf+eEl3iLwAKC/9/Rn6D9Degj/ u2OVoJm+j5+qg0LXbWRmPiA3In7zlFF6ZDFZsgY+bOICwpGfMBpkJKnaxjHdK2klM5yy Xa/w== X-Gm-Message-State: AOAM532wDBp7GFvzz9ntNhps7bHgDojzWJjnKHhB/IDkWF0SLnbdF9FP Ku9+jvo1mdN/RbC1XY35nbvVy4yatHVsrzL4xUHB4IKVKUSP+EgFuAl6lMri9EB03U4P8HdF1Uj vS1QrIzC1rQHL3+/6tQ== X-Received: by 2002:a05:6214:411e:: with SMTP id kc30mr19091747qvb.38.1635950375029; Wed, 03 Nov 2021 07:39:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxEMNsD24lMGkTE0AMhz1/AwvseXND+sRYDwU1TcU2GDCHjFMsazs/tFx9awfAQTXspMNnfqQ== X-Received: by 2002:a05:6214:411e:: with SMTP id kc30mr19091728qvb.38.1635950374877; Wed, 03 Nov 2021 07:39:34 -0700 (PDT) Received: from ?IPv6:2607:fea8:a262:5f00::38cf? ([2607:fea8:a262:5f00::38cf]) by smtp.gmail.com with ESMTPSA id o20sm1636949qkp.100.2021.11.03.07.39.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 03 Nov 2021 07:39:33 -0700 (PDT) To: gcc-patches Subject: [COMMITTED] For ranges, PHIs don't need to process arg == def. Message-ID: <87d2111a-a8fd-b2bb-52e7-3c91e760b552@redhat.com> Date: Wed, 3 Nov 2021 10:39:29 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-CA 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_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" If an argument of a phi is the same as the DEF of the phi, then the range on the incoming edge doesn't need to be taken into account since it can't be anything other than itself.  All this can do is pessimize the calculated result. ie, for something like a_2 = phi<0(2), a_2(6)> a_2 can never be anything other than [0,0], no matter what value comes in on edge 6, so lets not even check. Bootstrapped on x86_64-pc-linux-gnu with no regressions.  Pushed. Andrew From 6d936684fcf9bbb55837e3a87ae2221d5ec9b5b7 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Tue, 2 Nov 2021 09:46:53 -0400 Subject: [PATCH 4/6] For ranges, PHIs don't need to process arg == def. If an argument of a phi is the same as the DEF of the phi, then the range on the incoming edge doesn't need to be taken into account since it can't be anything other than itself. * gimple-range-fold.cc (fold_using_range::range_of_phi): Don't import a range from edge if arg == phidef. --- gcc/gimple-range-fold.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc index 6cc7753a750..608d98b43d5 100644 --- a/gcc/gimple-range-fold.cc +++ b/gcc/gimple-range-fold.cc @@ -779,6 +779,10 @@ fold_using_range::range_of_phi (irange &r, gphi *phi, fur_source &src) for (x = 0; x < gimple_phi_num_args (phi); x++) { tree arg = gimple_phi_arg_def (phi, x); + // An argument that is the same as the def provides no new range. + if (arg == phi_def) + continue; + edge e = gimple_phi_arg_edge (phi, x); // Get the range of the argument on its edge. -- 2.17.2