public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/58122] New: loops are not evaluated at compile time if loop count > 17
@ 2013-08-11 11:13 olegendo at gcc dot gnu.org
  2013-08-11 11:17 ` [Bug tree-optimization/58122] " olegendo at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: olegendo at gcc dot gnu.org @ 2013-08-11 11:13 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58122

            Bug ID: 58122
           Summary: loops are not evaluated at compile time if loop count
                    > 17
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: olegendo at gcc dot gnu.org

This one was originally reported here:
http://gcc.gnu.org/ml/gcc-help/2013-08/msg00124.html

The original example was:
#include <stdio.h>

template <typename T>
inline T const& max (T const& a, T const& b)
{
  return a < b ? b : a;
}

int main()
{
  long long unsigned sum = 0;

  for (int x = 1; x <= 100000000; x++)
    sum += max (x, x + 1);

  printf("%llu\n", sum);
}

It seems that GCC 4.7 was able to evaluate the loop at compile time and reduce
it to a constant value, but GCC 4.8 fails to do so.

I've also briefly checked with trunk rev 201282 and the problem seems to be
still there.  Here is a reduced test case:

int test (void)
{
  int sum = 0;
  for (int x = 0; x < 100; x++)
    sum += x;

  return sum;
}

I've checked this with an SH cross compiler setup, but I don't think it
matters.
The loops do get eliminated if the number of loop iterations is max. 17, for
both the reduced example and the originally reported case.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-12-17  7:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-11 11:13 [Bug tree-optimization/58122] New: loops are not evaluated at compile time if loop count > 17 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
2014-07-31 18:09 ` olegendo at gcc dot gnu.org
2021-12-17  7:58 ` pinskia at gcc dot gnu.org

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).