public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/109008] [13 Regression] Wrong code in scipy package since r13-3926-gd4c2f1d376da6f Date: Wed, 08 Mar 2023 09:36:12 +0000 [thread overview] Message-ID: <bug-109008-4-VhNbr4I0Dk@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-109008-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109008 --- Comment #28 from Jakub Jelinek <jakub at gcc dot gnu.org> --- On IRC we've discussed this and I believe a possible fix could be before we do: return float_binary_op_range_finish (minus.fold_range (r, type, lhs, op2), r, type, lhs); etc. artificially extend the lhs range by 1ulp or .5ulp or whatever works in each direction (on a copy) and then just let it do its job. But I want to fixup above patch first, so that we have something to compare to. From --- gcc/range-op-float.cc.jj 2023-03-07 21:20:49.885225381 +0100 +++ gcc/range-op-float.cc 2023-03-08 09:13:10.063608296 +0100 @@ -2319,9 +2319,15 @@ float_range_extend (tree type, frange &r u = m; } gcc_checking_assert (l + 1 == u); +fprintf (stderr, "--\n"); +SET_REAL_EXP (&t, l); +real_arithmetic (&w, PLUS_EXPR, &v, &t); +real_convert (&w, mode, &w); +test (w, type, lhs, op2); SET_REAL_EXP (&t, u); real_arithmetic (&w, PLUS_EXPR, &v, &t); real_convert (&w, mode, &w); +test (w, type, lhs, op2); REAL_VALUE_TYPE lastw = w; for (int i = SIGNIFICAND_BITS - 2; i >= SIGNIFICAND_BITS - 2 - p; i--) { @@ -2338,7 +2344,10 @@ float_range_extend (tree type, frange &r lastw = w; } w = lastw; +fprintf (stderr, "---\n"); +test (w, type, lhs, op2); frange_nextafter (mode, w, upper ? dconstninf : dconstinf); +test (w, type, lhs, op2); goto update; } @@ -2367,7 +2376,15 @@ public: REAL_VALUE_TYPE res; frange_arithmetic (PLUS_EXPR, type, res, r, op2.lower_bound (), dconstinf); - return !real_less (&res, &lhs.lower_bound ()); +bool ret = !real_less (&res, &lhs.lower_bound ()); +char br[60], bop2[60], bres[60], blhs[60]; +real_to_hexadecimal (br, &r, sizeof (br), 0, 1); +real_to_hexadecimal (bop2, &op2.lower_bound (), sizeof (bop2), 0, 1); +real_to_hexadecimal (bres, &res, sizeof (bres), 0, 1); +real_to_hexadecimal (blhs, &lhs.lower_bound (), sizeof (blhs), 0, 1); +fprintf (stderr, "float_range_extend1 %s + %s = %s %s %s\n", br, bop2, bres, ret ? ">=" : "<", blhs); +return ret; +// return !real_less (&res, &lhs.lower_bound ()); }); float_range_extend (type, r, lhs, op2, true, [] (REAL_VALUE_TYPE &r, tree type, @@ -2376,7 +2393,15 @@ public: REAL_VALUE_TYPE res; frange_arithmetic (PLUS_EXPR, type, res, r, op2.upper_bound (), dconstninf); - return !real_less (&lhs.upper_bound (), &res); +bool ret = !real_less (&lhs.upper_bound (), &res); +char br[60], bop2[60], bres[60], blhs[60]; +real_to_hexadecimal (br, &r, sizeof (br), 0, 1); +real_to_hexadecimal (bop2, &op2.lower_bound (), sizeof (bop2), 0, 1); +real_to_hexadecimal (bres, &res, sizeof (bres), 0, 1); +real_to_hexadecimal (blhs, &lhs.lower_bound (), sizeof (blhs), 0, 1); +fprintf (stderr, "float_range_extend2 %s + %s = %s %s %s\n", br, bop2, bres, ret ? "<=" : ">", blhs); +return ret; +// return !real_less (&lhs.upper_bound (), &res); }); return true; } debugging hacks seems it is the loop that tries to narrow the mantissa bits that is wrong, as immediately before it the l and u values seem correct: float_range_extend1 -0x0.8p-53 + 0x0.8p+1 = 0x0.8p+1 >= 0x0.8p+1 float_range_extend1 -0x0.8p-52 + 0x0.8p+1 = 0x0.fffffffffffff8p+0 < 0x0.8p+1 where the first is for l where test passes and u doesn't (and the right answer here is -0x0.8p-53).
next prev parent reply other threads:[~2023-03-08 9:36 UTC|newest] Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-03-03 12:08 [Bug tree-optimization/109008] New: [13 Regression ]Maybe wrong " marxin at gcc dot gnu.org 2023-03-03 12:11 ` [Bug tree-optimization/109008] [13 Regression] Maybe " rguenth at gcc dot gnu.org 2023-03-03 12:14 ` rguenth at gcc dot gnu.org 2023-03-03 12:18 ` [Bug tree-optimization/109008] [13 Regression] Wrong " rguenth at gcc dot gnu.org 2023-03-03 12:24 ` rguenth at gcc dot gnu.org 2023-03-03 12:27 ` rguenth at gcc dot gnu.org 2023-03-03 12:31 ` jakub at gcc dot gnu.org 2023-03-03 12:54 ` jakub at gcc dot gnu.org 2023-03-03 13:03 ` rguenth at gcc dot gnu.org 2023-03-03 13:10 ` rguenth at gcc dot gnu.org 2023-03-03 13:14 ` rguenth at gcc dot gnu.org 2023-03-03 13:34 ` jakub at gcc dot gnu.org 2023-03-03 13:50 ` rguenth at gcc dot gnu.org 2023-03-03 14:28 ` jakub at gcc dot gnu.org 2023-03-07 12:06 ` rguenth at gcc dot gnu.org 2023-03-07 12:12 ` jakub at gcc dot gnu.org 2023-03-07 12:20 ` jakub at gcc dot gnu.org 2023-03-07 12:23 ` rguenth at gcc dot gnu.org 2023-03-07 12:25 ` rguenth at gcc dot gnu.org 2023-03-07 13:16 ` jakub at gcc dot gnu.org 2023-03-07 13:18 ` rguenth at gcc dot gnu.org 2023-03-07 13:29 ` rguenth at gcc dot gnu.org 2023-03-07 13:58 ` rguenth at gcc dot gnu.org 2023-03-07 14:10 ` rguenth at gcc dot gnu.org 2023-03-07 18:52 ` jakub at gcc dot gnu.org 2023-03-07 19:39 ` jakub at gcc dot gnu.org 2023-03-07 20:49 ` jakub at gcc dot gnu.org 2023-03-08 9:26 ` aldyh at gcc dot gnu.org 2023-03-08 9:29 ` aldyh at gcc dot gnu.org 2023-03-08 9:36 ` jakub at gcc dot gnu.org [this message] 2023-03-08 10:09 ` aldyh at gcc dot gnu.org 2023-03-08 11:29 ` jakub at gcc dot gnu.org 2023-03-08 11:30 ` jakub at gcc dot gnu.org 2023-03-08 14:51 ` jakub at gcc dot gnu.org 2023-03-08 14:52 ` jakub at gcc dot gnu.org 2023-03-08 15:07 ` jakub at gcc dot gnu.org 2023-03-08 15:54 ` jakub at gcc dot gnu.org 2023-03-08 16:37 ` jakub at gcc dot gnu.org 2023-03-08 18:56 ` jakub at gcc dot gnu.org 2023-03-08 20:02 ` jakub at gcc dot gnu.org 2023-03-09 8:52 ` cvs-commit at gcc dot gnu.org 2023-03-09 10:24 ` rguenth at gcc dot gnu.org 2023-03-09 11:06 ` jakub at gcc dot gnu.org 2023-03-09 11:12 ` marxin at gcc dot gnu.org 2023-03-09 11:50 ` jakub at gcc dot gnu.org 2023-03-09 12:34 ` rguenth at gcc dot gnu.org 2023-03-09 12:56 ` jakub at gcc dot gnu.org 2023-03-09 13:03 ` jakub at gcc dot gnu.org 2023-03-09 13:25 ` jakub at gcc dot gnu.org 2023-03-10 9:08 ` cvs-commit at gcc dot gnu.org 2023-03-10 11:41 ` cvs-commit at gcc dot gnu.org 2023-03-22 9:07 ` cvs-commit at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-109008-4-VhNbr4I0Dk@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).