From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 881843858D33; Tue, 31 Jan 2023 11:58:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 881843858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675166288; bh=WWRdjmre7A1fKnLO8/qR5WApza1Y3up2TQ3HDFFvuU4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=mfmicRVb5Ke+yOncbYZExpB/n4PD+9qMCQ3g4djuAj0xVxjTZCrmPyAohnIeBc4r1 dH6K0WLPsjapka4FAfnxIopNMUqOszSt0fTIlrO+P7mnxn6iMQtJIeEGo7mf/BVnxh y77pp688pCrlp3Y8R4dZitCB02PNQgUfHrmZ48Io= From: "tnfchris at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/108583] [13 Regression] wrong code with vector division by uint16 at -O2 Date: Tue, 31 Jan 2023 11:58:07 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: tnfchris at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: tnfchris at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.0 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=3D108583 --- Comment #12 from Tamar Christina --- (In reply to rguenther@suse.de from comment #11) > On Tue, 31 Jan 2023, tnfchris at gcc dot gnu.org wrote: >=20 >=20 > I don't think passing in for example the tree operand 0 helps, the > target appearantly wants to not specialize by the constant divided by > but instead also by the number divided (of we already know its type). >=20 The target wants to specialize division by a specific constant. It just happens that there is an additional specialization when certain bits are kn= own to be free in operand0. > Do you plan to do SSA def pattern matching in the hook for this at > expand time? >=20 My intention was to only look if the DEF_STMT is a gimple assign, and then = the operands to it are half the precision of the result. This catches *w, *>> = and any other case. It doesn't need to know further up because it's harder to track non-zero bits across different math operations. and this is enough f= or the use case we're interested in. > As said, recognizing the special case and open-coding the full divison > in the vectorizer (or possibly even from RTL expansion) would be > another option here. open-coding in the vectorizer will require 4 new IFNs and 4 new optabs as it requires 4 different instructions. 2 for neon, 2 for SVE, which are semantically different as permutes work different across SVE and NEON. So = if you're happy with that I will do that. > (or possibly even from RTL expansion) would be another option here. I don't really follow this one. The open coding at expand time is what I was trying to do before. The issue is there's no longer a single statement if = we don't stop the vectorizer from decomposing it into shifts and multiplies. As long as the vectorizer does this decomposition there's not much to do at expand time. Additionally the number of widening operations after vectorization is large. So to semantically match them with the decomposed s= hift seems impossible.. But those are only my thoughts :) ultimately I'll do the approach you two w= ant. If you want me to revert to using IFNs I can do that.=