From patchwork Mon Nov 8 17:49:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1552465 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=FTLhXUEm; dkim-atps=neutral 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+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HnzG56kVjz9sCD for ; Tue, 9 Nov 2021 04:52:13 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 34C993858423 for ; Mon, 8 Nov 2021 17:52:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 34C993858423 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1636393931; bh=lWUavX2K12oJApHy3DCNM/bhWx5raKePo/N0PwtxLsc=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=FTLhXUEmLHq710r5pCAauOuMDPoFX2KJnrwwSmlw1/F90SjASXXjosbU3AzLEItGY 67hgQBNOX9sUfZFDq5VLMUOPmOJtobUnmhuZrKTjEUjABZX2zTnBCpWrJxiAuCWK88 gBCvXQlkoFENM4AqijpxXEFqSkTYPQvIKvoJJxfM= 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 [216.205.24.124]) by sourceware.org (Postfix) with ESMTPS id AB0663858425 for ; Mon, 8 Nov 2021 17:50:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AB0663858425 Received: from mail-io1-f70.google.com (mail-io1-f70.google.com [209.85.166.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-551-iw_hmAT0Nqa9jxMp8taBIQ-1; Mon, 08 Nov 2021 12:50:17 -0500 X-MC-Unique: iw_hmAT0Nqa9jxMp8taBIQ-1 Received: by mail-io1-f70.google.com with SMTP id r199-20020a6b2bd0000000b005e234972ddfso3037112ior.23 for ; Mon, 08 Nov 2021 09:50:17 -0800 (PST) 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=lWUavX2K12oJApHy3DCNM/bhWx5raKePo/N0PwtxLsc=; b=TNG/HUnPhL8x+wiuMLl+ayKlFIZGZwbMXenv0AVuOxJB1Rd/ab3vM41dIzRrmvOwrn USULtIun4vaFDrpjO+6NwSHwDT+JJ6fz1V47VihraAd1XFlqnBT4Wa5uGE1TtcX0jWNW OdZVEgi+xJHREAydSqlsmbzaXwIT+ifeS67daFc5/wwH0gZkWGnhLn3f++G3BrE+C/4n M6FX+vx+rfi6AksiK8FeQFKcty9iK0lqUDOmQ0hziHYAVNTwqzroM/ugly5l0kO88abR VPjxjzuIpRBIYJ//8lWamyI61OielAbms5JBBdlev9oYJZ/Ks5IqJx8TNCQ9G4hg2iVL qogA== X-Gm-Message-State: AOAM530Ojy5HEKRiUAS3sMCWngdYBeuT6eVXBOq2iDIqLqVSHbyId7Er fFIswVdx9h4avheENU8lxcHGVOtdfy252zUEd4vxfa5ZQ8w0zdKFNb2s6GJ4JmH8IuOC8vE5mKG ewtiYZz2o0ArSqAQqYQ== X-Received: by 2002:a05:6602:2b83:: with SMTP id r3mr676785iov.8.1636393816614; Mon, 08 Nov 2021 09:50:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJy/Ra2aAmxZLesIE1n74ccgXre9je5AJ4sv9wOXw6F80985dJXQrlQ33k3dj+5QTdrqmEg31A== X-Received: by 2002:a05:6602:2b83:: with SMTP id r3mr676774iov.8.1636393816483; Mon, 08 Nov 2021 09:50:16 -0800 (PST) Received: from [192.168.0.102] ([104.219.122.240]) by smtp.gmail.com with ESMTPSA id z11sm9678949ilb.11.2021.11.08.09.50.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 08 Nov 2021 09:50:11 -0800 (PST) To: gcc-patches Subject: [COMMITTED] tree-optimization/103022 - Don't calculate new values when using the private context, callback. Message-ID: <646b175e-3092-3cc9-2198-703442769c10@redhat.com> Date: Mon, 8 Nov 2021 12:49:54 -0500 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_H2, 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" When using the private communication method I introduced for fold_stmt to acquire context, we are suppose to be using the cache in read-only mode.  I didn't query it in that mode, so it was accidentally triggering another lookup before finishing the original query, and that triggered the safety trap.  This patch makes sure we make the request in read-only mode . Bootstraps with no regressions on x86_64-pc-linux-gnu.  Pushed. Andrew commit 0cd653bd2559701da9cc4c9bf51f22bdd68623b5 Author: Andrew MacLeod Date: Mon Nov 8 09:32:42 2021 -0500 Don't calculate new values when using the private context callback. When using rangers private callback mechanism to provide context to fold_stmt calls, we are only suppose to be using the cache in read only mode, never calculate new values. gcc/ PR tree-optimization/103122 * gimple-range.cc (gimple_ranger::range_of_expr): Request the cache entry with "calulate new values" set to false. gcc/testsuite/ * g++.dg/pr103122.C: New. diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc index e1177b1c5e8..87dba6e81d8 100644 --- a/gcc/gimple-range.cc +++ b/gcc/gimple-range.cc @@ -88,8 +88,8 @@ gimple_ranger::range_of_expr (irange &r, tree expr, gimple *stmt) if (!m_cache.get_global_range (r, expr)) r = gimple_range_global (expr); // Pick up implied context information from the on-entry cache - // if current_bb is set. - if (current_bb && m_cache.block_range (tmp, current_bb, expr)) + // if current_bb is set. Do not attempt any new calculations. + if (current_bb && m_cache.block_range (tmp, current_bb, expr, false)) { r.intersect (tmp); char str[80]; diff --git a/gcc/testsuite/g++.dg/pr103122.C b/gcc/testsuite/g++.dg/pr103122.C new file mode 100644 index 00000000000..3465eade46b --- /dev/null +++ b/gcc/testsuite/g++.dg/pr103122.C @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +unsigned a; +int b; +short c; +void d(long) { + for (bool e = (bool)c - 1; e < (bool)b - 1; e += 0) + ; + if (a) { + for (char f = 0; f < 7; f = 7) + for (int g = 0; g < c; g += 10) + ; + d(-!c); + } +}