From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by sourceware.org (Postfix) with ESMTPS id 5825E3851C3D for ; Thu, 7 Jan 2021 06:53:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5825E3851C3D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=vrull.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=philipp.tomsich@vrull.eu Received: by mail-wr1-x42a.google.com with SMTP id t16so4552557wra.3 for ; Wed, 06 Jan 2021 22:53:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull-eu.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=K9uePk5dQpxb+xIYpykdO6li1zIJx2q6FzwChrm23xM=; b=QYF6JxUYkURPnrt0oM5zMWYIzbdfACQUtxWQD0q0t+1tPxVnVyGV2RmWC81I44Zyl5 Fu/e5e0dVtLaMzpa4yKyUvmzpYsKLLh9E+U9v0fku55QwaZs2UQVu0xC3K+aekoZjM9i eFWsXVrVh8gKuwqfYWZkVPbw8qJtKpP7E20N6/FNIBHupmMgdipdR4I4NgmgSdCkyzuf V6jDT3h1gFPpx+8WLpHYILLY6rXT+E8gDLx2BjfqukMU7IlBYdlot7blNmlneoWksx2L o59gfanVksvik/FrNc9d8OcThr7QNDw5BbE7wvV/RvtYvwKitAIw5QyaSXE/nhY2V3wP uAug== 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=K9uePk5dQpxb+xIYpykdO6li1zIJx2q6FzwChrm23xM=; b=g0FCcC0YOaJ2vlpV+0WN06W+50tKh2JkXp55DcjR0Jvy1Dm8OoTsUt+SweKEEwFzdx SE+OwyPBCuf0C9rbVNQhRqMl5LwoB3qWFJ3+IIGp/hr4+yxlcROGIHx7WEoVXOmzINC8 I6SQqzRqJxIprxj1PmP26zLDHwlhO3/QMQvYje+IkwSIqp3ZA/ZcAD5shUNZ1HVXNNMp ghgjjoyacvx2yzRPtgVpTpBV4KUl1pgvqxXbvoA2WHWkD7Gz3T5y3F9tEvUc7sjp2HQY VI0H6Rr0MHJbhxvaOUv65UBMrpOatUqc+S1eCBLRNBLTnpaFsA8tMeICshtyH0SYMpZ5 YB6w== X-Gm-Message-State: AOAM531juFkqqzDTe0a5KoDLnBa1fDBeVgHTKxUzLLqYkZhRxi57NR54 ikJZ4Iymx6VyPya4gPmubtnAYmADWP0KNcpf3/rm2Q== X-Google-Smtp-Source: ABdhPJxzqXYMczbTc7MYr+y3WISJzJ96PfeBZryRwxplfgUplFCgIyEa337gO4HptBz95dls/u6F9v6rGCorJyUHPjo= X-Received: by 2002:a05:6000:85:: with SMTP id m5mr7328550wrx.378.1610002421386; Wed, 06 Jan 2021 22:53:41 -0800 (PST) MIME-Version: 1.0 References: <20210106173303.27988-1-philipp.tomsich@vrull.eu> In-Reply-To: From: Philipp Tomsich Date: Thu, 7 Jan 2021 07:53:30 +0100 Message-ID: Subject: Re: [PATCH] RISC-V: Zihintpause: add __builtin_riscv_pause To: Kito Cheng Cc: Andrew Waterman , Kito Cheng , Jim Wilson , GCC Patches X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, HTML_MESSAGE, 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jan 2021 06:53:45 -0000 Kito: We had originally considered to guard this with a -march, but decided against it eventually: this instruction will be (among other cases) used in the cpu_relax() of the Linux kernel. For cases like that, we should consider this the baseline (i.e. either there's no pause=E2=80=94in which case, the encoded fence will not h= urt=E2=80=94or the Zihintpause extension)... but it all maps back to a single builtin-call. Note that the Zihintfence will be enabled for all (also older) targets, as the insn is supported there as well (as a fence that doesn't do anything)... so guarding it will not really change the behavior. That said, I'll get going on an v2 that will include the -march guard (and we can still turn things back to how they are today). Thanks, Philipp. On Thu, 7 Jan 2021 at 06:42, Kito Cheng wrote: > Hi Andrew: > > It's safe to execute on old machine, but it is still a new extension not > included on baseline ISA, so I still prefer having -march to guard that, > and then we can track that in the ELF attribute to see what extensions an= d > which version are used in the executable / object files. > > > On Thu, Jan 7, 2021 at 11:51 AM Andrew Waterman > wrote: > >> I've got a contrary opinion: >> >> Since HINTs are guaranteed to execute as no-ops--e.g., this one is >> just a FENCE instruction, which is already a mandatory part of the >> base ISA--they don't _need_ to be called out as separate extensions in >> the toolchain. >> >> Although there's nothing fundamentally wrong with Kito's suggestion, >> it seems like an extra hoop to jump through without commensurate >> benefit. I see no reason to restrict the use of __builtin_pause, >> since all RISC-V implementations, including old ones, are required to >> support it. And, of course, that's the reason we encoded it this way >> :) >> >> >> On Wed, Jan 6, 2021 at 7:35 PM Kito Cheng wrote: >> > >> > Hi Philipp: >> > >> > Could you add zihintpause to -march parser and guard that on the >> > pattern and builtin like zifencei[1-2]? >> > >> > And could you sent a PR to >> > https://github.com/riscv/riscv-c-api-doc/blob/master/riscv-c-api.md to >> > mention __builtin_riscv_pause? >> > >> > Thanks! >> > >> > [1] march parser change: >> > >> https://github.com/gcc-mirror/gcc/commit/b03be74bad08c382da47e048007a78f= a3fb4ef49 >> > [2] Default version for ext.: >> > >> https://github.com/gcc-mirror/gcc/commit/4b81528241ca682025d92558ff6aeec= 91dafdca8 >> > >> > >> > > --- /dev/null >> > > +++ b/gcc/testsuite/gcc.target/riscv/builtin_pause.c >> > > @@ -0,0 +1,10 @@ >> > > +/* { dg-do compile } */ >> > > +/* { dg-options "-O2" } */ >> > > + >> > > +void test_pause() >> > >> > I would suggest you change the function name in the testcase, >> > otherwise the scan-assembler test will always pass even if you didn't >> > generate "pause" instruction. >> > >> > >> > > +{ >> > > + __builtin_riscv_pause (); >> > > +} >> > > + >> > > +/* { dg-final { scan-assembler "pause" } } */ >> > > + >> > > -- >> > > 2.18.4 >> > > >> >