Bug 58717 - [4.8 Regression] SCEV final value replacement no longer triggers
Summary: [4.8 Regression] SCEV final value replacement no longer triggers
Status: RESOLVED DUPLICATE of bug 57511
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: 4.8.2
Assignee: Not yet assigned to anyone
URL: http://stackoverflow.com/q/19350097/9...
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-13 22:35 UTC by masoud_mxm
Modified: 2013-10-14 07:13 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-10-14 00:00:00


Attachments
Two .cpp source code (866 bytes, application/zip)
2013-10-13 22:35 UTC, masoud_mxm
Details

Note You need to log in before you can comment on or make changes to this bug.
Description masoud_mxm 2013-10-13 22:35:30 UTC
Created attachment 30997 [details]
Two .cpp source code

It seems newer versions of gcc (4.8+) don't pre-calculate functions for constant inputs (Asked the issue here: http://stackoverflow.com/q/19350097/952747). Two source codes attached.


unsigned long long s(unsigned long long n)
{
    auto s = 0ULL;
    for (auto i = 0ULL; i < n; i++)
        s += i;
    return s;
}

const auto N = 1000000000ULL;

auto x = s(N); // It computes in run-time and dose NOT compute in compile-time!
Comment 1 masoud_mxm 2013-10-13 22:46:44 UTC
Comment on attachment 30997 [details]
Two .cpp source code

Tests are made in MinGW/32bit.
Comment 2 Ali Baharev 2013-10-13 23:00:00 UTC
This optimization is still available in 4.7.2. 

The issue is present on Linux 64 bit, 4.8.1 also.

http://coliru.stacked-crooked.com/a/9c22ce6c4b6f1a94
Comment 3 Jakub Jelinek 2013-10-14 07:05:03 UTC
sccp pass used to optimize:
unsigned long long
foo ()
{
  unsigned long long s = 0, i;
  for (i = 0; i < 1000000000ULL; i++)
    s += i;
  return s;
}
before r194578, but no longer does in 4.8.  In 4.9 this got fixed again, trying to bisect now.
Comment 4 Jakub Jelinek 2013-10-14 07:13:21 UTC
Ah, fixed by r202168.

*** This bug has been marked as a duplicate of bug 57511 ***