From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id F3B143858C54 for ; Tue, 23 Jan 2024 12:21:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F3B143858C54 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org F3B143858C54 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706012471; cv=none; b=DvaggGljR+H5ep8sZhpbQKzz/hNfbOWLMcks2rz2Yvq6rzXf8uOEDjFpM6ppC0qn4+yCwbQnNzt7Dv8e9M+LPmArm41hMfLmGC/3waXNEg9IdBGKtPjbIRAatt9f5LQA1BYGKor1TVkPVWxQ0D1JnzhV1Y71KwWZKl3PPoR85x0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706012471; c=relaxed/simple; bh=qjNNVqqd2FQNLQsZgxduEoAqCLfDltnTEIbwpRe7DWg=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=bwuCaDK03txEgVJ5l+GvMWfouCVWqPznzPFejr/rvlBG4fQD5mbqwZyAwYBCDAja4w49O/Z7ONCCSMABya7tQcqn8Dq0+/R31uZTJJq7r69nWYmM1GuWbK+zszmjSczeb0i+weALRhs8Uzkb4faNyPzUHVZl1ll1h/RJJR7D9UA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706012468; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=ivylRCjsGFGuFYbhjUbt2CzUSDEv/p0mYsBDuW81F9Q=; b=GR/Mw0VyU6V3g4KeomDidA/cDxN3d59chd5L83ErT9ZuhD44ykezbnjCKhKtKPpNwp8PRy uWqMjShrS2QuVzv6UuhTbe8Qdaw3RGyJTbId0Q+CUEBlYhON2T0NFn1phqtWICgYLd2DUn NXUq10nx9GBpFMVSJ/xLA6rU1Zp9kOk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-138-p3Y6CfHmPcyYqA6CbjpnQQ-1; Tue, 23 Jan 2024 07:21:07 -0500 X-MC-Unique: p3Y6CfHmPcyYqA6CbjpnQQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E413785A58F; Tue, 23 Jan 2024 12:21:06 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.70]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A7C6DC15E61; Tue, 23 Jan 2024 12:21:06 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 40NCL4ZV1534344 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 23 Jan 2024 13:21:04 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 40NCL3xL1534343; Tue, 23 Jan 2024 13:21:03 +0100 Date: Tue, 23 Jan 2024 13:21:03 +0100 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] tree-optimization/113552 - fix num_call accounting in simd clone vectorization Message-ID: Reply-To: Jakub Jelinek References: <20240123115653.47E5C136A4@imap1.dmz-prg2.suse.org> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE 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 Tue, Jan 23, 2024 at 01:03:46PM +0100, Richard Biener wrote: > On Tue, 23 Jan 2024, Jakub Jelinek wrote: > > > On Tue, Jan 23, 2024 at 12:56:52PM +0100, Richard Biener wrote: > > > The following avoids using exact_log2 on the number of SIMD clone calls > > > to be emitted when vectorizing calls since that can easily be not > > > a power of two in which case it will return -1. For different simd > > > clones the number of calls will differ by a multiply with a power of two > > > only so using floor_log2 is good enough here. > > > > > > Bootstrap and regtest running on x86_64-unknown-linux-gnu. > > > > > > PR tree-optimization/113552 > > > * tree-vect-stmts.cc (vectorizable_simd_clone_call): Use > > > floor_log2 instead of exact_log2 on the number of calls. > > > > Is there any target which supports non-power-of-two simdlen? > > If not, perhaps we should add !pow2p_hwi (num_calls) to the continue; > > condition a few lines earlier? > > Is non-power-of-two simdlen a thing? Note there's nothing wrong > with non-power-of-two num_calls, with VF == 4 and a group size > of 3 you get 12 lanes and either 3 (simdlen == 4) or 6 (simdlen == 2) > calls. > > Iff non-power-of-two simdlen is a thing then we could bias > by + num_calls (no idea why we use *_log2 in the first place, but it > was that way since the beginning). Ah, with SLP I can understand it doesn't have to be a power of two, the original + if (n->simdclone->simdlen + < (unsigned) LOOP_VINFO_VECT_FACTOR (loop_vinfo)) + this_badness += (exact_log2 (LOOP_VINFO_VECT_FACTOR (loop_vinfo)) + - exact_log2 (n->simdclone->simdlen)) * 1024; was written for loop vectorization only and I think correctly assumed power of 2 loop vectorization factors as well as simdlens. I admit I don't remember why log2 rather than the count has been used, the first version of the patch is https://gcc.gnu.org/pipermail/gcc-patches/2013-November/374728.html But if we keep using log2, perhaps better ceil_log2 because num_calls of 3 is certainly more expensive than 2. Jakub