Commit Graph

187 Commits

Author SHA1 Message Date
Tobias Grosser 2f4529f864 clang-format: Remove empty lines
llvm-svn: 204468
2014-03-21 14:04:25 +00:00
Tobias Grosser 0dd463facf Support for generating vectors for loads with -1 stride
This patch enables vectorization of loops containing backward array
traversal (array stride is -1).

Contributed-by: Chris Jenneisch <chrisj@codeaurora.org>
llvm-svn: 204257
2014-03-19 19:27:24 +00:00
Tobias Grosser 806e9fff60 Move Pass registration into polly library
This ensures that the polly passes get properly registered both, when using
polly as a loadable module and when directly linking it into clang/opt/bugpoint.

llvm-svn: 204255
2014-03-19 17:54:23 +00:00
Tobias Grosser ab38488c96 Ported scoplib to use isl_val * instead of isl_int
1) The isl_int -> isl_val changes are the ones Tobias suggested.
   One additional isl_val_free is added (and needed)
2) Three scoplib_vector_free are added, maybe we would need even
   more (and matrix_free) but it's hard to place them right.
3) Cleaned the includes (and removed 'extern C')

This fixes the broken compilation for the scoplib import and export.

Contributed-by: Johannes Doerfert <doerfert@cs.uni-saarland.de>
llvm-svn: 203500
2014-03-10 22:03:30 +00:00
Sebastian Pop 9cce17a23a remove unused code
llvm-svn: 203163
2014-03-06 20:59:18 +00:00
Tobias Grosser 7ff8ae8967 Fix formatting
llvm-svn: 202856
2014-03-04 15:57:29 +00:00
Tobias Grosser 9e400b076f Always name instructions
We currently need to always name instructions, as the polly test suite currently
matches for certain names. We should improve the test suite at some point.

This fixes 'make check-polly' in NDEBUG builds.

llvm-svn: 202855
2014-03-04 15:43:57 +00:00
Tobias Grosser 37c9b8e0f2 Emit llvm.loop metadata for parallel loops
For now we only mark innermost loops for the loop vectorizer.  We could later
also mark not-innermost loops to enable the introduction of openmp parallelism.

llvm-svn: 202854
2014-03-04 14:59:00 +00:00
Tobias Grosser 5103ba7c91 Introduce PollyIRBuilder
PollyIRBuilder is currently just a typedef to IRBuilder<>. Consequently, this
change should not affect behavior. In subsequent patches we will extend its
functionality to emit loop.parallel metadata.

llvm-svn: 202853
2014-03-04 14:58:49 +00:00
Tobias Grosser 2c1a81aefd cmake: Split off functionality for LLVM loadable module
This fixes the buildbots who failed, because the linker eliminated most of the
Polly functionality when building without BUILD_SHARED_LIBS=ON.

Besides fixing the build, this change also brings additional functionality. With
the new separation between the general polly libraries and the functionality for
the polly module, it is now possible to link polly directly into a tool instead
of using requiring users to load a shared library.

llvm-svn: 202762
2014-03-03 21:58:50 +00:00
Tobias Grosser 45bac0d953 Use C++11 formatting
clang-formats behaviour has changed for a couple of C++11 formattings. We adapt
Polly to ensure our formatting checks are clean again.

llvm-svn: 202650
2014-03-02 17:05:21 +00:00
Rafael Espindola c5d1689b45 Update for llvm api change.
llvm-svn: 202183
2014-02-25 19:17:57 +00:00
Tobias Grosser 38c36ea18e Do not fail in case we do not have valid dependences
In case we do not have valid dependences, we do not run dead code elimination or
the schedule optimizer. This fixes an infinite loop in the dead code
elimination (PR12110).

llvm-svn: 201982
2014-02-23 15:15:44 +00:00
Sebastian Pop bfec361cae GMP is only required for CLooG
llvm-svn: 201925
2014-02-22 02:15:39 +00:00
Tobias Grosser 37eb422f69 Add polyhedral dead code elimination.
This pass eliminates loop iterations that compute results that are not used
later on. This can help e.g. in D, where the default zero-initialization is
often unnecessary if right after new values are assigned to an array.

Contributed-by: Peter Conn <conn.peter@gmail.com>
llvm-svn: 201817
2014-02-20 21:43:54 +00:00
Tobias Grosser a1689937ba Check scops a second time before working on them
In rare cases the modification of one scop can effect the validity of other
scops, as code generation of an earlier scop may make the scalar evolution
functions derived for later scops less precise. The example that triggered this
patch was a scop that contained an 'or' expression as follows:

  %add13710 = or i32 %j.19, 1
    -->  {(1 + (4 * %l)),+,2}<nsw><%for.body81>

Scev could only analyze the 'or' as it knew %j.19 is a multiple of 2. This
information was not available after the first scop was code generated (or
independent-blocks was run on it) and SCEV could not derive a precise SCEV
expression any more. This means we could not any more code generate this SCoP.
My current understanding is that there is always the risk that an earlier code
generation change invalidates later scops.  As the example we have seen here is
difficult to avoid, we use this occasion to guard us against all such
invalidations.

