public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/87987] Missed optimization with ranged-for loop on a constexpr array
       [not found] <bug-87987-4@http.gcc.gnu.org/bugzilla/>
@ 2021-12-17  4:22 ` pinskia at gcc dot gnu.org
  2021-12-17  4:27 ` pinskia at gcc dot gnu.org
  2021-12-17  4:29 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-17  4:22 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87987

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
          Component|c++                         |tree-optimization

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

* [Bug tree-optimization/87987] Missed optimization with ranged-for loop on a constexpr array
       [not found] <bug-87987-4@http.gcc.gnu.org/bugzilla/>
  2021-12-17  4:22 ` [Bug tree-optimization/87987] Missed optimization with ranged-for loop on a constexpr array pinskia at gcc dot gnu.org
@ 2021-12-17  4:27 ` pinskia at gcc dot gnu.org
  2021-12-17  4:29 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-17  4:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87987

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So I think LLVM's unrolling notices the load will become constant and the whole
induction variable basically goes away for sum.

Even for this C code LLVM does the optimization:

static const int table[] = { 1,10,10, 1, 1,10, 1,10 , 1,10,10, 1, 1,10, 1,10 ,
1,10,10, 1, 1,10, 1,10 , 1,10,10, 1, 1,10, 1,10 };
int check1()
  {
    int sum = 1;
    for (unsigned long i = 0; i < sizeof(table)/sizeof(table[0]);i++)
      sum += table[i];
    return sum;
  }

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

* [Bug tree-optimization/87987] Missed optimization with ranged-for loop on a constexpr array
       [not found] <bug-87987-4@http.gcc.gnu.org/bugzilla/>
  2021-12-17  4:22 ` [Bug tree-optimization/87987] Missed optimization with ranged-for loop on a constexpr array pinskia at gcc dot gnu.org
  2021-12-17  4:27 ` pinskia at gcc dot gnu.org
@ 2021-12-17  4:29 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-17  4:29 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87987

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 87543.

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

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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-87987-4@http.gcc.gnu.org/bugzilla/>
2021-12-17  4:22 ` [Bug tree-optimization/87987] Missed optimization with ranged-for loop on a constexpr array pinskia at gcc dot gnu.org
2021-12-17  4:27 ` pinskia at gcc dot gnu.org
2021-12-17  4:29 ` 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).