Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
docs/LanguageExtensions.rst
Show First 20 Lines • Show All 1,985 Lines • ▼ Show 20 Lines | |||||
Unrolling a loop reduces the loop control overhead and exposes more | Unrolling a loop reduces the loop control overhead and exposes more | ||||
opportunities for ILP. Loops can be fully or partially unrolled. Full unrolling | opportunities for ILP. Loops can be fully or partially unrolled. Full unrolling | ||||
eliminates the loop and replaces it with an enumerated sequence of loop | eliminates the loop and replaces it with an enumerated sequence of loop | ||||
iterations. Full unrolling is only possible if the loop trip count is known at | iterations. Full unrolling is only possible if the loop trip count is known at | ||||
compile time. Partial unrolling replicates the loop body within the loop and | compile time. Partial unrolling replicates the loop body within the loop and | ||||
reduces the trip count. | reduces the trip count. | ||||
If ``unroll(full)`` is specified the unroller will attempt to fully unroll the | If ``unroll(full)`` is specified the unroller will attempt to fully unroll the | ||||
loop if the trip count is known at compile time. If the loop count is not known | loop if the trip count is known at compile time. If the fully unrolled code size | ||||
or the fully unrolled code size is greater than the limit specified by the | is greater than an internal limit the loop will be partially unrolled up to this | ||||
hfinkel: I know this is a pre-existing issue, but -pragma-unroll-threshold is an LLVM option, not a… | |||||
`-pragma-unroll-threshold` command line option the loop will be partially | limit. If the loop count is not known at compile time the loop will not be | ||||
unrolled subject to the same limit. | unrolled. | ||||
.. code-block:: c++ | .. code-block:: c++ | ||||
#pragma clang loop unroll(full) | #pragma clang loop unroll(full) | ||||
for(...) { | for(...) { | ||||
... | ... | ||||
} | } | ||||
The unroll count can be specified explicitly with ``unroll_count(_value_)`` where | The unroll count can be specified explicitly with ``unroll_count(_value_)`` where | ||||
_value_ is a positive integer. If this value is greater than the trip count the | _value_ is a positive integer. If this value is greater than the trip count the | ||||
loop will be fully unrolled. Otherwise the loop is partially unrolled subject | loop will be fully unrolled. Otherwise the loop is partially unrolled subject | ||||
to the `-pragma-unroll-threshold` limit. | to the same code size limit as with ``unroll(full)``. | ||||
.. code-block:: c++ | .. code-block:: c++ | ||||
#pragma clang loop unroll_count(8) | #pragma clang loop unroll_count(8) | ||||
for(...) { | for(...) { | ||||
... | ... | ||||
} | } | ||||
Show All 19 Lines |
I know this is a pre-existing issue, but -pragma-unroll-threshold is an LLVM option, not a Clang option, and I don't think we should mention it directly here. If I did not know how LLVM worked, and what -mllvm did, I'd find this documentation confusing.
Maybe just not mentioning this is best. What do you think?