Beispiel #1
0
unsigned int
tree_ssa_prefetch_arrays (struct loops *loops)
{
    unsigned i;
    struct loop *loop;
    bool unrolled = false;
    int todo_flags = 0;

    if (!HAVE_prefetch
            /* It is possible to ask compiler for say -mtune=i486 -march=pentium4.
            -mtune=i486 causes us having PREFETCH_BLOCK 0, since this is part
             of processor costs and i486 does not have prefetch, but
             -march=pentium4 causes HAVE_prefetch to be true.  Ugh.  */
            || PREFETCH_BLOCK == 0)
        return 0;

    initialize_original_copy_tables ();

    if (!built_in_decls[BUILT_IN_PREFETCH])
    {
        tree type = build_function_type (void_type_node,
                                         tree_cons (NULL_TREE,
                                                 const_ptr_type_node,
                                                 NULL_TREE));
        tree decl = lang_hooks.builtin_function ("__builtin_prefetch", type,
                    BUILT_IN_PREFETCH, BUILT_IN_NORMAL,
                    NULL, NULL_TREE);
        DECL_IS_NOVOPS (decl) = true;
        built_in_decls[BUILT_IN_PREFETCH] = decl;
    }

    /* We assume that size of cache line is a power of two, so verify this
       here.  */
    gcc_assert ((PREFETCH_BLOCK & (PREFETCH_BLOCK - 1)) == 0);

    for (i = loops->num - 1; i > 0; i--)
    {
        loop = loops->parray[i];

        if (dump_file && (dump_flags & TDF_DETAILS))
            fprintf (dump_file, "Processing loop %d:\n", loop->num);

        if (loop)
            unrolled |= loop_prefetch_arrays (loops, loop);

        if (dump_file && (dump_flags & TDF_DETAILS))
            fprintf (dump_file, "\n\n");
    }

    if (unrolled)
    {
        scev_reset ();
        todo_flags |= TODO_cleanup_cfg;
    }

    free_original_copy_tables ();
    return todo_flags;
}
Beispiel #2
0
unsigned int
tree_ssa_prefetch_arrays (void)
{
  loop_iterator li;
  struct loop *loop;
  bool unrolled = false;
  int todo_flags = 0;

  if (!HAVE_prefetch
      /* It is possible to ask compiler for say -mtune=i486 -march=pentium4.
	 -mtune=i486 causes us having PREFETCH_BLOCK 0, since this is part
	 of processor costs and i486 does not have prefetch, but
	 -march=pentium4 causes HAVE_prefetch to be true.  Ugh.  */
      || PREFETCH_BLOCK == 0)
    return 0;

  if (dump_file && (dump_flags & TDF_DETAILS))
    {
      fprintf (dump_file, "Prefetching parameters:\n");
      fprintf (dump_file, "    simultaneous prefetches: %d\n",
	       SIMULTANEOUS_PREFETCHES);
      fprintf (dump_file, "    prefetch latency: %d\n", PREFETCH_LATENCY);
      fprintf (dump_file, "    prefetch block size: %d\n", PREFETCH_BLOCK);
      fprintf (dump_file, "    L1 cache size: %d lines, %d kB\n",
	       L1_CACHE_SIZE_BYTES / L1_CACHE_LINE_SIZE, L1_CACHE_SIZE);
      fprintf (dump_file, "    L1 cache line size: %d\n", L1_CACHE_LINE_SIZE);
      fprintf (dump_file, "    L2 cache size: %d kB\n", L2_CACHE_SIZE);
      fprintf (dump_file, "\n");
    }

  initialize_original_copy_tables ();

  if (!built_in_decls[BUILT_IN_PREFETCH])
    {
      tree type = build_function_type (void_type_node,
				       tree_cons (NULL_TREE,
						  const_ptr_type_node,
						  NULL_TREE));
      tree decl = add_builtin_function ("__builtin_prefetch", type,
					BUILT_IN_PREFETCH, BUILT_IN_NORMAL,
					NULL, NULL_TREE);
      DECL_IS_NOVOPS (decl) = true;
      built_in_decls[BUILT_IN_PREFETCH] = decl;
    }

  /* We assume that size of cache line is a power of two, so verify this
     here.  */
  gcc_assert ((PREFETCH_BLOCK & (PREFETCH_BLOCK - 1)) == 0);

  FOR_EACH_LOOP (li, loop, LI_FROM_INNERMOST)
    {
      if (dump_file && (dump_flags & TDF_DETAILS))
	fprintf (dump_file, "Processing loop %d:\n", loop->num);

      unrolled |= loop_prefetch_arrays (loop);

      if (dump_file && (dump_flags & TDF_DETAILS))
	fprintf (dump_file, "\n\n");
    }

  if (unrolled)
    {
      scev_reset ();
      todo_flags |= TODO_cleanup_cfg;
    }

  free_original_copy_tables ();
  return todo_flags;
}