From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by sourceware.org (Postfix) with ESMTPS id 8C37D3858424 for ; Mon, 27 May 2024 12:54:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8C37D3858424 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8C37D3858424 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716814475; cv=none; b=HlVGtTkwIBu46AA+zZaCoJRk9V7mO3UCdX03iHMAXl9xl3UKr+dsc9ziAY16xmodHXsCK8Iqqt1++EyG/fMxJJH/mLjkvYNpscbCIJsQXO4qQz/ahLT5Oqc/7BlQS1vmm8AlOlzuBejlEsX8/G1FB3FzFVVa0N4Zn9i3uiJ2qgo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716814475; c=relaxed/simple; bh=8sy/223dxvus0GBFSC9VUqYDfEObH6vQ1bDch4e/dT4=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=gynMzU7FbarEvkmQe4I/6xCZMZeGY9kfR1E3x2ytyGWIvGuDpLh75bVDUX/hcjD8NupCyWqyaspSYwnZXncbaOboTxGi/8izYSh8sJKNt6RgSqLhfbKRI/gbkXTzsjAt9eystX9A+T5tfczXjo+qiMxdFWnsFX+xXhSqbslCCuM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-529648cd69dso3212766e87.2 for ; Mon, 27 May 2024 05:54:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716814472; x=1717419272; darn=gcc.gnu.org; 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=3v2jOongLP3mWXaEcCB1DJKg9UIKh/QOVvXdH/wYFX4=; b=jqGQBRwEchqc5Oz4Lodr2Iiv2NzTRvYIMrYzItPZU7KjTCkabZMKwJ5eSYKo+bxSC8 d25oZZ39t30s3OE8pka8gV5Xg61mLXNOeQPixOVtcdWHpy3UsNDnVDZfj/yGh1Pbb2jN lJnic9Zno1N92ckvse5B/iOxXxsyUvytYaP7VIAYcJjLZ5V3tyNl+odnFa4X/g/gyjgz 0KVkzFTgC3P8iEe3iq7RgiUx2pvH9j1kXB71JXSb+ZB6OyQOkL9dbp2f+o7Tc+rXHddZ bXV/5lcmIJ0+weRNJljSVyPK7XKsh67R9kT02m6uw3ViFcjYJ44ypXS9zpwMZKDEYnr1 gr/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716814472; x=1717419272; 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=3v2jOongLP3mWXaEcCB1DJKg9UIKh/QOVvXdH/wYFX4=; b=JR92hPZB2sm3tOrsif8sidlYSou4kJp8z5+sI0A4xRS2pv/xD6K7e9QLIWzmoG9z7V YVuI+1rVk5deyyiOvLjCWTinqR0t9ax1tJbNvzynjLl6Xfaf6U1aouhxlvUXbFCwb6lt tgrdR3PoYhlJQi7DrvLhlHwmr3qr/zsouG1qLupZdBwj8NbK7uGDAttXelZIcREvhpXL UIcz+pm3d7J6oSEkJdxX6JQGkuBN4h9cBI5MGnrzWeElnykcLhDoOS8iAim8/7ClLpIx DX046tC37PpxmRohyjoVotAnjUYtAE4U1cNG3vtDoK3xRpZ27tK9I9CxvM88WKk84Sys 290w== X-Gm-Message-State: AOJu0YxWmuLHCYVMEvufG9PVu2W4WqDKK81agOwRz95+njblFheEW8gG rJlEEw6nQkYOU+mwMwncwGxLvj+/ni4Jhc7MwLcF7jsOI3YGGL13/n/Px/HEF8aemau11EakaJk TfT4b7ZVN8gnTCiLAs5TY0utdQ3wJSg== X-Google-Smtp-Source: AGHT+IHP8QrLjwCCyyf0vjCULzFrDvz9wzfFLbP8nMErrE1dbvrW9nNs50kR68pqT+OFSaRS0IKvS0O2DTnAUtfTe24= X-Received: by 2002:a19:ad4a:0:b0:529:4864:9c17 with SMTP id 2adb3069b0e04-52967463e64mr7376316e87.57.1716814471749; Mon, 27 May 2024 05:54:31 -0700 (PDT) MIME-Version: 1.0 References: <936073f2-dfd4-4650-9b28-b905d97be477@linux.ibm.com> In-Reply-To: <936073f2-dfd4-4650-9b28-b905d97be477@linux.ibm.com> From: Richard Biener Date: Mon, 27 May 2024 14:54:20 +0200 Message-ID: Subject: Re: [PATCHv3] Optab: add isfinite_optab for __builtin_isfinite To: HAO CHEN GUI Cc: gcc-patches , Segher Boessenkool , David , "Kewen.Lin" , Peter Bergner , Andrew Pinski Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,KAM_SHORT,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: On Mon, May 27, 2024 at 11:37=E2=80=AFAM HAO CHEN GUI wrote: > > Hi, > This patch adds an optab for __builtin_isfinite. The finite check can b= e > implemented on rs6000 by a single instruction. It needs an optab to be > expanded to the certain sequence of instructions. > > The subsequent patches will implement the expand on rs6000. > > Compared to previous version, the main change is to specify acceptable > modes for the optab. > https://gcc.gnu.org/pipermail/gcc-patches/2024-May/652170.html > > Bootstrapped and tested on x86 and powerpc64-linux BE and LE with no > regressions. Is this OK for trunk? > > Thanks > Gui Haochen > > ChangeLog > optab: Add isfinite_optab for isfinite builtin > > gcc/ > * builtins.cc (interclass_mathfn_icode): Set optab to isfinite_op= tab > for isfinite builtin. > * optabs.def (isfinite_optab): New. > * doc/md.texi (isfinite): Document. > > > patch.diff > diff --git a/gcc/builtins.cc b/gcc/builtins.cc > index f8d94c4b435..b8432f84020 100644 > --- a/gcc/builtins.cc > +++ b/gcc/builtins.cc > @@ -2459,8 +2459,9 @@ interclass_mathfn_icode (tree arg, tree fndecl) > errno_set =3D true; builtin_optab =3D ilogb_optab; break; > CASE_FLT_FN (BUILT_IN_ISINF): > builtin_optab =3D isinf_optab; break; > - case BUILT_IN_ISNORMAL: > case BUILT_IN_ISFINITE: > + builtin_optab =3D isfinite_optab; break; > + case BUILT_IN_ISNORMAL: > CASE_FLT_FN (BUILT_IN_FINITE): > case BUILT_IN_FINITED32: > case BUILT_IN_FINITED64: > diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi > index 5730bda80dc..67407fad37d 100644 > --- a/gcc/doc/md.texi > +++ b/gcc/doc/md.texi > @@ -8557,6 +8557,15 @@ operand 2, greater than operand 2 or is unordered = with operand 2. > > This pattern is not allowed to @code{FAIL}. > > +@cindex @code{isfinite@var{m}2} instruction pattern > +@item @samp{isfinite@var{m}2} > +Set operand 0 to nonzero if operand 1 is a finite @code{SFmode}, > +@code{DFmode}, or @code{TFmode} floating point number and to 0 It should probably say scalar floating-point mode? But what about the resu= lt? Is any integer mode OK? That's esp. important if this might be used on vector modes. > +otherwise. > + > +If this pattern @code{FAIL}, a call to the library function > +@code{isfinite} is used. Or it's otherwise inline expanded? Or does this imply targets have to make sure to implement the pattern when isfinite is not available in libc/libm? I suggest to leave this sentence out, we usually only say when a pattern may _not_ FAIL (and usually FAILing isn't different from not providing a pattern). > @end table > > @end ifset > diff --git a/gcc/optabs.def b/gcc/optabs.def > index ad14f9328b9..dcd77315c2a 100644 > --- a/gcc/optabs.def > +++ b/gcc/optabs.def > @@ -352,6 +352,7 @@ OPTAB_D (fmod_optab, "fmod$a3") > OPTAB_D (hypot_optab, "hypot$a3") > OPTAB_D (ilogb_optab, "ilogb$a2") > OPTAB_D (isinf_optab, "isinf$a2") > +OPTAB_D (isfinite_optab, "isfinite$a2") > OPTAB_D (issignaling_optab, "issignaling$a2") > OPTAB_D (ldexp_optab, "ldexp$a3") > OPTAB_D (log10_optab, "log10$a2")