From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id 3C5573858D3C for ; Wed, 22 Mar 2023 15:57:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3C5573858D3C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.98,282,1673942400"; d="scan'208";a="845" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 22 Mar 2023 07:57:28 -0800 IronPort-SDR: StqS4PJwQTzqnZxytPoxlCfciaSNnZmUMF5o+XWR2kE4yd+drk+NXwC7ssp+OQ+CmY9QajtTW2 OwvACjmGzTWtPmpfTFevveLeyODs7oNxBDzXYoP/rltep5CF+zEPgDfXki0FHcEC5UUrnSJO2s ZNJ8VxQHlS9ooFe3Jk8q3BZhF58SIKNQGUOyjqEAFzP4t8LLpBqLK0m79MT1QZM5qrFTb99Tvj HTG6Wdswq163f6m3oN2nwXKbDn+UpwvnCzSxUraPyj2u6JqCjzf8RDwx6QbYSdyCoezDRv7Tig FOA= Message-ID: <7133bc52-6d18-0276-0b01-0f7dd239c2ed@codesourcery.com> Date: Wed, 22 Mar 2023 15:57:23 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: Libgcc divide vectorization question Content-Language: en-GB To: Richard Biener CC: GCC Development References: <7f227691-7c3d-599b-ed24-6fde2ce3c11d@codesourcery.com> From: Andrew Stubbs In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) To svr-ies-mbx-11.mgc.mentorg.com (139.181.222.11) X-Spam-Status: No, score=-6.2 required=5.0 tests=BAYES_00,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,NICE_REPLY_A,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=no 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 22/03/2023 13:56, Richard Biener wrote: >> Basically, the -ffast-math instructions will always be the fastest way, >> but the goal is that the default optimization shouldn't just disable >> vectorization entirely for any loop that has a divide in it. > > We try to express division as multiplication, but yes, I think there's > currently no way to tell the vectorizer that vectorized division is > available as libcall (nor for any other arithmetic operator that is not > a call in the first place). I have considered creating a new builtin code, similar to the libm functions, that would be enabled by a backend hook, or maybe just if TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION doesn't return NULL. The vectorizer would then use that, somehow. To treat it just like any other builtin it would have to be set before the vectorizer pass encounters it, which is probably not ideal for all the other passes that want to handle divide operators. Alternatively, the vectorizable_operation function could detect and introduce the builtin where appropriate. Would this be acceptable, or am I wasting my time planning something that would get rejected? Thanks Andrew