public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "law at redhat dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/34723] Summing variable should be initialized to the first member before the loop Date: Mon, 16 Dec 2013 18:08:00 -0000 [thread overview] Message-ID: <bug-34723-4-vFjMIbcoeU@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-34723-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34723 --- Comment #3 from Jeffrey A. Law <law at redhat dot com> --- Andrew, no. 4.2 didn't muck things up at all. The 4.2 code is clearly better (unless you're vectorizing the loop). What's happening is the IV code changes the loop structure enough that VRP2/DOM2 are unable to peel the iteration off the loop. In gcc-4.2, just prior to VRP2 we have: # BLOCK 2 freq:1000 # PRED: ENTRY [100.0%] (fallthru,exec) # SUCC: 3 [100.0%] (fallthru,exec) # BLOCK 3 freq:10000 # PRED: 3 [90.0%] (dfs_back,true,exec) 2 [100.0%] (fallthru,exec) # ivtmp.43_3 = PHI <ivtmp.43_5(3), 0(2)>; # val_16 = PHI <val_11(3), 0(2)>; <L0>:; D.1880_7 = MEM[symbol: table, index: ivtmp.43_3]{table[i]}; D.1881_8 = (unsigned char) D.1880_7; val.1_9 = (unsigned char) val_16; D.1883_10 = val.1_9 + D.1881_8; val_11 = (char) D.1883_10; ivtmp.43_5 = ivtmp.43_3 + 1; if (ivtmp.43_5 != 10) goto <L0>; else goto <L2>; # SUCC: 3 [90.0%] (dfs_back,true,exec) 4 [10.0%] (loop_exit,false,exec) VRP threads the jump through the backedge for the first iteration of the loop resulting in: # BLOCK 2 freq:1000 # PRED: ENTRY [100.0%] (fallthru,exec) goto <bb 5> (<L8>); # SUCC: 5 [100.0%] (fallthru,exec) # BLOCK 3 freq:9000 # PRED: 5 [100.0%] (fallthru) 3 [88.9%] (true,exec) # ivtmp.43_3 = PHI <ivtmp.43_23(5), ivtmp.43_5(3)>; # val_16 = PHI <val_22(5), val_11(3)>; <L0>:; D.1880_7 = MEM[symbol: table, index: ivtmp.43_3]{table[i]}; D.1881_8 = (unsigned char) D.1880_7; val.1_9 = (unsigned char) val_16; D.1883_10 = val.1_9 + D.1881_8; val_11 = (char) D.1883_10; ivtmp.43_5 = ivtmp.43_3 + 1; if (ivtmp.43_5 != 10) goto <L0>; else goto <L2>; # SUCC: 3 [88.9%] (true,exec) 4 [11.1%] (loop_exit,false,exec) # BLOCK 4 freq:1000 # PRED: 3 [11.1%] (loop_exit,false,exec) # val_2 = PHI <val_11(3)>; <L2>:; D.1884_13 = (int) val_2; return D.1884_13; # SUCC: EXIT [100.0%] # BLOCK 5 freq:1000 # PRED: 2 [100.0%] (fallthru,exec) # ivtmp.43_17 = PHI <0(2)>; # val_1 = PHI <0(2)>; <L8>:; D.1880_18 = MEM[symbol: table, index: ivtmp.43_17]{table[i]}; D.1881_19 = (unsigned char) D.1880_18; val.1_20 = (unsigned char) val_1; D.1883_21 = val.1_20 + D.1881_19; val_22 = (char) D.1883_21; ivtmp.43_23 = ivtmp.43_17 + 1; goto <bb 3> (<L0>); # SUCC: 3 [100.0%] (fallthru) Which will ultimately compile down to the efficient code where the first iteration has been peeled off. If we look at the trunk, DOM2/VRP2 have had the order changed, so if we look at the code immediately prior to DOM2 we have: <bb 2>: ivtmp.10_16 = (unsigned long) &table; _12 = (unsigned long) &MEM[(void *)&table + 10B]; goto <bb 4>; <bb 3>: <bb 4>: # val_14 = PHI <val_8(3), 0(2)> # ivtmp.10_18 = PHI <ivtmp.10_17(3), ivtmp.10_16(2)> _13 = (void *) ivtmp.10_18; _4 = MEM[base: _13, offset: 0B]; _5 = (unsigned char) _4; val.0_6 = (unsigned char) val_14; _7 = _5 + val.0_6; val_8 = (char) _7; ivtmp.10_17 = ivtmp.10_18 + 1; if (ivtmp.10_17 != _12) goto <bb 3>; else goto <bb 5>; Note how the test to go back to the top of the loop has changed. It's no longer testing a simple integer counter, which threading handled nicely. Instead it's a more complex test involving two objects. And neither DOM2 nor VRP2 are able to untangle it to get the code we want. ISTM this should have a regression marker and attached to the jump threading meta-bug. _
next prev parent reply other threads:[~2013-12-16 18:08 UTC|newest] Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-34723-4@http.gcc.gnu.org/bugzilla/> 2013-12-13 9:15 ` ubizjak at gmail dot com 2013-12-16 18:08 ` law at redhat dot com [this message] 2013-12-16 18:25 ` [Bug tree-optimization/34723] [4.7/4.8/4.9 Regression] " ubizjak at gmail dot com 2013-12-17 5:49 ` law at redhat dot com 2013-12-17 20:11 ` law at redhat dot com 2014-03-31 9:08 ` rguenth at gcc dot gnu.org 2014-06-12 13:49 ` [Bug tree-optimization/34723] [4.7/4.8/4.9/4.10 " rguenth at gcc dot gnu.org 2014-12-19 13:35 ` [Bug tree-optimization/34723] [4.8/4.9/5 " jakub at gcc dot gnu.org 2015-06-23 8:28 ` [Bug tree-optimization/34723] [4.8/4.9/5/6 " rguenth at gcc dot gnu.org 2015-06-26 20:02 ` [Bug tree-optimization/34723] [4.9/5/6 " jakub at gcc dot gnu.org 2015-06-26 20:32 ` jakub at gcc dot gnu.org 2021-05-14 9:45 ` [Bug tree-optimization/34723] [9/10/11/12 " jakub at gcc dot gnu.org 2021-06-01 8:04 ` rguenth at gcc dot gnu.org 2021-11-24 5:45 ` pinskia at gcc dot gnu.org 2022-05-27 9:33 ` [Bug tree-optimization/34723] [10/11/12/13 " rguenth at gcc dot gnu.org 2022-06-28 10:29 ` jakub at gcc dot gnu.org 2023-07-07 10:28 ` [Bug tree-optimization/34723] [11/12/13/14 " rguenth at gcc dot gnu.org 2008-01-09 9:39 [Bug tree-optimization/34723] New: Summing ariable " ubizjak at gmail dot com 2008-01-09 9:56 ` [Bug tree-optimization/34723] Summing variable " pinskia at gcc dot gnu dot 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-34723-4-vFjMIbcoeU@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).