public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99823] New: -funroll-all-loops bugs when using contexpr variable
@ 2021-03-30  4:42 ustcw0ng at mail dot ustc.edu.cn
  2021-03-30 13:06 ` [Bug c++/99823] " rguenth at gcc dot gnu.org
  2021-03-31  2:56 ` [Bug tree-optimization/99823] " ustcw0ng at mail dot ustc.edu.cn
  0 siblings, 2 replies; 3+ messages in thread
From: ustcw0ng at mail dot ustc.edu.cn @ 2021-03-30  4:42 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99823
           Summary: -funroll-all-loops bugs when using contexpr variable
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ustcw0ng at mail dot ustc.edu.cn
  Target Milestone: ---

Created attachment 50483
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50483&action=edit
constexpr.cpp && unroll.cpp

-funroll-all-loops indicates "Unroll all loops, even if their number of
iterations is uncertain when the loop is entered. This usually makes programs
run more slowly.". But in the following example constexpr.cpp can never turn to
unroll.cpp, even if number of iterations is certain due to constexpr.

compiler flag: -O3 -std=c++2a -DNDEBUG -funroll-all-loops

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

* [Bug c++/99823] -funroll-all-loops bugs when using contexpr variable
  2021-03-30  4:42 [Bug c++/99823] New: -funroll-all-loops bugs when using contexpr variable ustcw0ng at mail dot ustc.edu.cn
@ 2021-03-30 13:06 ` rguenth at gcc dot gnu.org
  2021-03-31  2:56 ` [Bug tree-optimization/99823] " ustcw0ng at mail dot ustc.edu.cn
  1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-03-30 13:06 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-03-30
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
-funroll-all-loops applies to the RTL loop unroller, the GIMPLE level
concludes:

Estimating sizes for loop 1
 BB: 3, after_exit: 0
  size:   1 _1 = MEM[(int (*<T9564>) (int) &)__for_begin_21];
  size:   5 _13 = _1 (s_20);
  size:   1 __for_begin_14 = __for_begin_21 + 8;
  size:   1 ivtmp_4 = ivtmp_11 - 1;
   Induction variable computation will be folded away.
  size:   2 if (ivtmp_4 != 0)
   Exit condition will be eliminated in peeled copies.
   Exit condition will be eliminated in last copy.
   Constant conditional.
 BB: 5, after_exit: 1
size: 10-3, last_iteration: 10-3
  Loop size: 10
  Estimated size after unrolling: 14
Not unrolling loop 1: contains call and code would grow.

so it concludes unrolling isn't profitable (but it would turn indirect into
direct calls).

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

* [Bug tree-optimization/99823] -funroll-all-loops bugs when using contexpr variable
  2021-03-30  4:42 [Bug c++/99823] New: -funroll-all-loops bugs when using contexpr variable ustcw0ng at mail dot ustc.edu.cn
  2021-03-30 13:06 ` [Bug c++/99823] " rguenth at gcc dot gnu.org
@ 2021-03-31  2:56 ` ustcw0ng at mail dot ustc.edu.cn
  1 sibling, 0 replies; 3+ messages in thread
From: ustcw0ng at mail dot ustc.edu.cn @ 2021-03-31  2:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from apple <ustcw0ng at mail dot ustc.edu.cn> ---
(In reply to Richard Biener from comment #1)
> -funroll-all-loops applies to the RTL loop unroller, the GIMPLE level
> concludes:
> 
> Estimating sizes for loop 1
>  BB: 3, after_exit: 0
>   size:   1 _1 = MEM[(int (*<T9564>) (int) &)__for_begin_21];
>   size:   5 _13 = _1 (s_20);
>   size:   1 __for_begin_14 = __for_begin_21 + 8;
>   size:   1 ivtmp_4 = ivtmp_11 - 1;
>    Induction variable computation will be folded away.
>   size:   2 if (ivtmp_4 != 0)
>    Exit condition will be eliminated in peeled copies.
>    Exit condition will be eliminated in last copy.
>    Constant conditional.
>  BB: 5, after_exit: 1
> size: 10-3, last_iteration: 10-3
>   Loop size: 10
>   Estimated size after unrolling: 14
> Not unrolling loop 1: contains call and code would grow.
> 
> so it concludes unrolling isn't profitable (but it would turn indirect into
> direct calls).

Anyway, I should mention here that clang can unroll it without this flag and
turn out constexpr.cpp equal to unroll.cpp. And you can try to insert "#pragma
GCC unroll 2“ the loop finally unrolled, even in this pragma, constexpr.cpp is
not equal to unroll.cpp. But this is technically another issue

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

end of thread, other threads:[~2021-03-31  2:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-30  4:42 [Bug c++/99823] New: -funroll-all-loops bugs when using contexpr variable ustcw0ng at mail dot ustc.edu.cn
2021-03-30 13:06 ` [Bug c++/99823] " rguenth at gcc dot gnu.org
2021-03-31  2:56 ` [Bug tree-optimization/99823] " ustcw0ng at mail dot ustc.edu.cn

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