On 6 March 2015 at 02:31, Sandra Loosemore <san...@codesourcery.com> wrote:
> On 03/05/2015 04:12 PM, Mike Stump wrote:
>>
>>
>> Ping?
>>
>
> Just commenting on the documentation part:
[]

and a few coding style nits:

+++ b/gcc/c-family/c-pragma.c
@@ -1459,6 +1459,10 @@ init_pragma (void)
     cpp_register_deferred_pragma (parse_in, "GCC", "ivdep",
PRAGMA_IVDEP, false,
                                  false);

+  if (!flag_preprocess_only)
+    cpp_register_deferred_pragma (parse_in, "GCC", "unroll",
PRAGMA_UNROLL, false,
+                                 false);
+

overlong line (also for the IVDEP above)

+++ b/gcc/c/c-parser.c
+static void c_parser_while_statement (c_parser *, bool, unsigned short);
+static void c_parser_do_statement (c_parser *, bool, unsigned short);
+static void c_parser_for_statement (c_parser *, bool, unsigned short);

since we're now a C++ app I would have added a default for the
unsigned short unroll of = 0
Same for
finish_while_stmt_cond, finish_do_stmt, finish_for_cond et al.

In cp_parser_range_for() i take it you remember there is a //TODO
I am attaching an unroll-5.C which might show that this does not seem
to be implemented yet, IIUC

gcc/loop-unroll.c::decide_unrolling()
I'd put the "if (loop->unroll == 1) {continue}" earlier in the
FOR_EACH_LOOP body (we're C++ nowadays) but maybe our optimizers are
good enough to do that anyway (but i fear we're not up to that?).

I did not see c/c++ tests for both !DIR$ UNROLL and !DIR$ IVDEP, fwiw.
You seem to handle both placements proper, though.
cheers,
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-rtl-loop2_unroll -fdump-tree-cunrolli-details" } */

#include <string>
#include <vector>

void bar(int);
int j;

void test1() {
  unsigned long m = j;
  const std::string s("abcdefgh");
  const std::vector<int> v = {7, 6, 5, 4, 3, 2, 1, 0};
  const std::size_t v_sz = 8;

  // { dg-final { scan-tree-dump "18:\[0-9\]*: note: loop turned into non-loop" "cunrolli" } }
  #pragma GCC unroll sizeof("abcdefgh") * 4
  for (auto ch : s)
    bar(ch);

  // { dg-final { scan-tree-dump "23:\[0-9\]*: note: loop turned into non-loop" "cunrolli" } }
  #pragma GCC unroll v_sz
  for (auto i : v)
    bar(i);

  // { dg-final { scan-tree-dump "28:\[0-9\]*: note: loop turned into non-loop" "cunrolli" } }
  #pragma GCC unroll 99
  for (auto i : v)
    bar(i);
}
// { dg-final { scan-rtl-dump-not "Unable to prove that the loop iterates constant times" "loop2_unroll" } }
// { dg-final { cleanup-tree-dump "cunrolli" } }
// { dg-final { cleanup-rtl-dump "loop2_unroll" } }

Reply via email to