From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by sourceware.org (Postfix) with ESMTP id DDE52384EF49 for ; Tue, 6 Dec 2022 12:21:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DDE52384EF49 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kernel.crashing.org Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 2B6CKIJZ007311; Tue, 6 Dec 2022 06:20:18 -0600 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 2B6CKHUj007310; Tue, 6 Dec 2022 06:20:17 -0600 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Tue, 6 Dec 2022 06:20:17 -0600 From: Segher Boessenkool To: Richard Biener Cc: HAO CHEN GUI , gcc-patches , David , "Kewen.Lin" , Peter Bergner Subject: Re: [PATCH] Add a new conversion for conditional ternary set into ifcvt [PR106536] Message-ID: <20221206122017.GY25951@gate.crashing.org> References: <75fb4899-ceb2-e6a9-0dd4-577de9a8b976@linux.ibm.com> <937d6047-e6e0-cbc9-2ed1-13a221f5a361@linux.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=no 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! On Thu, Nov 24, 2022 at 11:24:15AM +0100, Richard Biener wrote: > On Thu, Nov 24, 2022 at 8:25 AM HAO CHEN GUI wrote: > > 在 2022/11/24 4:06, Richard Biener 写道: > > > Wouldn't we usually either add an optab or try to recog a canonical > > > RTL form instead of adding a new target hook for things like this? > > > > Thanks so much for your comments. Please let me make it clear. > > > > Do you mean we should create an optab for "setb" pattern (the nested > > if-then-else insn) and detect candidate insns in ifcvt pass? Then > > generate the insn with the new optab? > > Yes, that would be one way to do it. Another way would be to > generate a (to be defined) canonical form of such instruction and > see whether it can be recognized (whether there's a define_insn > for it). But these insns are most useful when they come up "naturally", so we really have to recognise many formulations of it separately. The machine insn setb x,BF returns: { -1, if BF.0 is set { 1, if BF.1 is set { 0, otherwise This "otherwise" includes when a floating point comparison returned "unordered" (BF.3, set if an operand was NaN), and BF.2 ("equal"). If the comparison was only three-way (integer or fast-math) it is natural to test for equality first (given we always have exactly one of the first three BF bits set in that case!) > Note that were just things that came into my mind here, I'm not too > familiar with how we handle such situations but at least I'm not > aware of dozens of target hooks to handle instruction availability. In similar cases I never could up with anything that worked better than recognising all possible patterns, unfortunately. We can do a predicate for that though, there is no need to write it out all over the place :-) Segher