From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpout30.security-mail.net (smtpout30.security-mail.net [85.31.212.36]) by sourceware.org (Postfix) with ESMTPS id 327273858D35 for ; Tue, 26 Sep 2023 10:19:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 327273858D35 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=kalrayinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kalrayinc.com Received: from localhost (fx306.security-mail.net [127.0.0.1]) by fx306.security-mail.net (Postfix) with ESMTP id 1139B35D099 for ; Tue, 26 Sep 2023 12:19:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kalrayinc.com; s=sec-sig-email; t=1695723572; bh=B+zYYst7+RqsA9lNuFphY7BoW/j0IZ2h+/dLnxaM2TY=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=cYsnkVva1O9WXY97uhLUz1Dkq5T40O+nK+G4SH7uxi5zreWSm+/kpi7R0r7NX9EgB Jo+k3MwszkOUQYeao0BTmUDDBBOGA7poP+l1xwWJCVS8dvbTYSJ9tTMyMv3YizHvbo 54TpOtVLrCPdRhCu+pw6b2OCAhqjlce4NGpPJltc= Received: from fx306 (fx306.security-mail.net [127.0.0.1]) by fx306.security-mail.net (Postfix) with ESMTP id E1ACD35D032; Tue, 26 Sep 2023 12:19:31 +0200 (CEST) Received: from FRA01-PR2-obe.outbound.protection.outlook.com (mail-pr2fra01lp0108.outbound.protection.outlook.com [104.47.24.108]) by fx306.security-mail.net (Postfix) with ESMTPS id 6FBB935D0E1; Tue, 26 Sep 2023 12:19:31 +0200 (CEST) Received: from MR1P264MB2482.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:33::22) by PR0P264MB3370.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:147::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Tue, 26 Sep 2023 10:19:28 +0000 Received: from MR1P264MB2482.FRAP264.PROD.OUTLOOK.COM ([fe80::aeb6:2f26:45ff:5461]) by MR1P264MB2482.FRAP264.PROD.OUTLOOK.COM ([fe80::aeb6:2f26:45ff:5461%7]) with mapi id 15.20.6813.027; Tue, 26 Sep 2023 10:19:28 +0000 X-Virus-Scanned: E-securemail Secumail-id: <54a5.6512b033.6ea94.0> ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eAP54iccslcy2JU/OchCp5XX7Wodt5HiHK1Tz5w6yVBxGCWvxXnP6mXApFL40nRddedjGs+sgQmAcyJ837fgyrgZysInvJoGFM6tl9FEp1Kv1dck/wMGMQPmuugAYoxDJMwLCF7kvJzBDbA0fR05yJCqA5SlGFCzWm7+uhcRQX/NAIVGSvU17hhI3yXn/WN0bUnxXKTQzZFbhazk9dXU/kyGiopAXAdhSXwV1o07kzUgLC8jMWcA8Bk+yclgIXxEy/Aovd4AIsIPVz+88vLgcqUHQEUpKulJnSpKkxZjfVxvGrzLJaM7UWEytHLaZjaltGgZFARk5W3wqcKkjbdEzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mkBnxGc9Lh359X4nYjgpTymGWMyVUeKUHvK2Odz/aVE=; b=h/pXbEMZmfkDi1X5vwZZIMMspMeX0u8Wsf8FDfMRQar1ImNj9uyyH0M6zaCukdPsNLfTRNQ4OCKkl6tdnchniRDd2ho6qm0/6iZv90FX3zO+CtSZNufTpHXcr8CCapKDvOe+zquLvI+y28XE3dJSOa3jAjpxvU1mJSOk6fQlskr+NwRpbGXfFcLMFkNhLQAViEygtoeLaI3vd2fvR3yRMV4+giMCgU6xDJUw9u9Nwr2K1UVE6GwheJgBLnKZI1i7KTf11sgPVxC/nuQnXI0Of9t5DToujo2ym+Xu+2HEqVkZWHXYjJWdyYbOcTB8CzU4cDIMD/F0JmUAG4onW5/HQQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=kalrayinc.com; dmarc=pass action=none header.from=kalrayinc.com; dkim=pass header.d=kalrayinc.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kalrayinc.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mkBnxGc9Lh359X4nYjgpTymGWMyVUeKUHvK2Odz/aVE=; b=AcKToH+lJjzK47ijjOSuAipl2LWHgtYlrTcbe/Hg294hHbA/3Zia753FfmNuyK4sYf2nbB6a6bTN7hn1PqFGD5dfScJc87C7xntN5onmp4CbdDTglMEqQK4tsCoi3PMzTaOIzmdoZdAdIvbPu+zJkG13CixeuTT8f/0B+0fAriconz+VBQYI2hnsBN+hp2p0D4aTotPrAqNPPl09XJjOh4HecUMqEprYo3w8wFTvVsplPYbliAMdfppRX+/grOlgjTLNBwFsSZUThf6IeOzT0K+8XAo4qC07P1+pNBc9+Yr1BEXoy+Em7xNHhtrCYmBIGli1K0pZ9Ng7zt6JuTn5Ig== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=kalrayinc.com; Date: Tue, 26 Sep 2023 12:19:26 +0200 From: Paul Iannetta To: Tamar Christina Cc: Richard Biener , Sylvain Noiry , gcc@gcc.gnu.org, sylvain.noiry@hotmail.fr Subject: Re: Complex numbers support: discussions summary Message-ID: <20230926101926.omyzpgjeybddbdsn@ws2202.lin.mbt.kalray.eu> References: Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20171215 X-ClientProxiedBy: LO4P123CA0379.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:18f::6) To MR1P264MB2482.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:33::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MR1P264MB2482:EE_|PR0P264MB3370:EE_ X-MS-Office365-Filtering-Correlation-Id: a5093c84-3477-457b-843f-08dbbe7a10c4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oqWbzlbrze/xdvYWR41ZYHJwHDRAjRc7ggaYMRBsWBOGPU6JzP+SjKxJYJ/GeCRJuQ4+CLJN/d9rYFQXsPTmJiRDFuAILItbvmv54O93DGKWmSVtWV2F/CCw9nJ4J0iLnF9Oj18qVhsb72AIdEuHosgqyzKz0k+j7Fjs19yQW62MTzgbu+TfThfsT0TNIfoEHCGc6C/HaQ6dtq6k6lakt31rBHMCQVE5ywLPootgr6P8Fx0TJkOUA/NVhBybBw3Onh4dNoG7yd0Nb5TsOjGo7V3Xpg2KGuK57YIJdviWwWa1znOmHHCx8PyvrQpLu7iJaCLmm4VY6QIJwSVq1gVF2Qorhpiox5TMQhuKqUpLJO6QuxpFu4/OBdyjn9GBAwWO6geJ7T29LbzKxDAEAlVYz1KNaND+DncSFlLdEy18wje6NgGWkJgE+3aI8Fjlo8SlltcS0+Dp2gGezqUmJoyZUwYE7uihUSAV8T+VVoPAGIZF0VswPf3x+jt+DZWub232W8i7iNkDXctYqQVw0qQB9oGr+UC6BcLGoBrvFvrBIGE= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MR1P264MB2482.FRAP264.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230031)(136003)(366004)(39860400002)(376002)(346002)(396003)(230922051799003)(186009)(1800799009)(451199024)(6916009)(2906002)(3716004)(66946007)(66556008)(66476007)(54906003)(316002)(4326008)(8936002)(8676002)(5660300002)(41300700001)(66899024)(83380400001)(1076003)(26005)(86362001)(38100700002)(6486002)(6506007)(6512007)(9686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fwDrDt2FnWBSJsYPOtcnTFbRs3UAhVVKcoW2VobJpQWgXD/JyNziqNVRbgNu/FILpUhO98dLpC50KPHmXlvgRMV+TpQv9CNdq3rjvgA42QorvHQPWXXsWo4S2uOSqZDug4WOEopl/dQWXgmGeRO5TB/5jcFVjFvllY7FW9BTBrE30V6Fy5APO6fgVSdN2Cu6ksMna++Po7O1ROoe7w7FDXLvBqoZHIalhra2NANA4AC/hEAtmoJ6vzoLOe6dBPmPvHd5g7cHEO/tDF856lOXcaqwkVRO5CP6xB0G1JYHiG5C7ZWRoGaFERC2s9+/ODerdIL4ge5x+1FF21oK8lVfBtFNj/ueO11yvlKIcvB6DsFzNc9fa5djjQbQpHyLE+PKMDlUfbPaNQcK32rHKhb+PsSaA08BbEU0vGkfb43sM0YP8vPL8CBppMuq42nb5EQ0kqZiNz+t/GPMHGDJWGHFsDK+m5kRPaFJuydFGCXjQfHVmaDS8lhQApZPm7/AkvBTIX7UiGcjbUxflMYwnkZ9DbhWC9irNmzjuc2GZP6ekjr2hQYB29E17hGSu5irP3AhQX5BfK42SKz2GKUQ81w+jEbyf9YGpHfTd5Rz45fCaV4R0hSNQ1tVuQ== X-OriginatorOrg: kalrayinc.com X-MS-Exchange-CrossTenant-Network-Message-Id: a5093c84-3477-457b-843f-08dbbe7a10c4 X-MS-Exchange-CrossTenant-AuthSource: MR1P264MB2482.FRAP264.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2023 10:19:28.1321 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8931925d-7620-4a64-b7fe-20afd86363d3 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: q5eJwS+jAglTjLRMx3dq+YWYmFIUfoZlIhidCmrNcJkVHGPSEugpx4Upgy5P7RcP9qRFPJbqqI1G5iTAnk0v/g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR0P264MB3370 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-ALTERMIMEV2_out: done X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,RCVD_IN_DNSWL_LOW,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: On Tue, Sep 26, 2023 at 08:29:16AM +0000, Tamar Christina via Gcc wrote: > Hi, > > I tried to find you two on Sunday but couldn't locate you. Thanks for the presentation! Yes, sadly we could not attend on Sunday because we wanted to be back for Monday. > > > > > > We had very interesting discussions during our presentation with Paul > > > on the support of complex numbers in gcc at the Cauldron. > > > > > > Thank you all for your participation ! > > > > > > Here is a small summary from our viewpoint: > > > > > > - Replace CONCAT with a backend defined internal representation in RTL > > > --> No particular problems > > > > > > - Allow backend to write patterns for operation on complex modes > > > --> No particular problems > > > > > > - Conditional lowering depending on whether a pattern exists or not > > > --> Concerns when the vectorization of split complex operations > > > --> performs > > > better > > > than not vectorized unified complex operations > > > > > > - Centralize complex lowering in cplxlower > > > --> No particular problems if it doesn't prevent IEEE compliance and > > > optimizations (like const folding) > > > > > > - Vectorization of complex operations > > > --> 2 representations (interleaved and separated real/imag): cannot > > > impose one > > > if some machines prefer the other > > > --> Complex are composite modes, the vectorizer assumes that the inner > > > mode is > > > scalar to do some optimizations (which ones ?) > > > --> Mixed split/unified complex operations cannot be vectorized easely > > > --> Assuming that the inner representation of complex vectors is let > > > --> to > > > target > > > backends, the vectorizer doesn't know it, which prevent some > > > optimizations > > > (which ones ?) > > > > > > - Explicit vectors of complex > > > --> Cplxlower cannot lower it, and moving veclower before cplxlower is > > > --> a > > > bad > > > idea as it prevents some optimizations > > > --> Teaching cplxlower how to deal with vectors of complex seems to be > > > --> a > > > reasonable alternative > > > --> Concerns about ABI or indexing if the internal representation is > > > --> let > > > to the > > > backend and differs from the representation in memory > > > > > > - Impact of the current SLP pattern matching of complex operations > > > --> Only with -ffast-math > > > --> It can match user defined operations (not C99) that can be > > > simplified with a > > > complex instruction > > > --> Dedicated opcode and real vector type choosen VS standard opcode > > > --> and > > > complex > > > mode in our implementation > > > --> Need to preserve SLP pattern matching as too many applications > > > redefines > > > complex and bypass C99 standard. > > > --> So need to harmonize with our implementation > > > > > > - Support of the pure imaginary type (_Imaginary) > > > --> Still not supported by gcc (and llvm), neither in our > > > --> implementation Issues comes from the fact that an imaginary is not > > > --> a complex with > > > real part > > > set to 0 > > > --> The same issue with complex multiplication by a real (which is > > > --> split > > > in the > > > frontend, and our implementation hasn't changed it yet) > > > --> Idea: Add an attribute to the Tree complex type which specify pure > > > real / pure > > > imaginary / full complex ? > > > > > > - Fast pattern for IEEE compliant emulated operations > > > --> Not enough time to discuss about it > > > > > > Don't hesitate to add something or bring more precision if you want. > > > > > > As I said at the end of the presentation, we have written a paper > > > which explains our implementation in details. You can find it on the > > > wiki page of the Cauldron > > > > > (https://gcc.gnu.org/wiki/cauldron2023talks?action=AttachFile&do=view&tar > > get=Exposing+Complex+Numbers+to+Target+Back-ends+%28paper%29.pdf). > > > > Thanks for the detailed presentation at the Cauldron. > > > > My personal summary is that I'm less convinced delaying lowering is the way > > to go. > > I personally like the delayed lowering for scalar because it allows us to properly > reassociate as a unit. That is to say, it's easier to detect a * b * c when they > are still complex ops. And the late lowering will allow beter codegen than today. > > However I think we should *unconditionally* not lower them, even in situations > such as a * b * imag(b). This situation can happen by late optimizations anyway > so it has to be dealt with regardless so I don't think it should punt. > > I think you can then conditionally lower if the target does *not* implement the > optab. i.e. for AArch64 the complex mode wouldn't be useful. > Indeed, our current approach in the vectorizer works only if the complex scalar patterns exist as well, and I agree that it would be better to if the absence of either scalar or vector patterns would not prevent any optimizations. Keeping everything unified until after the vectorizer and the SLP passes and lowering after that might work. But we would have to try, and see if we do not run into any problem with -ffast-math and/or IEE754 compliance. In particular, in order to not lower imag(b) we could promote it to __complex_expr__ (0, b, IMAGINARY). At the cost of adding a field to __complex_expr__ that would help with floating-point compliance and be a step towards the support of _Imaginary. > > I do think that if targets implement complex optabs we should use them but > > eventually re-discovering complex operations from lowered form is going to be > > more useful. > > That's because as you said, use of _Complex is limited and > > people inventing their own representation. SLP vectorization can discover > > some ops already with the limiting factor being that we don't specifically > > search for only complex operations (plus we expose the result as vector > > operations, requiring target support for the vector ops rather than [SD]Cmode > > operations). > > I don't think the two are mutually exclusive, I do think we should form complex > instructions from scalar ops as well, because we can generate better expansions. > > Today we only expand efficiently when the COMPLEX_EXPR node is still there > and bitfield expansion knows then that the entire value will be written. So > rediscovery will help there. > > I also think if we don't lower early, as you mention we should lower the complex > operations in the vectorizer. I don't think having the complex mode as vectors > are useful. This can be easily done by using the scalar vect pattern. It'll have > to handle all arithmetic ops though, but for those the target has an optab we > can form it early which would have the SLP one skip it later. > Our main motivation to introduce complex modes for vectors was not to duplicate common SPN with alternatives like "cmul" and such. It is not a hard requirement from our part. We just thought that it would be cleaner. Paul & Sylvain > This also means vec_lower doesn't have issues anymore. > > Cheers, > Tamar > > > > > There's the gimple-isel.cc or the widen-mul pass that perform instruction > > selection which could be enhanced to discover scalar [SD]Cmode operations. > > > > Richard. > > > > > Sylvain > > > > > > > > > > > > > > > > > > >