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/109154] [13 regression] jump threading de-optimizes nested floating point comparisons Date: Thu, 13 Apr 2023 16:54:19 +0000 [thread overview] Message-ID: <bug-109154-4-FGD1i0KKev@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-109154-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109154 --- Comment #45 from Jakub Jelinek <jakub at gcc dot gnu.org> --- So, would void foo (float *f, float d, float e) { if (e >= 2.0f && e <= 4.0f) ; else __builtin_unreachable (); for (int i = 0; i < 1024; i++) { float a = f[i]; f[i] = (a < 0.0f ? 1.0f : 1.0f - a * d) * (a < e ? 1.0f : 0.0f); } } be a better reduction on what's going on? From the frange/threading POV, when e is in [2.0f, 4.0f] range, if a < 0.0f, we know that a < e is also true, so there is no point in testing that at runtime. So I think what threadfull1 does is right and desirable if the final code actually performs those comparisons and uses conditional jumps. The only thing is that it is harmful for vectorization and maybe for predicated code. Therefore, for scalar code at least without massive ARM style conditional execution, the above is better emitted as if (a < 0.0f) tmp = 1.0f; else { tmp = (1.0f - a * d) * (a < e ? 1.0f : 0.0f); } or even if (a < 0.0f) tmp = 1.0f; else if (a < e) tmp = 1.0f - a * d; else tmp = 0.0f; f[i] = tmp; Thus, could we effectively try to undo it at ifcvt time on loops for vectorization only, or during vectorization or something similar? As ifcvt then turns the IMHO desirable if (a_16 >= 0.0) goto <bb 5>; [59.00%] else goto <bb 11>; [41.00%] <bb 11> [local count: 435831803]: goto <bb 7>; [100.00%] <bb 5> [local count: 627172605]: _7 = a_16 * d_17(D); iftmp.0_18 = 1.0e+0 - _7; if (e_13(D) > a_16) goto <bb 12>; [20.00%] else goto <bb 6>; [80.00%] <bb 12> [local count: 125434523]: goto <bb 7>; [100.00%] <bb 6> [local count: 501738082]: <bb 7> [local count: 1063004410]: # prephitmp_26 = PHI <iftmp.0_18(12), 0.0(6), 1.0e+0(11)> (ok, the 2 empty forwarders are unlikely useful) into: _7 = a_16 * d_17(D); iftmp.0_18 = 1.0e+0 - _7; _21 = a_16 >= 0.0; _10 = e_13(D) > a_16; _9 = _10 & _21; _27 = e_13(D) <= a_16; _28 = _21 & _27; _ifc__43 = _9 ? iftmp.0_18 : 0.0; _ifc__44 = _28 ? 0.0 : _ifc__43; _45 = a_16 < 0.0; prephitmp_26 = _45 ? 1.0e+0 : _ifc__44; Now, perhaps if ifcvt used ranger, it could figure out that a_16 < 0.0 implies e_13(D) > a_16 and do something smarter with it. Or maybe just try to do smarter ifcvt just based on the original CFG. The pre-ifcvt code was a_16 < 0.0f ? 1.0f : a_16 < e_13 ? 1.0f - a_16 * d_17 : 0.0f so when ifcvt puts everything together, make it _7 = a_16 * d_17(D); iftmp.0_18 = 1.0e+0 - _7; _27 = e_13(D) > a_16; _28 = a_16 < 0.0; _ifc__43 = _27 ? iftmp.0_18 : 0.0f; prephitmp_26 = _28 ? 1.0f : _ifc__43; ?
next prev parent reply other threads:[~2023-04-13 16:54 UTC|newest] Thread overview: 84+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-03-16 11:57 [Bug tree-optimization/109154] New: [13 regression] aarch64 -mcpu=neoverse-v1 microbude performance regression pgodbole at nvidia dot com 2023-03-16 13:11 ` [Bug tree-optimization/109154] " tnfchris at gcc dot gnu.org 2023-03-16 14:58 ` [Bug target/109154] " rguenth at gcc dot gnu.org 2023-03-16 17:03 ` tnfchris at gcc dot gnu.org 2023-03-16 17:03 ` [Bug target/109154] [13 regression] jump threading with de-optimizes nested floating point comparisons tnfchris at gcc dot gnu.org 2023-03-22 10:20 ` [Bug tree-optimization/109154] [13 regression] jump threading " aldyh at gcc dot gnu.org 2023-03-22 10:29 ` avieira at gcc dot gnu.org 2023-03-22 12:22 ` rguenth at gcc dot gnu.org 2023-03-22 12:42 ` rguenth at gcc dot gnu.org 2023-03-22 13:11 ` aldyh at gcc dot gnu.org 2023-03-22 14:00 ` amacleod at redhat dot com 2023-03-22 14:39 ` aldyh at gcc dot gnu.org 2023-03-27 8:09 ` rguenth at gcc dot gnu.org 2023-03-27 9:30 ` jakub at gcc dot gnu.org 2023-03-27 9:42 ` aldyh at gcc dot gnu.org 2023-03-27 9:44 ` jakub at gcc dot gnu.org 2023-03-27 10:18 ` rguenther at suse dot de 2023-03-27 10:40 ` jakub at gcc dot gnu.org 2023-03-27 10:44 ` jakub at gcc dot gnu.org 2023-03-27 10:54 ` rguenth at gcc dot gnu.org 2023-03-27 10:56 ` jakub at gcc dot gnu.org 2023-03-27 10:59 ` jakub at gcc dot gnu.org 2023-03-27 17:07 ` jakub at gcc dot gnu.org 2023-03-28 8:33 ` rguenth at gcc dot gnu.org 2023-03-28 9:01 ` cvs-commit at gcc dot gnu.org 2023-03-28 10:07 ` tnfchris at gcc dot gnu.org 2023-03-28 10:08 ` tnfchris at gcc dot gnu.org 2023-03-28 12:18 ` jakub at gcc dot gnu.org 2023-03-28 12:25 ` rguenth at gcc dot gnu.org 2023-03-28 12:42 ` rguenth at gcc dot gnu.org 2023-03-28 13:19 ` rguenth at gcc dot gnu.org 2023-03-28 13:44 ` jakub at gcc dot gnu.org 2023-03-28 13:52 ` jakub at gcc dot gnu.org 2023-03-28 15:31 ` amacleod at redhat dot com 2023-03-28 15:40 ` jakub at gcc dot gnu.org 2023-03-28 15:53 ` amacleod at redhat dot com 2023-03-28 15:58 ` jakub at gcc dot gnu.org 2023-03-28 16:42 ` amacleod at redhat dot com 2023-03-28 21:12 ` amacleod at redhat dot com 2023-03-29 6:33 ` cvs-commit at gcc dot gnu.org 2023-03-29 6:38 ` rguenth at gcc dot gnu.org 2023-03-29 22:41 ` amacleod at redhat dot com 2023-03-30 18:17 ` cvs-commit at gcc dot gnu.org 2023-04-05 9:28 ` tnfchris at gcc dot gnu.org 2023-04-05 9:34 ` ktkachov at gcc dot gnu.org 2023-04-11 9:36 ` rguenth at gcc dot gnu.org 2023-04-13 16:54 ` jakub at gcc dot gnu.org [this message] 2023-04-13 17:25 ` rguenther at suse dot de 2023-04-13 17:29 ` jakub at gcc dot gnu.org 2023-04-14 18:10 ` jakub at gcc dot gnu.org 2023-04-14 18:14 ` jakub at gcc dot gnu.org 2023-04-14 18:22 ` jakub at gcc dot gnu.org 2023-04-14 19:09 ` jakub at gcc dot gnu.org 2023-04-15 10:10 ` cvs-commit at gcc dot gnu.org 2023-04-17 11:07 ` jakub at gcc dot gnu.org 2023-04-25 18:32 ` [Bug tree-optimization/109154] [13/14 " tnfchris at gcc dot gnu.org 2023-04-25 18:34 ` jakub at gcc dot gnu.org 2023-04-26 6:58 ` rguenth at gcc dot gnu.org 2023-04-26 9:43 ` tnfchris at gcc dot gnu.org 2023-04-26 10:07 ` jakub at gcc dot gnu.org 2023-07-07 18:10 ` tnfchris at gcc dot gnu.org 2023-07-10 7:15 ` rguenth at gcc dot gnu.org 2023-07-10 10:33 ` tnfchris at gcc dot gnu.org 2023-07-10 10:46 ` rguenth at gcc dot gnu.org 2023-07-10 11:02 ` tnfchris at gcc dot gnu.org 2023-07-10 11:27 ` rguenth at gcc dot gnu.org 2023-07-10 11:49 ` tnfchris at gcc dot gnu.org 2023-07-14 10:22 ` cvs-commit at gcc dot gnu.org 2023-07-14 10:22 ` cvs-commit at gcc dot gnu.org 2023-07-27 9:25 ` rguenth at gcc dot gnu.org 2023-10-02 10:53 ` cvs-commit at gcc dot gnu.org 2023-10-18 8:54 ` cvs-commit at gcc dot gnu.org 2023-10-18 8:54 ` cvs-commit at gcc dot gnu.org 2023-10-18 8:54 ` cvs-commit at gcc dot gnu.org 2023-10-18 8:55 ` cvs-commit at gcc dot gnu.org 2023-11-09 14:20 ` cvs-commit at gcc dot gnu.org 2023-11-09 14:20 ` cvs-commit at gcc dot gnu.org 2023-11-09 14:20 ` cvs-commit at gcc dot gnu.org 2023-11-09 14:20 ` cvs-commit at gcc dot gnu.org 2023-11-09 14:20 ` cvs-commit at gcc dot gnu.org 2023-11-09 14:20 ` cvs-commit at gcc dot gnu.org 2023-11-09 14:20 ` cvs-commit at gcc dot gnu.org 2023-11-09 14:20 ` cvs-commit at gcc dot gnu.org 2023-11-09 14:25 ` [Bug tree-optimization/109154] [13 " tnfchris 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-109154-4-FGD1i0KKev@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).