This patch "solves" this issue by verifying right before we start working on
a detected scop, if this scop is in fact still valid. This adds a certain
overhead. However the verification we run is anyways very fast and secondly
it is only run on detected scops. So the overhead should not be very large. As
a later optimization we could detect scops only on demand, such that we need
to run scop-detections always only a single time.

This should fix the single last failure in the LLVM test-suite for the new
scev-based code generation.

llvm-svn: 201593
2014-02-18 18:49:49 +00:00
Tobias Grosser 9b1100b305 Add ScopDetection::isValidRegion(Region)
llvm-svn: 201592
2014-02-18 18:49:46 +00:00
Tobias Grosser 86070d226b Remove MayAliasSet class
The MayAliasSet class is currently not used and just confuses people. We can
reintroduce it in case need a more precise tracking of alias sets.

llvm-svn: 201191
2014-02-11 23:34:40 +00:00
Tobias Grosser e200d58ad7 Add missing doxygen comment
llvm-svn: 200410
2014-01-29 19:05:22 +00:00
Tobias Grosser 458fb78cfa Check if array base addresses are invariant
Array base addresses need to be invariant in the region considered. The base
address has to be computed outside the region, or, when it is computed inside,
the value must not change with the iterations of the loops. For example, when a
two-dimensional array is represented as a pointer to pointers the base address
A[i] in an access A[i][j] changes with i; therefore, such regions have to be
rejected.

Contributed by:  Armin Größlinger <armin.groesslinger@uni-passau.de>

llvm-svn: 200314
2014-01-28 12:58:58 +00:00
Tobias Grosser 63c6b45a5a Temporarily reformat Polly to silence buildbots
We may revert this depending on how the current discussion on llvm-commits
ends.

llvm-svn: 198581
2014-01-06 01:37:13 +00:00
Tobias Grosser ca7887d729 Another formatting fix
llvm-svn: 198386
2014-01-03 00:56:20 +00:00
Tobias Grosser 765a70abab Fix formatting issues
llvm-svn: 198384
2014-01-03 00:44:43 +00:00
Tobias Grosser a9376ff571 Introduce -polly-canonicalize pass
This ModulePass schedules the set of Polly canonicalization passes. It is a
debugging tool that can be used to preoptimize .ll files for Polly processing.

llvm-svn: 198376
2014-01-02 23:39:18 +00:00
Tobias Grosser 54ee0ba74d IslCodegen: Support for run-time conditions
llvm-svn: 194948
2013-11-17 03:18:25 +00:00
Tobias Grosser 1c84d80457 Style fixes, brought to you by clang-format
llvm-svn: 194910
2013-11-16 01:07:06 +00:00
Andy Gibbs 78fc064b1a PassManagerBase has moved into the legacy namespace as of r194324; match it here.
llvm-svn: 194490
2013-11-12 17:10:46 +00:00
Tobias Grosser d764fcbd5a Update comments to address Sebastian's review
llvm-svn: 193741
2013-10-31 11:50:52 +00:00
Tobias Grosser e86109f508 ScopInfo: Add support for AssumedContext
When constructing a scop sometimes the exact representation of a statement or
condition would be very complex, but there is a common case which is a lot
simpler, but which is only valid under certain assumptions. The assumed context
records the assumptions taken during the construction of this scop and that need
to be code generated as a run-time test.

At the moment, we do not yet model any assumptions, but only added the
AssumedContext as well as the isl-ast generation support. As a next step,
this needs to be hooked up with the isl code generation.

if (1) /* run-time condition */
  {  /* optimized code */ }
else
  {  /* original code */ }

llvm-svn: 193652
2013-10-29 21:05:49 +00:00
Tobias Grosser dd6dc8276f clang-format: No empty line after 'public:'
llvm-svn: 192710
2013-10-15 14:41:02 +00:00
Tobias Grosser 51b78752fe Use LLVM_DELETED_FUNCTION instead of a comment
Contributed-by:  Michael Kruse  <MichaelKruse@meinersbur.de>
llvm-svn: 191894
2013-10-03 13:09:14 +00:00
Tobias Grosser abe9193b6b ScopInfo: Fix typos
Contributed-by:  Michael Kruse  <MichaelKruse@meinersbur.de>
llvm-svn: 191892
2013-10-03 13:08:59 +00:00
Hongbin Zheng 5b463ceaf5 BlockGenerator: Split getNewValue.
Split the old getNewValue into two parts:

1. The function "lookupAvailableValue" that return the new version of
the instruction which is already available.

2. The function calls "lookupAvailableValue", and tries to generate
the new version if it is not available yet.

llvm-svn: 187114
2013-07-25 09:12:07 +00:00
Tobias Grosser c7d3fc5547 ScopDetect: Only track detection failures if actually needed.
String operations resulted by raw_string_ostream in the INVALID macro can lead
to significant compile-time overhead when compiling large size source code.
This is because raw_string_ostream relies on TypeFinder class, whose
compile-time cost increases as the size of the module increases. This patch
targets to ensure that it only track detection failures if actually needed.
In this way, we can avoid expensive string operations in normal execution.

