On January 30, 2015 5:36:16 PM GMT+01:00, Marek Polacek <pola...@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 :)


Reply via email to