From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A86EE385842B; Thu, 8 Feb 2024 10:31:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A86EE385842B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1707388271; bh=MVjr1utTx3PzJX6OPLAQrSLsuhYMDVgIHFFJsz5LUDU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=lpAIHE37sX1a76GSg+goVUyEJoHfexBtx0cnLaHgvgIKGPjrQCUN/2J1Ewp9hIY9a lFLFJnCB91Pso1h2oMLBwQUTacl1VYRSMbbOck7WykZQ3/qhVIR4MzMpl2yzWjMArD W+dCIsmPZkHP0hjR0mj+NtGITXJkhpLYjH1g99Aw= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/102580] Failure to optimize signed division to unsigned division when dividend can't be negative Date: Thu, 08 Feb 2024 10:31:11 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: jakub 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: 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=3D102580 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |aldyh at gcc dot gnu.org, | |amacleod at redhat dot com, | |jakub at gcc dot gnu.org --- Comment #5 from Jakub Jelinek --- To be precise, expand_expr_divmod uses get_range_pos_neg for that during expansion (unless we'd e.g. somehow noted it in some very late pass before expansion that the division ought to be expanded both ways and cost compare= d), and get_range_pos_neg uses the global range of SSA_NAME only. In order to optimize #c0 we'd need to query range with the use stmt and enabling ranger= in the pass (that is possible in some pass before expansion, but doing it duri= ng expansion (which would be useful to other spots too, say .*_OVERFLOW expans= ion) would need to deal with some basic blocks already converted into RTL and ot= hers still at GIMPLE).=