From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2B3F13858D39; Mon, 1 Aug 2022 13:27:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2B3F13858D39 From: "aldyh at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/24021] VRP does not work with floating points Date: Mon, 01 Aug 2022 13:27:04 +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.1.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: aldyh at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: aldyh 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Aug 2022 13:27:05 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D24021 --- Comment #25 from Aldy Hernandez --- Adding some notes here as I work through this PR... Even with floating aware VRP, we won't be able to do much because SCEV (whi= ch ranger and VRP use) does not work with non-integers. At EVRP time we see: double BG_SplineLength () { double i; double lastPoint; : goto ; [INV] : if (i_3 =3D=3D 0.0) goto ; [INV] else goto ; [INV] : : # lastPoint_1 =3D PHI i_10 =3D i_3 + 1.00000001490116119384765625e-1; : # lastPoint_2 =3D PHI # i_3 =3D PHI <1.00000000000000002081668171172168513294309377670288085938e-2(2), i_10(5)> if (i_3 <=3D 1.0e+0) goto ; [INV] else goto ; [INV] : return lastPoint_2; } On the 6->3 edge we know that i_3 is [-INF, 1.0], so even adding a range-op entry for the PLUS_EXPR, we'd know that i_3 is [-INF, 1.1], which is not en= ough to fold the i_3 =3D=3D 0.0 conditional. If you convert this testcase to in= teger and turn off SCEV (and unrolling and FRE, etc), you'll notice that VRP does= n't do much here (in either legacy nor ranger mode). We would need SCEV to give us [1.0, 1.1] in order to fold the i_3 =3D=3D 0.0 conditional. For that matter, if I hack SCEV to give us the expected end points, I can get evrp to fold the conditional. I think once VRP is FP awa= re, we can close this PR because this particular testcase is SCEV specific. So= for this particular testcase, perhaps we could open a SCEV+FP PR? As an aside, the second conditional will not be folded by VRP (legacy or ranger), even with SCEV, even if you convert the above testcase to integer...it's either gotten later by unrolling+FRE for FP, or cddce for integers. What I'm trying to say is that even with FP VRP, which we'll have shortly, = the first conditional won't be folded because SCEV doesn't do floats, and the second one won't be, because it's not VRP's job.=