From patchwork Thu Oct 31 10:48:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 99903 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E3B8E3857438 for ; Thu, 31 Oct 2024 10:49:12 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by sourceware.org (Postfix) with ESMTPS id 8AE433858D21 for ; Thu, 31 Oct 2024 10:48:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8AE433858D21 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8AE433858D21 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730371723; cv=none; b=svvE6jkvUbTAP4fvfPqD2PUmiZ5x7xzSZhV7TEc8oXrmRX5+NFgddybacwWw6Ep59R73KIKvGyhafhJUKWTLuePCdidLiJJt/OHJCcibNV1peVTLFes5tOS5+ezUHSn7TSjAOZT3L8QOOkRRnRqjjFugIj4zNLTs41VTHNrI8oE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730371723; c=relaxed/simple; bh=H2Iv8MITqLj4K6bvKUHP9pH63+9+lQp/87dNAYQWE3I=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version; b=bsNpMhEdAhZtBAq4Uq+8d5FapYoxWBag8USNffKc1HNch7lTq30vWGrNRRltTnLVmXXilgAgLCOI00AzHlpfhstPq4fWBssJHzyhxV7S1jIi3MUhofHvXm4nBruaMWjxIJBqd1GcP451YlvQqmMkyAgzh/lrLiyjFeDMMWavAr0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from murzim.nue2.suse.org (unknown [10.168.4.243]) (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 smtp-out2.suse.de (Postfix) with ESMTPS id 7392D1FE31 for ; Thu, 31 Oct 2024 10:48:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1730371720; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=0sBEcM173wyALpkNVB9Pum+mZMyobrHH8+fikX3ExNE=; b=o5e8wOuMuVu/4enj6B6seZEiC6j6OXOvxh+i1/RYWIN0ol9QVpdz5HKyKfMDVsgnLL4rHP xy1HjejujLMzcBHW6c8RcTgW06wpyXkRX0Iml8hgbfujitw7qcSwFUD39LS0pOCAGu2Onr yO5UjZ7qPD9n2ukUWHBku5R0wlhFb3o= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1730371720; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=0sBEcM173wyALpkNVB9Pum+mZMyobrHH8+fikX3ExNE=; b=cLadHEoySdtRQG/kO4zwm7nnawNKHy0Whc//jUAppl6/keJV8LPRCgyOlnWKZZsY2sVwYu 5wamomH7M7Rtx4CQ== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1730371719; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=0sBEcM173wyALpkNVB9Pum+mZMyobrHH8+fikX3ExNE=; b=JZSSlvtxHMJIBu5Ki4ZsJ5jNMlBDxZZHUNVhN2ADnYAavZwvR8ATZubrVAlcCHu7Z4CmKR SVP1O/jZQ5JxfZd3Y6LlI0haY2ieLYVt3iGNF12IJ89CBcf6ntTBFOdLIa8xAg2HJMAsQb yU16iezfiKp/Lgjv0gBiY2oc+kYRoak= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1730371719; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=0sBEcM173wyALpkNVB9Pum+mZMyobrHH8+fikX3ExNE=; b=tsV7ys3suiFg8OhlUCqMFOMD7d/oZJVHEtDJesi5mkZFLBt0JVfHEto17Ml5eXgr4xNk99 5vn/LcQczXzNFiCA== Date: Thu, 31 Oct 2024 11:48:39 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Move updated versioning threshold compute MIME-Version: 1.0 X-Spam-Score: -1.08 X-Spamd-Result: default: False [-1.08 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MISSING_MID(2.50)[]; NEURAL_HAM_LONG(-0.33)[-0.335]; NEURAL_HAM_SHORT(-0.14)[-0.703]; MIME_GOOD(-0.10)[text/plain]; MISSING_XM_UA(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; RCVD_COUNT_ZERO(0.00)[0]; FROM_HAS_DN(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_DN_NONE(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[tree-vect-loop.cc:url, murzim.nue2.suse.org:helo] X-Spam-Level: X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MISSING_MID, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org Message-Id: <20241031104912.E3B8E3857438@sourceware.org> The following moves computing the combined main + epilogue loop versioning threshold until we figured the epilogues to use rather than incrementally updating it with the chance to joust candidates after the fact. Bootstrapped and tested on x86_64-unknown-linux-gnu. * tree-vect-loop.cc (vect_analyze_loop): Move lowest_th compute until after epilogue_vinfos is final. --- gcc/tree-vect-loop.cc | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index df89edac036..7ed3a56bc68 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -3691,7 +3691,6 @@ vect_analyze_loop (class loop *loop, gimple *loop_vectorized_call, return first_loop_vinfo; /* Now analyze first_loop_vinfo for epilogue vectorization. */ - poly_uint64 lowest_th = LOOP_VINFO_VERSIONING_THRESHOLD (first_loop_vinfo); /* For epilogues start the analysis from the first mode. The motivation behind starting from the beginning comes from cases where the VECTOR_MODES @@ -3750,16 +3749,7 @@ vect_analyze_loop (class loop *loop, gimple *loop_vectorized_call, } /* For now only allow one epilogue loop. */ if (first_loop_vinfo->epilogue_vinfos.is_empty ()) - { - first_loop_vinfo->epilogue_vinfos.safe_push (loop_vinfo); - poly_uint64 th = LOOP_VINFO_VERSIONING_THRESHOLD (loop_vinfo); - gcc_assert (!LOOP_REQUIRES_VERSIONING (loop_vinfo) - || maybe_ne (lowest_th, 0U)); - /* Keep track of the known smallest versioning - threshold. */ - if (ordered_p (lowest_th, th)) - lowest_th = ordered_min (lowest_th, th); - } + first_loop_vinfo->epilogue_vinfos.safe_push (loop_vinfo); else { delete loop_vinfo; @@ -3780,6 +3770,17 @@ vect_analyze_loop (class loop *loop, gimple *loop_vectorized_call, if (!first_loop_vinfo->epilogue_vinfos.is_empty ()) { + poly_uint64 lowest_th + = LOOP_VINFO_VERSIONING_THRESHOLD (first_loop_vinfo); + for (auto epilog_vinfo : first_loop_vinfo->epilogue_vinfos) + { + poly_uint64 th = LOOP_VINFO_VERSIONING_THRESHOLD (epilog_vinfo); + gcc_assert (!LOOP_REQUIRES_VERSIONING (epilog_vinfo) + || maybe_ne (lowest_th, 0U)); + /* Keep track of the known smallest versioning threshold. */ + if (ordered_p (lowest_th, th)) + lowest_th = ordered_min (lowest_th, th); + } LOOP_VINFO_VERSIONING_THRESHOLD (first_loop_vinfo) = lowest_th; if (dump_enabled_p ()) dump_printf_loc (MSG_NOTE, vect_location,