From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C2F083858D28; Mon, 30 Jan 2023 14:20:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C2F083858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675088450; bh=Ief5qXw5HSA+B1zFsgEHC0redqZZdiRS8X6kGjNRmuc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=G12vG3gAsA0oZ1fOMg38EmT2Eo+eDf67QFvEnxvBkG/RfXK9Eb5qeJJfMaqz9b3zV GQJtrEAdmQ30d30rhK3EEyS4SjmxlhDWNuXTJt8gRPzWTH3MenVslM4a2f1uHTGD1k CDMt048OUeH7FqbnLrfIAOc9WN2U9NzMBS4Iv3xo= 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: Mon, 30 Jan 2023 14:20:50 +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: cc 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 Tamar Christina changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |rguenth at gcc dot gnu.org, | |rsandifo at gcc dot gnu.org --- Comment #3 from Tamar Christina --- Right, so this is because in the expansion we don't have enough context to decide how to optimize the division. This optimization is only possible when the input is widened because you ne= ed an additional free bit so that the second addition can't overflow. The vectorizer has this context but since we didn't want a new IFN the cont= ext should instead be derivable in targetm.vectorize.can_special_div_by_const h= ook. So my proposal to fix this and keep targetm.vectorize.can_special_div_by_co= nst as a general divide optimization hook is to pass the actual `tree` operand0= as well to the hook such that the hook has a bit more context. I was hoping to use get_nonzero_bits to get what the actual range of the operand is. But it looks like for widening operations it still reports -1. So my suggestion is the backend should just check if the operand is a non-constant and the type of the operation being performed is matches the precision we require. Is this ok with you Richards? since I'll need both of you to approve.=