public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "olegendo at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/58122] loops are not evaluated at compile time if loop count > 17 Date: Sun, 11 Aug 2013 18:00:00 -0000 [thread overview] Message-ID: <bug-58122-4-w67QOEImf9@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-58122-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58122 --- Comment #3 from Oleg Endo <olegendo at gcc dot gnu.org> --- Looking at the tree dump (-fdump-tree-all -fdump-tree-all-details), it seems that this is related to loop unrolling (dump file *t.cunroll) and induction variable optimization. If the number of iterations is small enough the loop gets unrolled and then the calculations on 'sum' are folded away. For this one: int test2 (void) { int sum = 0; for (int x = 0; x < 5; x++) sum += x; return sum; } t.cunroll shows: ;; Function int test2() (_Z5test2v, funcdef_no=0, decl_uid=1593, symbol_order=0) int test2() () { int x; int sum; <bb 2>: return 10; } However, with this one: int test2 (void) { int sum = 0; for (int x = 0; x < 6; x++) sum += x; return sum; } The unrolled result is: int test2() () { int x; int sum; unsigned int ivtmp_2; unsigned int ivtmp_14; unsigned int ivtmp_20; unsigned int ivtmp_26; unsigned int ivtmp_32; unsigned int ivtmp_38; <bb 2>: sum_12 = 0; x_13 = 1; ivtmp_14 = 5; sum_18 = sum_12 + x_13; x_19 = x_13 + 1; ivtmp_20 = ivtmp_14 + 4294967295; sum_24 = sum_18 + x_19; x_25 = x_19 + 1; ivtmp_26 = ivtmp_20 + 4294967295; sum_30 = sum_24 + x_25; x_31 = x_25 + 1; ivtmp_32 = ivtmp_26 + 4294967295; sum_36 = sum_30 + x_31; x_37 = x_31 + 1; ivtmp_38 = ivtmp_32 + 4294967295; sum_3 = sum_36 + x_37; x_4 = x_37 + 1; ivtmp_2 = ivtmp_38 + 4294967295; return sum_3; }
next prev parent reply other threads:[~2013-08-11 18:00 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-08-11 11:13 [Bug tree-optimization/58122] New: " olegendo at gcc dot gnu.org 2013-08-11 11:17 ` [Bug tree-optimization/58122] " olegendo at gcc dot gnu.org 2013-08-11 16:51 ` anthony.foiani at gmail dot com 2013-08-11 18:00 ` olegendo at gcc dot gnu.org [this message] 2014-07-31 18:09 ` olegendo at gcc dot gnu.org 2021-12-17 7:58 ` 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-58122-4-w67QOEImf9@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).