From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x143.google.com (mail-il1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) by sourceware.org (Postfix) with ESMTPS id 90B0E3870879 for ; Thu, 27 Aug 2020 18:47:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 90B0E3870879 Received: by mail-il1-x143.google.com with SMTP id c6so5724087ilo.13 for ; Thu, 27 Aug 2020 11:47:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6zRQ5N8OHP4Vp/hAwvgmu2ewc4Hzy7BR8yIBLx0Ej6g=; b=ckT0Mgwv7G0nd5dtYrbPCCOc0PfGGe0GOc6YQs7zI+3d2eWcZw+kGYDpOTBMNql+0D d0Li23X9/Klo2nsRCj8E53FRWtk219AOQP4IeybHMleXh3sydZImt0ZzG/w0R0JiRQZ7 c8P9tmxyr8WA3pv/8yqHGuGtQt9RHL26xY/0BtQ+xmQM4vK3gtduDjxEWzZHCXiHJROQ JBqsrHk6h5PpR1WQIojNBJlMwg/KVH9c9z5/sXa5u/vk7lnxJEgIsntC+iS0vYBNFX/q wKTInRXSgD3qPYt2CuL1yzQYsCtmrrRE7R/M9WFLF+to6BSukHVtuQfpBIfSczXWhVuz dOdA== X-Gm-Message-State: AOAM532mE2Dz3aRiALbkg0vmpo7VrPGj5RSpA51Qsd2vn4DeiZnflaQE 4u8+fIgaOoTBauHDcSko0j1epUk7R2UHcHKCxGnSd5KedH0= X-Google-Smtp-Source: ABdhPJysPRAslzMlibW1zqBZYJNf4qw8bRGoMWsZSZTSCsBVL1QyqD+kK7SRw57O5Rp+dCR18IYIORCwZhe130WC40o= X-Received: by 2002:a92:c889:: with SMTP id w9mr3097698ilo.177.1598554023982; Thu, 27 Aug 2020 11:47:03 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Alistair Francis Date: Thu, 27 Aug 2020 11:36:18 -0700 Message-ID: Subject: Re: [PATCH v2 10/18] RISC-V: Hard float support for 32-bit To: "Maciej W. Rozycki" Cc: Alistair Francis , GNU C Library Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Aug 2020 18:47:05 -0000 On Sun, Jul 12, 2020 at 3:10 PM Maciej W. Rozycki wrote: > > On Sun, 12 Jul 2020, Alistair Francis wrote: > > > > I don't think there is a simple alternative available for RV32 that would > > > be worth keeping together with the RV64 variant. Did I miss anything? > > > What instruction(s) do you have in mind? > > > > Something like this for the generic RISC-V lround: > > > > long int > > __lroundf (float x) > > { > > #if __WORDSIZE == 64 > > int64_t res; > > asm ("fcvt.l.s %0, %1, rmm" : "=r" (res) : "f" (x)); > > #else > > int32_t res; > > asm ("fcvt.w.s %0, %1, rmm" : "=r" (res) : "f" (x)); > > #endif > > return res; > > } > > > > I'm not sure if it's clearer, but for some of the more complex > > functions (roundeven for example) it might be easier. > > > > It also means if there is a bug fixed in one it'll end up fixed for both. > > Ah, you mean the `float' to `long int' conversion functions, necessarily > ABI-specific due to the changing width of the latter data type. Well, I > meant the operations involving FCVT.L.D/FCVT.D.L. I can see no RISC-V > solution for them that would surpass the generic implementation. > > As far as your example above is concerned if we decided to merge the > files at all, I would reduce it to: > > #if __WORDSIZE == 64 > # define OP "fcvt.l.s" > #elif __WORDSIZE == 32 > # define OP "fcvt.w.s" > #else > # error Unsupported > #endif > > long int > __lroundf (float x) > { > long int res; > asm (OP "\t%0, %1, rmm" : "=r" (res) : "f" (x)); > return res; > } > > or suchlike (I'm not sure if there's any gain here from `res' having an > explicit-width data type). Likewise with the rest. Sounds good. Now that RV32 support is in I have some patches for this, I'll send them out soon. Alistair > > Maciej