public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "amacleod at redhat dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/102705] [12 Regression] Dead Code Elimination Regression at -O3 since r12-2637-g145bc41dae7c7bfa093d61e77346f98e6a595a0e Date: Wed, 13 Oct 2021 19:25:10 +0000 [thread overview] Message-ID: <bug-102705-4-hMO2pNNjLz@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-102705-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102705 --- Comment #1 from Andrew Macleod <amacleod at redhat dot com> --- That impact of that patch on this PR is that it teaches range extraction that [0,1] % [5,5] is [0,1], unlike before which came up with [0,4] This in turn causes the thread1 pass to decide to thread something it didn't thread before. In the absence of thread1 making this decision (ie, before the patch), the next pass is VRP/VRpthread which ends up performing the thread anyway, but via different means, and ever so slightly different IL By the time we hit DCE3, the differences are very slight: (We know b.1_1 has a range of [0,1]) Original code where we get the optimization: _2 = 1 >> b.1_1; iftmp.0_10 = (char) _2; _3 = (int) iftmp.0_10; b = _3; _4 = iftmp.0_10 ^ 1; _5 = (int) _4; iftmp.6_22 = (short int) _5; _6 = (short int) iftmp.0_10; if (_6 == iftmp.6_22) goto <bb 4>; [49.37%] else goto <bb 5>; [50.63%] The next pass is forwprop3, and it reports: gimple_simplified to iftmp.6_22 = (short int) _4; gimple_simplified to if (0 != 0) I think it can see that with iftmp.0_10 having range [0, 1] that _4,_5 and iftmp.6_22 are therefore basically ~iftmp.0_10 Thus if can fold the condition as never being true. And turns this into : _2 = 1 >> b.1_1; iftmp.0_10 = (char) _2; _3 = (int) iftmp.0_10; b = _3; _4 = iftmp.0_10 ^ 1; _5 = (int) _4; iftmp.6_22 = (short int) _4; _6 = (short int) iftmp.0_10; Meanwhile, trunk threads earlier, and produces slightly different code . At DSE3 time it looks like: _2 = 1 >> b.1_1; iftmp.0_10 = (char) _2; b = _2; _4 = iftmp.0_10 ^ 1; _5 = (int) _4; iftmp.6_22 = (short int) _5; _6 = (short int) _2; if (_6 == iftmp.6_22) goto <bb 5>; [50.37%] else goto <bb 6>; [49.63%] So we have already skipped a few casts as use _2 more directly. The problem is that the next pass, forwprop3 does not like this new code, and does not perform the same fold, leaving the condition. And thus we never lose the call to foo(). again, _4,_5 and iftmp.6_22 would all be known to be ~iftmp.0_10, but it looks like forwprop no longer recognizes that _6 = (short int) _2 makes it equivalent to iftmp.0_10 ?
next prev parent reply other threads:[~2021-10-13 19:25 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-10-12 13:41 [Bug tree-optimization/102705] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) theodort at inf dot ethz.ch 2021-10-12 13:51 ` [Bug tree-optimization/102705] [12 Regression] Dead Code Elimination Regression at -O3 since r12-2637-g145bc41dae7c7bfa093d61e77346f98e6a595a0e marxin at gcc dot gnu.org 2021-10-13 6:22 ` rguenth at gcc dot gnu.org 2021-10-13 19:25 ` amacleod at redhat dot com [this message] 2022-01-19 9:18 ` rguenth at gcc dot gnu.org 2022-05-06 8:31 ` [Bug tree-optimization/102705] [12/13 " jakub at gcc dot gnu.org 2022-10-19 9:35 ` rguenth at gcc dot gnu.org 2023-05-08 12:22 ` [Bug tree-optimization/102705] [12/13/14 " rguenth at gcc dot gnu.org 2024-02-21 7:00 ` pinskia 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-102705-4-hMO2pNNjLz@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).