From patchwork Mon Feb 7 14:29:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 50858 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 4E127385842B for ; Mon, 7 Feb 2022 14:29:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4E127385842B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1644244186; bh=ENlHRfOl4350+KShoVgdOgIcnF6uB3dG1d83z3RtLkY=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=c5Vq4bDJ9n+ph5PgWdnIozvGI8Tn275SmrW21XerPp67ffkM8oF+z6L66TJRmMKLY 60obu/9PLd3PLV8rdCNNKx3Isz1upi21GasVhTEdd2u3wbOXHKTRCMJHhfVBQ4Jo2X 91IgoZaTTBNHSUugkMabt7zkvR6fNgPCvXgr81oY= 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 E2CB63858D20 for ; Mon, 7 Feb 2022 14:29:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E2CB63858D20 Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-189-dl5hAIWBOVudi-ObKG8Qgw-1; Mon, 07 Feb 2022 09:29:15 -0500 X-MC-Unique: dl5hAIWBOVudi-ObKG8Qgw-1 Received: by mail-qt1-f197.google.com with SMTP id e14-20020ac84b4e000000b002cfbbdf8206so11151442qts.10 for ; Mon, 07 Feb 2022 06:29:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:from:subject:to:content-transfer-encoding; bh=ENlHRfOl4350+KShoVgdOgIcnF6uB3dG1d83z3RtLkY=; b=rtu0xRU+rMmnibP8+B0ehI1Ar1clrhTFYucCRHnalEvudnIQK1PccMN48usD7bj1hh L1HzVFy5ECmOMu6+g6UpHPbMXL1zActgoFAPiz/+/Z4sKG7Vk77MmMqP43zH6T8Ozu+s 6vYTnZ6JGG3FX3NKRxxd8K8o5LPAWbc1/bwnhirIsP60J2SyiyloyKM1NyNohnYm8Lb4 n/jQ4V1gzVelB0IsRz8jVGxLitM8HUFvPU48HsYeMFVV/VCWFGWwqw5/tEZXbR/sgh/J CtheoJ+1w6CxdnlAjVKzOTCc+niyHlaBc4tO4OY7/lAdG6gP0MuV8TVDi4roJ13ScvyY M0zA== X-Gm-Message-State: AOAM530xgzusv6fVhoRmnHMSb2Z1WzicQ2SlT7JNungs7wHsu0RdEt6L D57M/bGzCgIWMfDQ6a4aOYmZZImGk85cnY4MKo1IZS0wfE6nag/trFaL44sNlyBzVyD50QWBcW5 sp/kedHZZM2HPtZqNSeonLj0YIERwpBR/WZ+yPvcn8xfYPFsjUs/41PAOeJ02wOSLd2LTnw== X-Received: by 2002:a05:620a:2226:: with SMTP id n6mr3341qkh.87.1644244154391; Mon, 07 Feb 2022 06:29:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJxnGtxUbXH064hIlHN5c0E673rKvs+NCw+1Fwy+iHHZguefS35EgII0M17vWqTqn0qyG5cLAQ== X-Received: by 2002:a05:620a:2226:: with SMTP id n6mr3313qkh.87.1644244153908; Mon, 07 Feb 2022 06:29:13 -0800 (PST) Received: from ?IPV6:2607:fea8:a262:5f00::9b6f? ([2607:fea8:a262:5f00::9b6f]) by smtp.gmail.com with ESMTPSA id d17sm5665539qkn.84.2022.02.07.06.29.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 07 Feb 2022 06:29:13 -0800 (PST) Message-ID: <4425f569-b42a-bd10-b3c7-bc110e9a5c95@redhat.com> Date: Mon, 7 Feb 2022 09:29:12 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Subject: [PATCH 0/4] tree-optimization/104288 - Add more granularity to non-null tracking To: gcc-patches , Aldy Hernandez X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-CA X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GUARANTEED_100_PERCENT, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no 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" I have a proposal for PR 104288. This PR highlights the shortcomings of assuming that when the non-null property is seen within a block, that it applies to the entire block. This is a 3 patch set, but is less dramatic than it sounds.  I just wanted to split it into small bits for safety and readability. The changes boil down to making the same queries as before, only with more precision. patch set 1 changes the nonnull tracking system from a single bit to a pair of bits.  This uses the aligned_chunk code previously added to the sparse bitmaps, and the overall impact is minimal. This allows us to trace whether a block is non-null throughout the entire block, or just part of the block. patch set 2 added a callback into ranger to register side effects of a statement after ranger_vrp has folded a statement during its domwalk.  This simply checks if infer_nonnull_range is true on the statement just processed, and if it is, lets the non-null class know which then changes the state in that block to always non-null. There is no impact to the on-demand clients. patch set 3 then added a new interface to non-null in which we can ask more refined question about the state of nonnull in a block.  All queries are then audited such that   1) All queries within a block require that the nonnull property be 100% guaranteed to be nonull in the block, or we dont adjust the range.   2) Range on entry queries check if any dominator block has the non-null property at all. This will ensure we don't make the assumption that non-null somewhere in the block always applies to the entire block. The 3rd set also adds a more complicated test to the test suite to ensure we cannot remove a use early in the block even if we find it is non-null later in the same block, but then we will remove it later in the block. the 4th patch is the GCC11 version.. much simpler, it only ever checks if non-null is true in a dominator, and doesn't check within the current block.  This works fine as EVRP runs in hybrid mode by default and evrp will pick up the inter-block granularity. More details are provided with each patch. I think the risk is low since I do not believe we can do anything worse than we did before :-).  We can discuss alternatives if you think its too much at this stage. ALL patches (in sequence) bootstrap on their own and each cause no regressions. Andrew