HomePhabricator

[OpenCL] Generate 'unroll.enable' metadata for __attribute__…

Authored by asavonic on Mar 20 2019, 9:43 AM.

Description

[OpenCL] Generate 'unroll.enable' metadata for attribute((opencl_unroll_hint))

Summary:
[OpenCL] Generate 'unroll.enable' metadata for attribute((opencl_unroll_hint))

For both !{!"llvm.loop.unroll.enable"} and !{!"llvm.loop.unroll.full"} the unroller
will try to fully unroll a loop unless the trip count is not known at compile time.
In that case for '.full' metadata no unrolling will be processed, while for '.enable'
the loop will be partially unrolled with a heuristically chosen unroll factor.

See: docs/LanguageExtensions.rst

From https://www.khronos.org/registry/OpenCL/sdk/2.0/docs/man/xhtml/attributes-loopUnroll.html

__attribute__((opencl_unroll_hint))
for (int i=0; i<2; i++)
{
    ...
}

In the example above, the compiler will determine how much to unroll the loop.

Before the patch for attribute((opencl_unroll_hint)) was generated metadata
!{!"llvm.loop.unroll.full"}, which limits ability of loop unroller to decide, how
much to unroll the loop.

Reviewers: Anastasia, yaxunl

Reviewed By: Anastasia

Subscribers: zzheng, dmgreen, jdoerfert, cfe-commits, asavonic, AlexeySotkin

Tags: #clang

Differential Revision: https://reviews.llvm.org/D59493

llvm-svn: 356571