From patchwork Fri Aug 4 07:15:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 1816828 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.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=qH0fNdqq; dkim-atps=neutral Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RHH7L6xmfz1ybS for ; Fri, 4 Aug 2023 17:15:58 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2D53E3858436 for ; Fri, 4 Aug 2023 07:15:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2D53E3858436 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1691133356; bh=7R13j3pQeGAyZRJOaRboDA96hSfzZa1UMPYNLfYexfo=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=qH0fNdqq+FJE7Lc1++WnCPvU1KXuMTGbvg0KGQwZQX8VMUcHPFdyH8PO9mTVea8Z8 H9oHuXTjfDAKUlDNaLw/rhjUqXWmr6XGHY8SuAM/9dL0Hf8PQYu7LGGStHDTfKp1SL lytCRscxjNKUpRkhKOWZmB/liSJO+6J8x9qPeBY8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from nikam.ms.mff.cuni.cz (nikam.ms.mff.cuni.cz [195.113.20.16]) by sourceware.org (Postfix) with ESMTPS id 5004D3858436 for ; Fri, 4 Aug 2023 07:15:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5004D3858436 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 70E042828D4; Fri, 4 Aug 2023 09:15:36 +0200 (CEST) Date: Fri, 4 Aug 2023 09:15:36 +0200 To: gcc-patches@gcc.gnu.org Subject: Disable loop distribution for loops with estimated iterations 0 Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, JMQ_SPF_NEUTRAL, KAM_NUMSUBJECT, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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 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: Jan Hubicka via Gcc-patches From: Jan Hubicka Reply-To: Jan Hubicka Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi, this prevents useless loop distribiton produced in hmmer. With FDO we now correctly work out that the loop created for last iteraiton is not going to iterate however loop distribution still produces a verioned loop that has no chance to survive loop vectorizer since we only keep distributed loops when loop vectorization suceeds and it requires number of (header) iterations to exceed the vectorization factor. Bootstrapped/regtested x86_64-linux, OK? gcc/ChangeLog: * tree-loop-distribution.cc (loop_distribution::execute): Disable distribution for loops with estimated iterations 0. diff --git a/gcc/tree-loop-distribution.cc b/gcc/tree-loop-distribution.cc index cf7c197aaf7..8ff2108f284 100644 --- a/gcc/tree-loop-distribution.cc +++ b/gcc/tree-loop-distribution.cc @@ -3871,10 +3871,20 @@ loop_distribution::execute (function *fun) bool destroy_p; int nb_generated_loops, nb_generated_calls; + bool only_patterns = !optimize_loop_for_speed_p (loop) + || !flag_tree_loop_distribution; + /* do not try to distribute loops that are not expected to iterate. */ + if (!only_patterns) + { + HOST_WIDE_INT iterations = estimated_loop_iterations_int (loop); + if (iterations < 0) + iterations = likely_max_loop_iterations_int (loop); + if (!iterations) + only_patterns = true; + } nb_generated_loops = distribute_loop (loop, work_list, cd, &nb_generated_calls, - &destroy_p, (!optimize_loop_for_speed_p (loop) - || !flag_tree_loop_distribution)); + &destroy_p, only_patterns); if (destroy_p) loops_to_be_destroyed.safe_push (loop);