From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7D0DB38582A1; Thu, 1 Feb 2024 15:10:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7D0DB38582A1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1706800256; bh=CVXkKFI4uqOWj4BKAh0RWmILB3aswQ2BJZhDQYeXT2w=; h=From:To:Subject:Date:In-Reply-To:References:From; b=SmltTSr6AcyDIlJoGzX7MNAjXdPytM6Z4isPIQScP+h9AjsZ0a0wg+SdN3wqLMt1S qYq2YSxXknInkPihqhTtT+MYDdy6Cs8e/ScYvmkiu+n/Eaxyns9sYKkuj4jSkiprhH hTAHL+w+Ow+A1YxbHRnoQl/Hn7BFgeBdtWsYjlF8= From: "tnfchris at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/51492] vectorizer does not support saturated arithmetic patterns Date: Thu, 01 Feb 2024 15:10:55 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 4.6.2 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: tnfchris at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D51492 --- Comment #12 from Tamar Christina --- (In reply to JuzheZhong from comment #11) > Hi, Tamar. >=20 > We are interested in supporting saturating and rounding. Awesome! >=20 > We may need to support scalar first. >=20 > Do you have any suggestions ? >=20 > Or you are already working on it? No, atm we're not, it's on the backlog but haven't gotten to it so feel fre= e to do so. The general conclusion of the thread is that we should introduce new intern= al functions in the mid-end for this (also see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D112600 for some other scalar examples). So e.g. we'd have IFN_SAT_ADD etc and new optabs. recognizing this on scal= ar you'll then automatically get autovect. What I would do is create non-direct-optab IFNs. as in, have a default fallback for architectures that don't have the optab implemented, and those that do use the optab. I think we should be able to do better here in general even for scalar if we know the operation is supposed to saturate like https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D112600 shows. This also simplifies optimizations because every target then has the same GIMPLE representation for these operations. The only outstanding thing is where to do this. We obviously have to do so before vectorization but some of the saturation idioms require phi-opts https://godbolt.org/z/9oWP5vqee but others can't be done in phi-opts, those probably fit in match.pd or forwardprop. Any suggestions of where to best add the detection richi? >=20 > Thanks.=