With this patch file, the relative compile-time cost of Polly-detect pass does
not increase even when compiling very large size source code.

Contributed-by:   Star Tan <tanmx_star@yeah.net>
llvm-svn: 187102
2013-07-25 03:02:29 +00:00
Hongbin Zheng 63cc9467af Ensure a correct order between memory accesses.
Ensure that the scalar write access corresponds to the result of a load
instruction appears after the generic read access corresponds to the load
instruction.

llvm-svn: 186419
2013-07-16 15:20:29 +00:00
Tobias Grosser 001bd274f5 Dependences: Use ostream printer to print analysis output
llvm-svn: 186288
2013-07-14 18:09:40 +00:00
Tobias Grosser 8c895b4248 Support: No need to comment __isl_keep
llvm-svn: 186281
2013-07-14 06:59:38 +00:00
Tobias Grosser b58f6a4211 ScopInfo: Add getTupe() method to MemoryAccess
We also move the enum to UPPERCASE.

llvm-svn: 186259
2013-07-13 20:41:24 +00:00
Tobias Grosser 14a3999354 clang-format latest changes
llvm-svn: 185440
2013-07-02 16:13:07 +00:00
Hongbin Zheng 8d3a888ca3 TempScop: (Partial) Implement the printDetail function.
llvm-svn: 185254
2013-06-29 07:00:14 +00:00
Hongbin Zheng b5f24a665e Refactor memory access getting code in ScopStmt.
1. Do not allow creating new memory access record in the InstructionToAccess map
   on the fly in function getAccessFor.
2. Do not allow user to modify the memory accesses returned by getAccessFor
   during the code generation process.

llvm-svn: 185253
2013-06-29 06:31:39 +00:00
Tobias Grosser 4f96749351 ScopInfo: Clarify may-write and must-write accesses
llvm-svn: 184658
2013-06-23 05:21:18 +00:00
Tobias Grosser 58032cb029 Integrate latest clang-format changes
llvm-svn: 184655
2013-06-23 01:29:29 +00:00
Tobias Grosser edab1359a0 Use isl_val instead of isl_int in the core of Polly
isl recently introduced isl_val as an abstract interface to represent arbitrary
precision numbers. This interface superseeds the old isl_int interface. In
contrast to the old interface which implemented arbitrary precision arithmetic
using macros that forward to the gmp library, the new library hides the math
library implementation in isl. This allows us to switch the math library used by
isl without affecting users such as Polly.

llvm-svn: 184529
2013-06-21 06:41:31 +00:00
Tobias Grosser c5f290f6c6 Fix typo in header guards
Found by the new -Wheader-guard warning.

llvm-svn: 184047
2013-06-15 18:52:49 +00:00
Sebastian Pop 8ca899c781 scop detection: inline and remove isValidBasicBlock
llvm-svn: 184001
2013-06-14 20:20:43 +00:00
Hongbin Zheng 599782bb6c TempScopInfo: Add code to build the scalar dependences.
llvm-svn: 183653
2013-06-10 13:55:34 +00:00
Hongbin Zheng d1fdf0b180 Refactor: Move the IRAccess building code to a new function.
llvm-svn: 183635
2013-06-10 02:52:30 +00:00
Tobias Grosser 5db6ffd76f LoopGenerators: Construct loops such that they are already loop rotated
BeforeBB
                   |
                   v
                GuardBB
                /      \
       __  PreHeaderBB  \
      /  \    /         |
   latch  HeaderBB      |
      \  /    \         /
       <       \       /
                \     /
                ExitBB

This does not only remove the need for an explicit loop rotate pass, but it also
gives us the possibility to skip the construction of the guard condition in case
the loop is known to be executed at least once. We do not yet exploit this, but
by implementing this analysis in the isl code generator we should be able to
remove more guards than the generic loop rotate pass can.  Another point is that
loop rotation can introduce additional PHI nodes, which may hide that a loop can
be executed in parallel. This change avoids this complication and will make it
easier to move the openmp code generation into a separate pass.

llvm-svn: 181986
2013-05-16 06:40:06 +00:00
Tobias Grosser 637bd63123 Move polly options into separate option category
Use the new cl::OptionCategory support to move the Polly options into a separate
option category. The aim is to hide most options and show by default only the
options a user needs to influence '-O3 -polly'. The available options probably
need some care, but here is the current status:

Polly Options:
Configure the polly loop optimizer

  -enable-polly-openmp              - Generate OpenMP parallel code
  -polly                            - Enable the polly optimizer (only at -O3)
  -polly-no-tiling                  - Disable tiling in the scheduler
  -polly-only-func=<function-name>  - Only run on a single function
  -polly-report                     - Print information about the activities
                                      of Polly
  -polly-vectorizer                 - Select the vectorization strategy
    =none                           -   No Vectorization
    =polly                          -   Polly internal vectorizer
    =unroll-only                    -   Only grouped unroll the vectorize
                                        candidate loops
    =bb                             -   The Basic Block vectorizer driven by
                                        Polly

llvm-svn: 181295
2013-05-07 07:31:10 +00:00