From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x32c.google.com (mail-ot1-x32c.google.com [IPv6:2607:f8b0:4864:20::32c]) by sourceware.org (Postfix) with ESMTPS id 2A63B3858D3C for ; Tue, 25 Jul 2023 13:23:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2A63B3858D3C Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-ot1-x32c.google.com with SMTP id 46e09a7af769-6bb0cadd372so3881911a34.0 for ; Tue, 25 Jul 2023 06:23:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1690291420; x=1690896220; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=npKdvD+mavL4DMVf5zzv0tYHd/2CXH5ob73LUmggQ/8=; b=fsMD8ulSPjGzkZn974i5Ou2geq2KYvNjJrr4cguu2baEvp3KPMT0SyF7msIqTGKNjD KQW5qZ3owX7n/ZiZCQTsm2+sF0oM7qIBbLzO4gdVkjIT5lXRV4uqUgG67I2fBlE7BpHZ aD+mRjveaEwOT4LTbK8WOhCfgd3S6TrWK4LZXEAb68LlfdG4GZpuU/2st3p45am2Y3CB IdyyFBkrXotGGFLvI3kz3NW5H5uOKbxCc+avPBm3bRsgWSwJrQH/h+R9LkhqxRQW/Ei3 wD4HXgxUR9yh2yH0V7eXUWt5a+pa6j8pcqtzSMiGRHd+Lcn/iSwkNuF43bhgCTzMu0b6 pEAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690291420; x=1690896220; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=npKdvD+mavL4DMVf5zzv0tYHd/2CXH5ob73LUmggQ/8=; b=KgbeimlsVDj1+vHlgg/9kSXzDzST3cxH8qdsgzxiDzJHOs21ChVCTI8T05HVNXtpqp z0N8MQW9KgbG/nAG83i+mCGey+xRUYQUyAN0FILhmJNoTRewcQ2qMUaAN4DlIZm90teQ q2LcmeT4FdXMHjs7UyIJgqxohReS2X71SjNMSai42E15SS2p8my/KgITaOE9Pwn837/b LMWrSq8smWg9ACIEsvjabAr0XDiJCTgF8h+V2lQKy6W1XfglBgy+SSgXeW05Cj4ZdyKp oktMD5sHCBD+9GgVVmHImtCAQI8QdAkcoIzQeHA5Z63eBh2uvi+V5ZZy5P+Hpz9uqsqj +SzA== X-Gm-Message-State: ABy/qLZ4Excj1+DxCFmGOq9mDBZVoF+IQHE7Wu0yZS5LB0F7DEiYWBPp JEoUXA9y+JA6ok4pUnDI2REFHjNFzuc8Z80YnhStvg== X-Google-Smtp-Source: APBJJlGU0dWV8slp18Nv9vmPVXUqoccL015j1xFTDOw37nRKh0rE4J1dVpC0qLa7U8AZnYN0IivtmiA1FNDPut77VY8= X-Received: by 2002:a9d:7319:0:b0:6b9:1ee7:5289 with SMTP id e25-20020a9d7319000000b006b91ee75289mr9907729otk.10.1690291420072; Tue, 25 Jul 2023 06:23:40 -0700 (PDT) MIME-Version: 1.0 References: <20230719032822.85817-1-pan2.li@intel.com> <20230725055156.595718-1-pan2.li@intel.com> In-Reply-To: From: Kito Cheng Date: Tue, 25 Jul 2023 21:23:28 +0800 Message-ID: Subject: Re: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding To: "Li, Pan2" Cc: Robin Dapp , "gcc-patches@gcc.gnu.org" , "juzhe.zhong@rivai.ai" , "Wang, Yanzhang" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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: Hi Robin: Give few more context about the design: The call fesetround could be any function in practice, and we never know if that function might use dynamic rounding mode floating point operation or not, also we don't know if it will be called fesetround or not. So that's why we want to restore before function call to make sure we don't break rounding mode for any inner function, also backup the frm after function call can handle the case if the inner function has changed global rounding mode. On Tue, Jul 25, 2023 at 7:53=E2=80=AFPM Li, Pan2 wrote: > > Thanks Robin. Let me share one example for the CALL scenario, considering= below code. > > external int fesetround(int rounding_mode); > > test_call_for_rm: > <- FRM X > vfadd RTZ (static) <- FRM RTZ > <- RESTORE FRM X > call fesetround RMM <- Change FRM to RMM during the cal= l > <- Backup the FRM= RMM > vfadd RUP (static) <- FRM RUP > <- Restore the F= RM to RMM > ret > > When emit at the insn call, we need to emit 2 insns, one restore before t= he call and one backup after call, to ensure 2 things. > > 1. The static FRM should not pollute the call. > 2. The updated FRM in the call will alive to the end of the cfun. > > Unfortunately, current mode switching cannot emit 2 insns as above, it mo= stly emits after. It become even worse when the call > is the last insn of the bb, we try to do some special handling in needed = function for this. > > And thank robin again for nits and cleanups, like previous/next_nonnote_n= ondebug_insn_bb. > > Pan > > -----Original Message----- > From: Robin Dapp > Sent: Tuesday, July 25, 2023 4:38 PM > To: Li, Pan2 ; gcc-patches@gcc.gnu.org > Cc: rdapp.gcc@gmail.com; juzhe.zhong@rivai.ai; kito.cheng@sifive.com; Wan= g, Yanzhang > Subject: Re: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynam= ic rounding > > Hi Pan, > > > Given we have a call, we would like to restore before call and then > > backup frm after call. Looks current mode switching cannot emit insn > > like that, it can only either emit insn before (mostly) or after > > (when NOTE_INSN_BASIC_BLOCK_P). Thus, we try to emit the one after > > call when needed as a specially handling here. > > Would you mind explaining a bit more here? As far as I know we can > perform necessary mode switching (including saving necessary > registers) directly after function entry and right before function > exit. Is this somehow too early or too late or cannot handle what > you want? > > The patch in itself makes sense (apart from some nits and possible > cleanups) but I'm still missing the bigger picture. For me it gets > more confusing with every patch to be honest :D > > Regards > Robin >