This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: #pragma GCC unroll support
- From: Bernhard Reutner-Fischer <rep dot dot dot nop at gmail dot com>
- To: Marek Polacek <polacek at redhat dot com>,Mike Stump <mikestump at comcast dot net>
- Cc: Joseph Myers <joseph at codesourcery dot com>,Richard Biener <richard dot guenther at gmail dot com>,gcc-patches Patches <gcc-patches at gcc dot gnu dot org>,Jason Merrill <jason at redhat dot com>
- Date: Fri, 30 Jan 2015 21:52:17 +0100
- Subject: Re: #pragma GCC unroll support
- Authentication-results: sourceware.org; auth=none
- References: <0596944B-9DDC-4299-8CBC-9B6EB06BEF68 at comcast dot net> <CAFiYyc2nFsKByeNc70nDJj=eL3e33Biz+M-fkBNC1J69=LwYHg at mail dot gmail dot com> <9FE5AF27-EB8A-4CC3-A345-A69C2BFD8F30 at comcast dot net> <alpine dot DEB dot 2 dot 10 dot 1501292310061 dot 14904 at digraph dot polyomino dot org dot uk> <EFDD2A4E-F705-45E9-B9B1-8F22A3670B35 at comcast dot net> <alpine dot DEB dot 2 dot 10 dot 1501301535370 dot 29419 at digraph dot polyomino dot org dot uk> <E298CABB-4D38-4009-8876-3EB7B48D4AE5 at comcast dot net> <20150130163616 dot GJ4074 at redhat dot com>
On January 30, 2015 5:36:16 PM GMT+01:00, Marek Polacek <polacek@redhat.com> wrote:
>On Fri, Jan 30, 2015 at 08:27:06AM -0800, Mike Stump wrote:
>> >
>> +static bool
>> +c_parse_pragma_ivdep (c_parser *parser)
>> +{
>> + c_parser_consume_pragma (parser);
>> + c_parser_skip_to_pragma_eol (parser);
>> + return true;
>> +}
>> +
>> +static unsigned short
>> +c_parser_pragma_unroll (c_parser *parser)
>> +{
>
>Note that these functions are missing comments.
+++ testsuite/c-c++-common/unroll-1.c (working copy)
@@ -0,0 +1,40 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdisable-tree-cunroll -fdump-rtl-loop2_unroll -fdump-tree-cunrolli-details" } */
+
+void bar(int);
+
+int j;
+
+void test1()
+{
+ unsigned long m = j;
+ unsigned long i;
+
+ /* { dg-final { scan-tree-dump "loop with 9 iterations completely unrolled" "cunrolli" } } */
+ #pragma GCC unroll 8
+ for (unsigned long i = 1; i <= 8; ++i)
+ bar(i);
+
+ /* { dg-final { scan-rtl-dump "21:\(5|11\): note: loop unrolled 7 times" "loop2_unroll" } } */
+ #pragma GCC unroll 8
+ for (unsigned long i = 1; i <= j; ++i)
+ bar(i);
+
+ /* { dg-final { scan-rtl-dump "26:\(5|11\): note: loop unrolled 3 times" "loop2_unroll" } } */
+ #pragma GCC unroll 7
+ for (unsigned long i = 1; i <= j; ++i)
+ bar(i);
This last test is still puzzling me.
I want to unroll 7 times, we make that 6, so be it.
Now we compute a power-of-2 trip count AFAIU, which gives us 4. And due to the odd dumping off-by-one thing we end up seeing 3 in the dump as per above. Correct?
>From a user perspective this is not very intuitive, IMHO :)