From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=ucw.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kam.mff.cuni.cz Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 70E042828D4; Fri, 4 Aug 2023 09:15:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucw.cz; s=gen1; t=1691133336; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=7R13j3pQeGAyZRJOaRboDA96hSfzZa1UMPYNLfYexfo=; b=Z/4Dh6KVyHM8RO4FF4efn+8qopjhRlx+WabSSou0hROvvTJfNl1oeWwruE5Ard4jRBcf/7 ROv22Xp+h+B7k0kXiZuevgRarn8YymLeGJWiH7DAFwBxmgqk9fzXv0wQEv+YYdcCYEyIhw diIlnQOhLsQ46wlr6Sub1tHqjzzeMNU= Date: Fri, 4 Aug 2023 09:15:36 +0200 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Disable loop distribution for loops with estimated iterations 0 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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 List-Id: 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);