From patchwork Wed Oct 2 20:01:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1170900 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-510096-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="c2FpgdKf"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="aeS6cFoq"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46k6Tq2dqwz9sN1 for ; Thu, 3 Oct 2019 06:01:33 +1000 (AEST) 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 :content-transfer-encoding; q=dns; s=default; b=JdEelFanqg7uNsp9 lqQUz0bBky193av5G1+ENk1fxKusppgZIW+Eyb8cOzqDR4vbqoaVY5BCqbeZ3UuJ yxgYNstETGhh4xac5gm4WsS4MqOg7KDFQoHvyWSi7Szc2MO1h9KmaZEcus2Byd+X 3H7/ZTCohDiNG5Rq9/PVAEf722c= 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 :content-transfer-encoding; s=default; bh=LSELW7g9hhpPJtP0Jqbn0n kwwRE=; b=c2FpgdKfZMSMcAY+uNvk8we4tGCyCihHizUGrvRlgeXnjQgiGxn+vC 3bs8n9LceRu0N7k2gpVV5zMJkAK7d4uPP9frS4LJP/t/df7BACQuhEvbNgA6rUmf T7py1khdthKycjsRPy8v+CnwOwVF9UQTRSjYD2OPKVlv7tevohP60= Received: (qmail 14397 invoked by alias); 2 Oct 2019 20:01:26 -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 14389 invoked by uid 89); 2 Oct 2019 20:01:25 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy= X-HELO: us-smtp-1.mimecast.com Received: from us-smtp-delivery-1.mimecast.com (HELO us-smtp-1.mimecast.com) (205.139.110.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 02 Oct 2019 20:01:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1570046483; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5TcQIlkrU9hdOow3mS6fBYtMkukeqAKxN0EZhYnF+xU=; b=aeS6cFoq23K1cQT+d+GWtvEIcIwgAHnvkCpBkwM6vYYZ0bHDSKE815Pf0CTQ9or55a6PRU LHv9YCAZY/h0r9ejTu2ZKLOBCmM6XjWdHh+/DszukoV8pwT439U5x722X9YVMdWcUvYElB AF0sp4WEqHA5fVD+8sQnX6fL5t/ZBbQ= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-44-7jovN7D0Or22LDpetIhztg-1; Wed, 02 Oct 2019 16:01:20 -0400 Received: by mail-qk1-f197.google.com with SMTP id d25so171413qkk.17 for ; Wed, 02 Oct 2019 13:01:20 -0700 (PDT) Received: from orpheus.redhat.com (209-6-216-142.s141.c3-0.smr-cbr1.sbo-smr.ma.cable.rcncustomer.com. [209.6.216.142]) by smtp.gmail.com with ESMTPSA id v68sm104630qkd.109.2019.10.02.13.01.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2019 13:01:18 -0700 (PDT) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [C++ PATCH] Improve C++ fold caching efficiency. Date: Wed, 2 Oct 2019 16:01:17 -0400 Message-Id: <20191002200117.11287-1-jason@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-IsSubscribed: yes While looking at concepts caching I noticed that we were clearing the caches unnecessarily for non-constant initialization, which shouldn't affect folding. Tested x86_64-pc-linux-gnu, applying to trunk. * typeck2.c (store_init_value): Only clear_cv_and_fold_caches if the value is constant. --- gcc/cp/typeck2.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) base-commit: d07428e896b5cfc7d78435de6ea08aad4e5ccfa5 diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 58fa54f40af..ec0e6a7e33d 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -907,9 +907,6 @@ store_init_value (tree decl, tree init, vec** cleanups, int flags) /* Handle aggregate NSDMI in non-constant initializers, too. */ value = replace_placeholders (value, decl); - /* DECL may change value; purge caches. */ - clear_cv_and_fold_caches (); - /* If the initializer is not a constant, fill in DECL_INITIAL with the bits that are constant, and then return an expression that will perform the dynamic initialization. */ @@ -918,6 +915,10 @@ store_init_value (tree decl, tree init, vec** cleanups, int flags) || vla_type_p (type) || ! reduced_constant_expression_p (value))) return split_nonconstant_init (decl, value); + + /* DECL may change value; purge caches. */ + clear_cv_and_fold_caches (); + /* If the value is a constant, just put it in DECL_INITIAL. If DECL is an automatic variable, the middle end will turn this into a dynamic initialization later. */