From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by sourceware.org (Postfix) with ESMTPS id 1BA673858D32 for ; Thu, 10 Aug 2023 15:01:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1BA673858D32 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-686daaa5f1fso728480b3a.3 for ; Thu, 10 Aug 2023 08:01:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691679659; x=1692284459; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=fhN6fm7WvPVsKdhqSXcl0XFjXVntz2CkJJPsauSmr44=; b=gVmaBo+35TfWld9Zayv2QNwVLcTNzYyaYNrFZNhPE23B8Y2NQYZ4AbcKZm15Kly/J2 B65inVV1Q8JIvKXLJ8MT+iZdbHm9Ma6F1Wm5fQE3zClhU8gfej9w+evDk2dR9z9gmt3g 1ju1e4w+yyBPNDGl9MVxgiJdybECKHQckAOdaOn1OGKyBmfSSlE2ulh89s5ZQ/7LzFNj BKUvqMIK6rlCRylrYVA52vDh1TzKOZVSw+yYPPKs/i1Q9bIUQzuMQISsAX8mnFJHPPtw mD9ii8+fpQlDw31oNNaEcrJrIWOTIir7C/2pUUdQHb/Q2ARcR7yUwiIHglLE4+et6r8k whQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691679659; x=1692284459; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fhN6fm7WvPVsKdhqSXcl0XFjXVntz2CkJJPsauSmr44=; b=QVVn01LyyFHhBmO9h0wDV5U7QgZwJxEspUzkvwTOq4ypt2JPoWsKshsVWQVqUuWz5i U9Lax4B41/WieQlCzlyMrGGXd93WIh7zznxCgd0K6P1MzwmHNuuZOgE+2+gB8ZJCaD1S fcYCKeXC8q/CN1/FuxEn8PbEVOOH6LfZNGjpeOW2y0HtIfmkGWAfCif+MyyePlY6Kzkl 6NjQWckBm9hafCNvFNyug6QRdjkmTcoJu1/qc5WeqTkP2QKUM+DYsteSOoLYvGxrgVMS n74a1cIq6HwXAKvpcofaIipiQtgDH6OHy4RLiOuqEebwZap9pBh+H7kB0ssLVI3W/NTq MiPA== X-Gm-Message-State: AOJu0YywSrW68N/UGOoG9WTGhK1XwCPMP69B8OqilHymJjv9uqex0v2p RUg3QyIyWT4mIFRmG2TDT8I= X-Google-Smtp-Source: AGHT+IGYLM7addZAs9Jv2Lvj+4cHPQY6YuTg/Id1ql55smnKwmj+alCdqSllMTb1rASUppBoTYbU5g== X-Received: by 2002:a05:6a20:748b:b0:137:fa5:8519 with SMTP id p11-20020a056a20748b00b001370fa58519mr2620848pzd.31.1691679658823; Thu, 10 Aug 2023 08:00:58 -0700 (PDT) Received: from [172.31.0.109] ([136.36.130.248]) by smtp.gmail.com with ESMTPSA id g1-20020aa78741000000b00686bdff1d6fsm1635393pfo.77.2023.08.10.08.00.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 10 Aug 2023 08:00:58 -0700 (PDT) Message-ID: <293733b2-c372-dc5d-91b9-a3bbdf226f3d@gmail.com> Date: Thu, 10 Aug 2023 09:00:56 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH] tree-optimization/110963 - more PRE when optimizing for size To: Richard Biener , gcc-patches@gcc.gnu.org Cc: Jan Hubicka References: <20230810124206.BF5803857806@sourceware.org> Content-Language: en-US From: Jeff Law In-Reply-To: <20230810124206.BF5803857806@sourceware.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 8/10/23 06:41, Richard Biener via Gcc-patches wrote: > The following adjusts the heuristic when we perform PHI insertion > during GIMPLE PRE from requiring at least one edge that is supposed > to be optimized for speed to also doing insertion when the expression > is available on all edges (but possibly with different value) and > we'd at most have one copy from a constant. The first ensures > we optimize two computations on all paths to one plus a possible > copy due to the PHI, the second makes sure we do not need to insert > many possibly large copies from constants, disregarding the > cummulative size cost of the register copies when they are not > coalesced. > > The case in the testcase is > > > _14 = h; > if (_14 == 0B) > goto ; > else > goto ; > > > h = 0B; > > > h.6_12 = h; > > and we want to optimize that to > > > # h.6_12 = PHI <_14(5), 0B(6)> > > If we want to consider the cost of the register copies I think the > only simplistic enough way would be to restrict the special-case to > two incoming edges - we'd assume one register copy is coalesced > leaving one copy from a register or from a constant. > > As with every optimization the downstream effects are probably > bigger than what we can locally estimate. > > Bootstrapped and tested on x86_64-unknown-linux-gnu. > > Any comments? > > Thanks, > Richard. > > PR tree-optimization/110963 > * tree-ssa-pre.cc (do_pre_regular_insertion): Also insert > a PHI node when the expression is available on all edges > and we insert at most one copy from a constant. > > * gcc.dg/tree-ssa/ssa-pre-34.c: New testcase. The other thing in this space is to extend it to the case where multiple phi args have the same constant. My recollection is we had some bits in the out-of-ssa code to factor those into a single path -- if that still works in the more modern expansion approach, the it'd likely be a win to support as well. jeff