Commit Graph

758 Commits

Author SHA1 Message Date
Tobias Grosser 817d51dd1b DCE: Switch to hybrid precise-unprecise analysis
Instead of giving a choice between a precise (but possibly very complex)
analysis and an approximative analysis we now use a hybrid approach which uses N
precise steps followed by one approximating step. The precision of the analysis
can be changed by increasing N. With a default of 'N' = 2, we get fully precise
results for our current test cases and should not run into performance problems
for more complex test cases. We can adjust this value when we got more
experience with this dead code elimination.

llvm-svn: 201888
2014-02-21 20:51:46 +00:00
Tobias Grosser ecae17ffca DCE: Update description
llvm-svn: 201887
2014-02-21 20:51:40 +00:00
Tobias Grosser 34f0613562 Optimizer: Do not accidentally set schedule to NULL
In case the domain of a statement is empty, the schedule optimizer set by
accident the schedule to a NULL pointer. This is incorrect. Instead, we set
it to an empty isl_map with zero schedule dimensions. We already checked for
this in our test cases, but unfortunately the test cases did not fail as
expected. The assert we add in this commit now ensures that the test cases
fail properly in case we regress on this again.

llvm-svn: 201886
2014-02-21 20:51:36 +00:00
Tobias Grosser 030237d0ff Codegen: Do not crash when seeing debug intrinsics
We now skip the debug intrinsics which is a lot better than crashing due to
uncopied metadata references. We should step by step investigate which debug
intrinsics we can copy without trouble.

We still keep the debug location metadata.

llvm-svn: 201860
2014-02-21 15:06:05 +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 3fc9154c40 Fix formatting
llvm-svn: 201816
2014-02-20 21:43:45 +00:00
Tobias Grosser d6aafa7c2e Do not track location of scalar dependences in ScopInfo
We do not have a use for this information at the moment. If we need this at some
point, the "instruction -> access" mapping needs to be enhanced as a single
instruction could then possibly perform multiple accesses.

This patch allows us to build the polyhedral information for scops with scalar
dependences.

llvm-svn: 201815
2014-02-20 21:29:09 +00:00
Tobias Grosser 612c2bc071 Fix typo
llvm-svn: 201814
2014-02-20 21:29:02 +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 5ea6b58e4a Fix formatting
llvm-svn: 201204
2014-02-12 01:55:28 +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 933edd04af IndependentBlocks: Do not assert for PHI nodes outside of scops
There does not seem to be a reason that we can not support PHI nodes outside of
the scop that reference values within the SCoP. Or at least, the attached test
case seems to do the right thing. We remove the assert for now.

llvm-svn: 200427
2014-01-29 23:08:10 +00:00
Tobias Grosser 28a70c543d ScopDetect: Transitively remove all children after region expansion
In rare cases, a region R which is itself not valid has an indirect child region
that is valid. When R becomes part of a valid region by expansion of another
region, then all children of R have to be erased from the set of valid regions.
This patch ensures that indirect children are erased in addition to direct
children.

Contributed-by: Armin Groesslinger <armin.groesslinger@uni-passau.de>

Tobias: I added a reduced test case and adjusted the logic of the patch to
        only recurse until the first child is found.
llvm-svn: 200411
2014-01-29 19:05:30 +00:00
Tobias Grosser ab2227a505 Do not verify the base addresses
Verification of base addresses is difficult as the independent blocks pass may
introduce aliasing that was not there during scop detection. As a midterm
solution -polly-codegen-scev will remove the need for the independent blocks
pass. For now, we do not verify at compile time that the independent blocks pass
does not make the base addresses loop invariant. Disabling this just removes
one of the multiple safety layers we have. We still can check for correctness
in our regression tests.

llvm-svn: 200315
2014-01-28 13:43:24 +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 4449e52655 Detection: Allow to filter the regions that can be detected
llvm-svn: 200224
2014-01-27 14:24:53 +00:00
Tobias Grosser 5ff8579ced Remove an unused parameter
llvm-svn: 200209
2014-01-27 10:44:25 +00:00
Tobias Grosser f20210940c Allow Polly at all optimization levels
Restricting Polly to -O3 does not make a lot of sense as it is opt-in anyway
and users who specifically request it should get it. If this causes performance
problems we should rather address them by scheduling the right cleanup passes
then just prevent the user from trying.

Also restricting Polly to -O3 made bugpoint not work with the -O3 flag and polly
enabled.

llvm-svn: 200208
2014-01-27 10:44:21 +00:00
Tobias Grosser b917f47fc4 Dependences: Bound the time dependence calculation is allowed to take
Count the number of computational steps that have been used to solve the
dependence problem and abort in case we reach the "compute-out". This ensures we
do not hang forever in cases the dependence problem is too difficult to solve.
There is just a single case in the LLVM test-suite that runs into the
compute-out. Even in this case, we can probably coalesce some of the parameters
(i32 b, i32 b zext i64, ...) to simplify the problem enough to not hit the
compute out. However, for now we set the compute out in place to address the
general issue. The compute out was choosen such that it stops on a recent laptop
after about 8 seconds.

llvm-svn: 200156
2014-01-26 19:38:34 +00:00
Tobias Grosser a38c92406c Update to isl 1b3ba3b72c0482fd36bf0b4a1186a259f7bafeed
This includes the following very useful isl commit:

commit d962967ab42323ea5ca0398956fbff6a98c782fa
Author: Sven Verdoolaege <skimo@kotnet.org>
Date:   Wed Dec 18 12:05:32 2013 +0100

allow the user to impose a bound on the number of low-level operations

This should allow the user to deterministically limit the effort spent on a
computation.

llvm-svn: 200155
2014-01-26 19:36:28 +00:00
Tobias Grosser b8cd4a8341 CodeGeneration: Replace reference to isl_int with explicit mpz call.
This removes the last isl_int dependency in the default build. There are
still some in OpenScop and Scoplib. For those isl-0.12.2 still needs to be used.

llvm-svn: 199585
2014-01-19 11:31:23 +00:00
Sylvestre Ledru 660712570a llvm/IR/Writer.h has been removed in llvm commit r198836 and seems useless in polly
llvm-svn: 199360
2014-01-16 07:10:09 +00:00
Tobias Grosser 42aff30dbc Adapt to DomTree changes in r199104
llvm-svn: 199157
2014-01-13 22:29:56 +00:00
Chandler Carruth e87c6a81d6 [cleanup] Update Polly for moved header in LLVM r199082.
llvm-svn: 199088
2014-01-13 09:56:11 +00:00
Tobias Grosser f240b487a3 Remove IR/Writer.h
This should fix the buildbots.

llvm-svn: 198859
2014-01-09 10:42:15 +00:00
Chandler Carruth e243b03a8c Update #include paths for r198688 in LLVM that moved headers in the Assembly
directory to their proper homes.

llvm-svn: 198691
2014-01-07 12:59: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 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 e61b86c9cd RegisterPasses: Do not claim we schedule canonicalization passes at -O0
Also the code makes the impression this was happening, shouldEnablePolly()
always returns false for optlevel equal to zero. This was previously different,
but was accidentally changed by a commit a couple of months ago. As this
behavior was mainly a debugging tool and adding this to clang never really made
sense, we just remove the last traces.

llvm-svn: 198370
2014-01-02 22:48:50 +00:00
Tobias Grosser 9a26f2986c ScopInfo: Ensure the RegionInfo analysis is always available
This fixes a crash that appeared when generating dotty graphs for functions
without loops (for which we do not calculate polyhedral information).

llvm-svn: 198364
2014-01-02 22:28:53 +00:00
Tobias Grosser 1b12f46464 Fix formatting
The polly on-commit formatting checker notified me that I forgot to format
the code before submitting.

llvm-svn: 197560
2013-12-18 11:14:36 +00:00
Tobias Grosser 8519f897e7 Report detected scops using the new diagnostics
We now report the following:

$ polly-clang -O3 -mllvm -polly -mllvm -polly-report test.c  -c \
  -gline-tables-only

note: Polly detected an optimizable loop region (scop) in function 'foo'
test.c:2: Start of scop
test.c:3: End of scop
note: Polly detected an optimizable loop region (scop) in function 'bar'
test.c:9: Start of scop
test.c:13: End of scop

llvm-svn: 197558
2013-12-18 10:49:53 +00:00
Tobias Grosser 7b6f9ba572 ScopValidator: smax expressions are no parameters
This fixes PR18155 which is a regression introduced in 152913.

llvm-svn: 196827
2013-12-09 21:51:46 +00:00
Tobias Grosser e5f00c8bd2 Fix 80 column violation
Found by clang-format.

llvm-svn: 194949
2013-11-17 03:18:32 +00:00
Tobias Grosser 54ee0ba74d IslCodegen: Support for run-time conditions
llvm-svn: 194948
2013-11-17 03:18:25 +00:00
Tobias Grosser 378a9f2b91 ScopDetection: Improve formatting
llvm-svn: 194931
2013-11-16 19:34:11 +00:00
Sebastian Pop 3d1806b907 prepend LLVM to all Polly* libs
llvm-svn: 194923
2013-11-16 15:28:55 +00:00
Sebastian Pop 8d6cca1906 factor out code in shouldEnablePolly
to be able to call the same functionality from registerPollyEarlyAsPossiblePasses
and registerPollyOptLevel0Passes.

llvm-svn: 194922
2013-11-16 15:28:49 +00:00
Sebastian Pop 4915ccbe8b move MayAliasSet.cpp into lib/Analysis
llvm-svn: 194921
2013-11-16 15:28:45 +00:00
Tobias Grosser 1c84d80457 Style fixes, brought to you by clang-format
llvm-svn: 194910
2013-11-16 01:07:06 +00:00
Tobias Grosser 2ea6deb62f IslCodegen: Do not build upper bound in vector for
For for-nodes that are translated to a set of vector lanes, we already know the
overall number of iterations. Calculating the upper bound is consequently not
necessary. This change removes the code for upper bound calculation, which was
probably copy/pasted from the code generation for the normal for-loop.

This issue was found by Sylvestre's scan-build server.

llvm-svn: 193925
2013-11-02 12:59:39 +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
Sebastian Pop 40408760c1 do not compute isl_map_dim in the loop
llvm-svn: 191969
2013-10-04 17:14:53 +00:00
Tobias Grosser 0d17013cb7 clang-format
llvm-svn: 191895
2013-10-03 13:09:19 +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 1ff0be799d ScopInfo: Do not include "isl/int.h" any more
We already removed all uses of isl_int in ScopInfo.

Contributed-by:  Michael Kruse  <MichaelKruse@meinersbur.de>
llvm-svn: 191893
2013-10-03 13:09:07 +00:00
Tobias Grosser b276158efa clang-format recent change
llvm-svn: 190842
2013-09-17 03:30:36 +00:00
Tobias Grosser 0695ee433e Move SCEVAffinator member definitions out of class body
Instead of defining the relevant functions inline, we now just keep the
declarations in the class itself. This makes the class declaration a lot
easier to read as all functions can be seen at once. We also use this
opportunity to privatize all functions not used in the public interface of the
class.

llvm-svn: 190841
2013-09-17 03:30:31 +00:00
Matt Arsenault 77d55f8abd Fix build after SCEV change
llvm-svn: 190429
2013-09-10 20:22:17 +00:00
Tobias Grosser e2622c2acc TempScopInfo: Microoptimize constant conditions
Use 0 >= 1 instead of 0 != 0 to represent 'false'. This might be slightly more
efficient as isl may create a union of sets for 0 != 0, whereas this is never
needed for the expression 0 >= 1.

Contributed-by: Alexandre Isoard <alexandre.isoard@gmail.com>
llvm-svn: 190384
2013-09-10 04:47:19 +00:00
Tobias Grosser 3613fd7a35 ScopInfo: Correctly handle true/false conditions
This is a modified version of the orignally contributed patch.

Contributed-by: alexandre.isoard@gmail.com
llvm-svn: 190237
2013-09-07 01:54:13 +00:00
Tobias Grosser 815c635cec [CodeGen] Fixup assert fails caused by incorrect LoopInfo update
Contributed-by: Star Tan <tanmx_star@yeah.net>
llvm-svn: 189764
2013-09-02 16:13:00 +00:00
Tobias Grosser 4c932b8a4b Remove unneeded comma and update formatting
llvm-svn: 189177
2013-08-24 17:58:59 +00:00
Tobias Grosser e2c05bbefe PollyDependence: Simplify Read/Write/MayWrite before feeding them into ISL.
Contributed-by: Star Tan <tanmx_star@yeah.net>
llvm-svn: 187981
2013-08-08 13:55:45 +00:00
Tobias Grosser e42ddb9ad3 ScopInfo: Split start value from SCEVAddRecExpr to enable parameter sharing.
SCoP invariant parameters with the different start value would deter parameter
sharing. For example, when compiling the following C code:

  void foo(float *input) {
    for (long j = 0; j < 8; j++) {
      // SCoP begin
      for (long i = 0; i < 8; i++) {
        float x = input[j * 64 + i + 1];
        input[j * 64 + i] = x * x;
      }
    }
  }

Polly would creat two parameters for these memory accesses:

    p_0: {0,+,256}
    p_2: {4,+,256}
    [j * 64 + i + 1] => MemRef_input[o0] : 4o0 = p_1 + 4i0
    [j * 64 + i]     => MemRef_input[o0] : 4o0 = p_0 + 4i0

These parameters only differ from start value. To enable parameter sharing,
we split the start value from SCEVAddRecExpr, so they would share a single
parameter that always has zero start value:

    p0: {0,+,256}<%for.cond1.preheader>
    [j * 64 + i + 1] => MemRef_input[o0] : 4o0 = 4 + p_1 + 4i0
    [j * 64 + i]     => MemRef_input[o0] : 4o0 = p_0 + 4i0

Such translation can make the polly-dependence much faster.

Contributed-by: Star Tan <tanmx_star@yeah.net>
llvm-svn: 187728
2013-08-05 15:14:15 +00:00
Tobias Grosser abd96a0c0a Dependence: Add DEBUG support.
Contributed-by:  Star Tan <tanmx_star@yeah.net>
llvm-svn: 187498
2013-07-31 14:35:17 +00:00
Tobias Grosser 85f7421731 JSONImporter: Free new schedule if found invalid
In case we detect that the schedule the user wants to import is invalid we
refuse it _and_ free the isl_maps containing it.

Another bug found thanks to Rafael.

llvm-svn: 187339
2013-07-29 05:12:01 +00:00
Tobias Grosser 880c52f56a CodeGeneration: Fix double free in vector for
We now use __isl_take to annotate the uses of the isl_set where we got the
memory management wrong.

Thanks to Rafael! His pipefail work hardened our test environment and exposed
this bug nicely.

llvm-svn: 187338
2013-07-29 01:58:07 +00:00
Tobias Grosser 983e785f17 gitattributes: .png and .txt are no text files
llvm-svn: 187326
2013-07-28 09:05:20 +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
Tobias Grosser ff9bfdfa80 ScopInfo/IndependentBlocks: clang-format
llvm-svn: 187023
2013-07-24 06:10:30 +00:00
Tobias Grosser 54cb789d39 RegisterPass: Unhide -polly-show and -polly-show-only
llvm-svn: 186806
2013-07-22 04:11:00 +00:00
Tobias Grosser 5b1a7f2245 ScopDetect: move "return false" out of INVALID macro.
Contributed-by: Star Tan <tanmx_star@yeah.net>
llvm-svn: 186805
2013-07-22 03:50:33 +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
Hongbin Zheng 5a772dcd84 IndependentBlock: Add option to disable scalar to array rewriting.
llvm-svn: 186418
2013-07-16 15:19:33 +00:00
Hongbin Zheng c6aa9f5c2a Make sure the each instruction is mapped to one memory access.
llvm-svn: 186417
2013-07-16 15:18:51 +00:00
Tobias Grosser 298a7646f3 ScopDetect: clang-format
llvm-svn: 186289
2013-07-14 18:09:43 +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 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 229d681675 Dependences: Clarify difference between value and memory based dependences
We make the option a clear choice between the two analysis types and add
descriptions about the difference between the two.

llvm-svn: 186251
2013-07-13 17:37:55 +00:00
Tobias Grosser aef925e81f Small style improvements
llvm-svn: 186248
2013-07-13 16:58:07 +00:00
Sebastian Pop 784c012982 scop detection: remove an iteration over all uses
reenabled reverted patch after checking that it passes without regressions on
the nightly test-suite.  Added testcase from Tobi.

llvm-svn: 185720
2013-07-05 20:24:47 +00:00
Sebastian Pop 8c2d75302f scop detection: early return
to reduce indentation level
No functionality changed.

llvm-svn: 185590
2013-07-03 22:50:36 +00:00
Tobias Grosser 14a3999354 clang-format latest changes
llvm-svn: 185440
2013-07-02 16:13:07 +00:00
Hongbin Zheng fe11e287b4 BlockGenerator: Simplify the old value searching code.
Orignally, we first test if a ValueMap contains a Value, and than use the
index operator to get the corresponding new value. This requires the ValueMap
to lookup the key (i.e. the old value) twice.

Now, we directly use the "lookup" function provided by DenseMap to implement
the same functionality.

llvm-svn: 185260
2013-06-29 13:22:15 +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
Hongbin Zheng f4adf0fc44 Minor change: No need to specify the namespace of raw_ostream.
llvm-svn: 185252
2013-06-29 06:30:55 +00:00
Tobias Grosser 04d6ae65b7 Fix my own formatting mistakes
llvm-svn: 184659
2013-06-23 06:04:54 +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
Sebastian Pop a189a5763c revert r183799: scop detection: remove an iteration over all uses
llvm-svn: 184128
2013-06-17 21:43:10 +00:00
Sebastian Pop 8ca899c781 scop detection: inline and remove isValidBasicBlock
llvm-svn: 184001
2013-06-14 20:20:43 +00:00
Sebastian Pop e1e4a2d534 scop detection: check flag before expensive call
llvm-svn: 184000
2013-06-14 20:20:39 +00:00
Tobias Grosser 3e030e178a Correctly convert APInt to gmp values
Previously this happend to work for integers up to i64, but we got it wrong
for larger numbers. Fix this and add test cases to verify this keeps working.

Reported by: Sven Verdoolaege <skimo at kotnet dot org>

llvm-svn: 183986
2013-06-14 16:23:38 +00:00
Tobias Grosser ef2ee4fec2 PoCC: Adjust to recent sys::Path removal
llvm-svn: 183969
2013-06-14 06:26:33 +00:00
Tobias Grosser aa76805796 Do not create an object to call a static function
llvm-svn: 183897
2013-06-13 09:10:23 +00:00
Sebastian Pop 9d63234ad1 ScopDetect: check region entering edges are valid.
When a region header is part of a loop, then all entering edges of this region
should not come from the loop but outside the region. Otherwise, the loop may be
only partially part of the region, which would cause troubles in handling
induction variables.

Currently, we can only model induction variables that are either fully part of
the scop (loop induction variable) or induction variables that are scop-
invariant (parameter). A loop that is only partially part of the
scop causes troubles, as there is no good way to handle the induction
variable in the independent blocks pass.

Contributed-by:    Star Tan <tanmx_star@yeah.net>
llvm-svn: 183800
2013-06-11 22:20:40 +00:00
Sebastian Pop 15117271c7 scop detection: remove an iteration over all uses
llvm-svn: 183799
2013-06-11 22:20:35 +00:00
Sebastian Pop b88ea5e991 scop detection: run isValidLoop as early as possible
to discard regions with invalid loops before going through the contents of the
basic blocks

llvm-svn: 183798
2013-06-11 22:20:32 +00:00
Sebastian Pop 9e3d2dd6ea scop detection: run isValidCFG as early as possible
to discard regions with invalid CFG before going through the contents of the
basic blocks

llvm-svn: 183797
2013-06-11 22:20:27 +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
Sebastian Pop b35892bd59 scop detection: do not call getAliasSetForPointer when IgnoreAliasing
Contributed-by: Dmitry N. Mikushin <maemarcus@gmail.com>
llvm-svn: 183114
2013-06-03 16:35:41 +00:00
Sebastian Pop 2c9ec2e651 scop detection: do not run scop detection on regions without loops
otherwise, use -polly-detect-scops-in-regions-without-loops to also detect scops
in regions without loops

llvm-svn: 183113
2013-06-03 16:35:37 +00:00
Sebastian Pop 14f802f99c include missing ISL header file
to be able to compile with ISL master as of today
1df91d8515ec88dc7f7f597168ad0f34f26de5a7

llvm-svn: 183023
2013-05-31 17:41:17 +00:00
Sebastian Pop 8fe6d11b84 scop detection: only handle functions with loops
to detect scops in functions with no loops, use -polly-detect-scops-in-functions-without-loops

llvm-svn: 182941
2013-05-30 17:47:32 +00:00
Sebastian Pop 3d94fedf0b add comments to clarify the use of a temporary variable in the map insertion
llvm-svn: 182662
2013-05-24 18:46:02 +00:00
Sebastian Pop cbeb5e821f independent blocks: do not insert stores between phi nodes
llvm-svn: 182661
2013-05-24 18:45:58 +00:00
Sebastian Pop 753d43f974 fix insertion of values in BBMap
In GDB when "step" through generateScalarLoad and "finish" the call, the
returned value is non NULL, however when printing the value contained in
BBMap[Load] after this stmt:

  BBMap[Load] = generateScalarLoad(...);

the value in BBMap[Load] is NULL, and the BBMap.count(Load) is 1.

The only intuitive idea that I have to explain this behavior is that we are
playing with the undefined behavior of eval order of the params for the function
standing for "BBMap[Load] = generateScalarLoad()". "BBMap[Load] = " may be
executed before generateScalarLoad is called.

Here are some other possible explanations from Will Dietz <w@wdtz.org>:

The error is likely due to BBMap[Load] being evaluated first (creating
a {Load -> uninitialized } entry in the DenseMap), then
generateScalarLoad eventually accesses the same element and finds it
to be NULL (DenseMap[Old])..  Offhand I'm not sure if this is
guaranteed to be NULL or if it's uninitialized and happens to be NULL.

The same issue can also go wrong in an even worse way: the second
DenseMap access can trigger a rehash and *invalidate* the an earlier
evaluated expression (for example LHS of the assignment), leading to a
crash when performing the assignment store.

llvm-svn: 182655
2013-05-24 17:16:02 +00:00
Sebastian Pop 359d3aa8a1 independent blocks: when moving Values, invalidate SCEV cached info
llvm-svn: 182310
2013-05-20 20:02:03 +00:00
Tobias Grosser 3081b0f5ec Update LoopInfo correctly
When the Polly code generation was written we did not correctly update the
LoopInfo data, but still claimed that the loop information is correct. This
does not only lead to missed optimizations, but it can also cause
miscompilations in case passes such as LoopSimplify are run after Polly.

Reported-by: Sergei Larin <slarin@codeaurora.org>
llvm-svn: 181987
2013-05-16 06:40:24 +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 83628182f7 Sort includes
llvm-svn: 181297
2013-05-07 08:11:54 +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
Tobias Grosser e602a07662 Reformat with clang-format
clang-format become way more stable. This time we mainly reformat function
signatures.

llvm-svn: 181294
2013-05-07 07:30:56 +00:00
Tobias Grosser e8df5bd92b IndependentBlocks: We can only reconstruct PHI nodes that are within the ScoP
In the classical (non -polly-codegen-scev) mode, we assume that we can always
recreate PHI nodes during code generation. This is not true. We can only
reconstruct them from the polyhedral information, in case the entire loop of the
PHI node is part of the SCoP and consequently the PHI node was translated in
the polyhedral description.

llvm-svn: 179674
2013-04-17 07:20:36 +00:00
Tobias Grosser b5f92892d1 Remove unneeded RegionSimplify pass.
We now support regions with multiple entries and multiple exits natively.
Regions are not needed to be simplified to single entry and single exit.

We need to XFAIL two test cases as this change increases the scop coverage
and uncoveres two failures in the independent blocks pass. The first failure
will be fixed in a subsequent commit, the second one is in the non-default
-polly-codegen-scev mode and still needs to be fixed.

Contributed-by: Star Tan <tanmx_star@yeah.net>
llvm-svn: 179673
2013-04-17 07:20:30 +00:00
Tobias Grosser 8edce4ee62 Support SCoPs with multiple entry edges.
Regions that have multiple entry edges are very common. A simple if condition
yields e.g. such a region:

  if
 /   \
then  else
 \   /
for_region

This for_region contains two entry edges 'then' -> 'for_region' and 'else' -> 'for_region'.

Previously we scheduled the RegionSimplify pass to translate such regions into
simple regions. With this patch, we now support them natively when the region is
in -loop-simplify form, which means the entry block should not be a loop header.

Contributed by:  Star Tan <tanmx_star@yeah.net>

llvm-svn: 179586
2013-04-16 08:04:42 +00:00
Tobias Grosser 3ed2600cab SCEVValidator: Correctly store 'k * p' as a parameter
We do not only need to understand that 'k * p' is a parameter expression, but
also need to store this expression in the set of parameters. Before this patch
we wrongly stored the two individual parameters %k and %p.

Reported by: Sebastian Pop <spop@codeaurora.org>

llvm-svn: 179485
2013-04-14 13:15:59 +00:00
Tobias Grosser 249c4b1ad5 ScheduleOptimizer: Use isl_map_from_union_map to extract map.
llvm-svn: 179268
2013-04-11 05:55:13 +00:00
Tobias Grosser f242b806ac ScheduleOpt: Do not crash on statements with empty iteration domains
Statements with an empty iteration domain may not have a schedule assigned by
the isl schedule optimizer. As Polly expects each statement to have a schedule,
we keep the old schedule for such statements.

This fixes http://llvm.org/PR15645`

Reported-by: Johannes Doerfert  <johannesdoerfert@gmx.de>
llvm-svn: 179233
2013-04-10 22:48:08 +00:00
Tobias Grosser ecb5092707 ScopDetect: Allow multiplications of the form <param> * <param>
We handle these by treating this result of the multiplication as an additional
parameter.

llvm-svn: 179163
2013-04-10 07:42:28 +00:00
Tobias Grosser d7e58640a5 Update formatting to latest version of clang-format
llvm-svn: 179160
2013-04-10 06:55:45 +00:00
Tobias Grosser 0ee50f6ee4 Support SCoPs with multiple exit edges
Regions that have multiple exit edges are very common. A simple if condition
yields e.g. such a region:

        if
      /   \
  then     else
      \   /
      after

Region: if -> after

This regions contains the bbs 'if', 'then', 'else', but not 'after'. It has
two exit edges 'then' -> 'after' and 'else' -> 'after'.

Previously we scheduled the RegionSimplify pass to translate such regions into
simple regions. With this patch, we now support them natively.

Contributed-by: Star Tan <tanmx_star@yeah.net>
llvm-svn: 179159
2013-04-10 06:55:31 +00:00
Tobias Grosser 03fc9acbe5 Codegen: Replace region exit and entries recursively
During code generation we split the original entry and exit basic blocks
of the scop to make room for the newly generated code. To keep the region tree
up to date, we need to update the region tree. This patch ensures that not only
the region of the scop is updated, but also all child regions that share the
same entry or exit block.

We have now test case here, as the bug is only exposed by the subsequent commit.
The test cases of that commit also cover this bug.

Contributed-by: Star Tan <tanmx_star@yeah.net>
llvm-svn: 179158
2013-04-10 06:55:20 +00:00
Sebastian Pop e7a7beec7d fix typos
llvm-svn: 179149
2013-04-10 04:09:12 +00:00
Sebastian Pop 9f57c5b695 scop detection: properly instantiate SCEVs to the place where they are used
Fix inspired from c2d4a0627e95c34a819b9d4ffb4db62daa78dade.

    Given the following code

        for (i = 0; i < 10; i++) {
          ;
        }

    S:  A[i] = 0

    When translate the data reference A[i] in statement S using scev, we need to
    retrieve the scev of 'i' at the location of 'S'. If we do not do this the
    scev that we obtain will be expressed as {0,+,1}_for and will reference loop
    iterators that do not surround 'S'. What we really want is the scev to be
    instantiated to the value of 'i' after the loop. This value is {10}.

This used to crash in:

    int loopDimension = getLoopDepth(Expr->getLoop());

    isl_aff *LAff = isl_aff_set_coefficient_si(
        isl_aff_zero_on_domain(LocalSpace), isl_dim_in, loopDimension, 1);

(gdb) p Expr->dump()
{8,+,8}<nw><%do.body>

(gdb) p getLoopDepth(Expr->getLoop())
$5 = 0

    isl_space *Space = isl_space_set_alloc(Ctx, 0, NbLoopSpaces);
    isl_local_space *LocalSpace = isl_local_space_from_space(Space);

As we are trying to create a memory access in a stmt that is outside all loops,
LocalSpace has 0 dimensions:

(gdb) p NbLoopSpaces
$12 = 0

(gdb) p Statement.BB->dump()

if.then:                                          ; preds = %do.end
  %0 = load float* %add.ptr, align 4
  store float %0, float* %q.1.reg2mem, align 4
  br label %if.end.single_exit

and so the scev for %add.ptr should be taken at the place where it is used,
i.e., it should be the value on the last iteration of the do.body loop, and not
"{8,+,8}<nw><%do.body>".

llvm-svn: 179148
2013-04-10 04:05:18 +00:00
Sebastian Pop 9ca6612731 IndependentBlocks: translate out of SSA all uses escaping the region
llvm-svn: 179019
2013-04-08 13:05:41 +00:00
Sebastian Pop cefec6d7e4 SCEVCodegen should not run createIndVarSimplifyPass
llvm-svn: 179018
2013-04-08 13:05:37 +00:00
Tobias Grosser aeabcf24df ScopDetection: Use isTopLevelRegion
Contributed-by: Star Tan <tanmx_star@yeah.net>
llvm-svn: 178530
2013-04-02 06:41:48 +00:00
Tobias Grosser c2bdf1973b RegisterPasses: Improve comments
llvm-svn: 177831
2013-03-23 21:35:52 +00:00
Tobias Grosser 4d96c8d714 clang-format: Many more files
After this commit, polly is clang-format clean. This can be tested with
'ninja polly-check-format'. Updates to clang-format may change this, but the
differences will hopefully be both small and general improvements to the
formatting.

We currently have some not very nice formatting for a couple of items, DEBUG()
stmts for example. I believe the benefit of being clang-format clean outweights
the not perfect layout of this code.

llvm-svn: 177796
2013-03-23 01:05:07 +00:00
Tobias Grosser 45af235e09 RegisterPasses: clang-format
llvm-svn: 177787
2013-03-23 00:32:21 +00:00
Tobias Grosser f008da125c Instvarsimplify: clang-format
Even though we will soon get rid of this pass, we reformat it on the way to
make polly clang-format clean.

llvm-svn: 177786
2013-03-23 00:32:18 +00:00
Tobias Grosser 9abbfc0b69 IndependentBlocks: clang-format and remove includes
llvm-svn: 177785
2013-03-23 00:32:15 +00:00
Tobias Grosser c30d9cc678 DeadCodeElimination: clang-format and comment
llvm-svn: 177782
2013-03-23 00:16:05 +00:00
Tobias Grosser 33bc2e93be CodePreparation: Comment and format the file properly
llvm-svn: 177781
2013-03-23 00:13:39 +00:00
Tobias Grosser 369430ffca codegen: properly instantiate SCEVs to the place where they are used
Given the following code

    for (i = 0; i < 10; i++) {
      ;
    }

S:  A[i] = 0

When code generating S using scev based code generation, we need to retrieve
the scev of 'i' at the location of 'S'. If we do not do this the scev that
we obtain will be expressed as {0,+,1}_for and will reference loop iterators
that do not surround 'S' and that we consequently do not know how to code
generate. What we really want is the scev to be instantiated to the value of 'i'
after the loop. This value is {10} and it can be code generated without
troubles.

llvm-svn: 177777
2013-03-22 23:42:53 +00:00
Sebastian Pop 27c10c6b1f ScopInfo: do not call getCanonicalInductionVariable for SCEVCodegen
llvm-svn: 177771
2013-03-22 22:07:43 +00:00
Tobias Grosser 4e318abece Do not canonicalize indvars with scev based codegen
Scev code generation can now handle scops with non canonical induction
variables. Hence there is no need to introduce canonical ones any more.

llvm-svn: 177644
2013-03-21 16:14:53 +00:00
Tobias Grosser 826b2af112 Remove last uses of canoncial induction variable when scev code generating
We now detect scops without a canonical induction variable and can generate a
polyhedral representation for them. There was no modification necessary to
code generate these scops.

llvm-svn: 177643
2013-03-21 16:14:50 +00:00
Tobias Grosser 5bfa4f8eb8 CodePrepare: Do not require canonical induction variables for scev based mode
llvm-svn: 177593
2013-03-20 22:41:53 +00:00
Tobias Grosser ecfe21b792 Remove dependence on canonical induction variable
When using the scev based code generation, we now do not rely on the presence
of a canonical induction variable any more. This commit prepares the path to
(conditionally) disable the induction variable canonicalization pass.

llvm-svn: 177548
2013-03-20 18:03:18 +00:00
Andy Gibbs 36e6ca0143 Remove unnecessary explicit typing in std::make_pair
llvm-svn: 177528
2013-03-20 15:42:59 +00:00
Tobias Grosser b921e6377b Add option -polly-code-generator=none
This allows us to test Polly and the Polly optimizer without actually doing
code generation at the end. By enabling this option, we can also measure the
compile time overhead due to code generation and the cost of LLVM optimizing the
newly generated code.t

llvm-svn: 177516
2013-03-20 13:03:26 +00:00
Tobias Grosser 0fbbbf6aa7 Silence 'variable unused' warning in release mode
llvm-svn: 177515
2013-03-20 13:03:25 +00:00
Tobias Grosser 84b81dee55 ScopDetect: Remove some redundant semicolons
llvm-svn: 177444
2013-03-19 21:44:07 +00:00
Sebastian Pop 97cb813c29 Correct function to decide if a SCEV can be ignored
When doing SCEV based code generation, we ignore instructions calculating values
that are fully defined by a SCEV expression. The values that are calculated by
this instructions are recalculated on demand.

This commit improves the check to verify if certain instructions can be ignored
and recalculated on demand.

llvm-svn: 177313
2013-03-18 20:21:13 +00:00
Tobias Grosser 0d1cf2b875 ScopHelper: Remove some dead code
llvm-svn: 177307
2013-03-18 19:17:07 +00:00
Sebastian Pop e039bb1fdb use the canonical IV only when it exists
llvm-svn: 177306
2013-03-18 19:09:49 +00:00
Tobias Grosser b2863ca2dc Print function names under --polly-report
llvm-svn: 176446
2013-03-04 19:49:51 +00:00
Tobias Grosser de49b8fa3b Support: clang-format
llvm-svn: 175874
2013-02-22 08:21:52 +00:00
Tobias Grosser 7242ad9226 CodeGen: clang-format
llvm-svn: 175872
2013-02-22 08:07:06 +00:00
Sebastian Pop 47d4ee3ed4 capitalize SCEV to match the current naming convention
llvm-svn: 175306
2013-02-15 21:26:53 +00:00
Sebastian Pop f30d3b2d89 don't store a pointer to the loop in IVS
llvm-svn: 175304
2013-02-15 21:26:48 +00:00
Sebastian Pop 860e021fe6 add NestLoops to remove some uses of IVS
llvm-svn: 175303
2013-02-15 21:26:44 +00:00
Sebastian Pop 637b23dc63 use apply and ScevParameterRewriter::rewrite instead of SCEVRewriter
llvm-svn: 175296
2013-02-15 20:56:01 +00:00
Sebastian Pop 9d10fffa33 add LoopToScev maps
llvm-svn: 175295
2013-02-15 20:55:59 +00:00
Tobias Grosser d535f55146 Formatting fixes
llvm-svn: 175177
2013-02-14 16:42:45 +00:00
Tobias Grosser c14582f276 CodeGen: clang-format goodness
The changed files are not yet clang-format clean, but we are getting close.

llvm-svn: 174403
2013-02-05 18:01:29 +00:00
Tobias Grosser 1f11b44939 TempScopInfo: clang-format
llvm-svn: 174368
2013-02-05 12:27:23 +00:00
Tobias Grosser 14f4c3e9fa Dependences: clang-format
Everything except INITIALIZE_PASS_* macros

llvm-svn: 174367
2013-02-05 12:27:22 +00:00
Tobias Grosser abfbe637bc ScopInfo: clang-format file
clang-format was able to format the entire file except the final
INITIALIZE_PASS_* macros.

llvm-svn: 174366
2013-02-05 12:09:06 +00:00
Tobias Grosser 0d1eee3298 ScopDetect: clang-format pointer types in templates
llvm-svn: 174365
2013-02-05 11:56:05 +00:00
Tobias Grosser af3c00b87b ScopDetection: clang-format some more code
llvm-svn: 174362
2013-02-05 09:40:22 +00:00
Tobias Grosser 428b3e48e2 ScopDetection: Improve printing of alias sets
We now show the all members of the alias set that may couse possible aliasing.
In case a alias set member is not a named instruction (unnamed instructions or
constant expressions), we show the expression itself.

This improves our error message

from:

  Possible aliasing for value: .reg2mem

to:

  Possible aliasing: ".reg2mem",
                     "[0 x double]* inttoptr (i64 47255179264 to [0 x double]*)

llvm-svn: 174329
2013-02-04 15:46:25 +00:00
Tobias Grosser 74394f0dcf clang-format goodness
llvm-svn: 172486
2013-01-14 22:40:23 +00:00
Tobias Grosser b1304ba9b2 Dead code elimination: Make variable names uppercase
llvm-svn: 171844
2013-01-08 08:53:58 +00:00
Tobias Grosser 184e2fcd9c clang-format the dead code elimination pass
llvm-svn: 171843
2013-01-08 08:27:46 +00:00
Chandler Carruth 535d52c7ca Rewrite #includes for llvm/Foo.h to llvm/IR/Foo.h as appropriate to
reflect the migration in r171366.

llvm-svn: 171370
2013-01-02 11:47:44 +00:00
Tobias Grosser ae2d83ec41 Formatting: Break lines after binary operators such as '&&'
assert(Condition
       && "Text");

->

assert(Condition &&
       "Text);

This aligns Polly with the style used in LLVM.

llvm-svn: 171242
2012-12-29 23:57:18 +00:00
Tobias Grosser 1bb59b0dcf Fix obvious formatting problems.
We fix the following formatting problems found by clang-format:

  - 80 cols violations
  - Obvious problems with missing or too many spaces
  - multiple new lines in a row

clang-format suggests many more changes, most of them falling in the following
two categories:

  1) clang-format does not at all format a piece of code nicely

  2) The style that clang-format suggests does not match the style used in
     Polly/LLVM

I consider differences caused by reason 1) bugs, which should be fixed by
improving clang-format. Differences due to 2) need to be investigated closer
to understand the cause of the difference and the solution that should be taken.

llvm-svn: 171241
2012-12-29 23:47:38 +00:00
Tobias Grosser 7a2f39534f 'chmod -x' on files that do not need the executable bits
llvm-svn: 171224
2012-12-29 15:09:03 +00:00
Sebastian Pop ab9ea13f64 avoid initializing twice
llvm-svn: 170854
2012-12-21 07:27:17 +00:00
Sebastian Pop eb283143e2 do not access Info when it is NULL
llvm-svn: 170853
2012-12-21 07:27:13 +00:00
Sebastian Pop 2aa5c24a3a return -1 when polly::getNumberOfIterations returns -1
llvm-svn: 170422
2012-12-18 08:56:51 +00:00
Sebastian Pop 04c4ce32ae isl: vector code generation based on ISL ast
Original patch by Tobias Grosser, slightly modified by Sebastian Pop.

llvm-svn: 170420
2012-12-18 07:46:13 +00:00
Sebastian Pop a00a029115 change interface for isStride
isStride now takes a partial schedule as input.

Patch from Tobias Grosser <tobias@grosser.es>.

llvm-svn: 170419
2012-12-18 07:46:06 +00:00
Sebastian Pop e252c85545 isl: detect vector parallelism
llvm-svn: 170138
2012-12-13 16:52:41 +00:00
Tobias Grosser e36abf6d5d isl: Detect openmp parallelism
Based on code written by Riyadh Baghdadi.

llvm-svn: 170102
2012-12-13 06:24:06 +00:00
Tobias Grosser b2e572c6df Update the recommended isl version
Recent changes in isl:

- Allow analysis of loops during code generation

This simplifies the detection of parallel loops.

- Simplify the way costumized ast printers are defined

This enables us to highlight parallel / vector loops in our debug output.

- Compile time improvements for codegen contexts that include parameters

- Various bug fixes

This update also gets us in sync for the isl 0.11 release.

llvm-svn: 169100
2012-12-01 21:51:10 +00:00
Tobias Grosser 46c6abb306 Remove unneeded preservation and restore of ValueMap and ClastVars in GPGPU code
generation.

We don't use the exact same way to build loop body for GPGPU codegen as openmp
codegen and other transformations do currently, in which cases 'createLoop'
function is called recursively. GPGPU codegen may fail due to improper restore
of ValueMap and ClastVars .

Contributed by:  Yabin Hu <yabin.hwu@gmail.com>

llvm-svn: 168966
2012-11-30 01:05:05 +00:00
Tobias Grosser 6f3d0633a4 Add an additional input argument according to chanages of function polly::createLoop.
Contributed-by:  Yabin Hu <yabin.hwu@gmail.com>
llvm-svn: 168964
2012-11-30 00:39:49 +00:00
Sebastian Pop facd36e5c7 make IslAstInfo::printScop compatible with CloogInfo::printScop
llvm-svn: 168714
2012-11-27 18:50:41 +00:00
Sebastian Pop 7cf3104b7c fix typo
Caught while compiling polly without cloog:

../tools/polly/lib/RegisterPasses.cpp:77: error: use of enum 'CodegenChoice' without previous declaration

llvm-svn: 168624
2012-11-26 22:16:19 +00:00
Sebastian Pop 05c1f00cae remove dead code
llvm-svn: 168621
2012-11-26 22:07:30 +00:00
Sebastian Pop b35ae612ea remove unused flag
llvm-svn: 168620
2012-11-26 22:07:27 +00:00
Tobias Grosser c1b6cec0e7 Make polly -Wdocumentation clean
llvm-svn: 168311
2012-11-19 12:26:25 +00:00
Tobias Grosser 81a1c75035 Dependences: Add support to calculate memory based dependences
Instead of calculating exact value (flow) dependences, it is also possible to
calculate memory based dependences. Sometimes memory based dependences are a lot
easier to calculate. To evaluate the benefits, we add an option to calculate
memory based dependences (use -polly-value-dependences=false).

llvm-svn: 167251
2012-11-01 21:28:32 +00:00
Tobias Grosser 531891e980 ScopDetection: Print line numbers of detected scops
If the flags '-polly-report -g' are given, we print file name and line numbers
for the beginning and end of all detected scops.

  linear-algebra/kernels/gemm/gemm.c:23: Scop start
  linear-algebra/kernels/gemm/gemm.c:42: Scop end
  linear-algebra/kernels/gemm/gemm.c:77: Scop start
  linear-algebra/kernels/gemm/gemm.c:82: Scop end

llvm-svn: 167235
2012-11-01 16:45:20 +00:00
Tobias Grosser 5d01691d76 Revert multiple adress space changes in Polly
llvm-svn: 167234
2012-11-01 16:45:18 +00:00
Tobias Grosser ebe8c8cea2 Codegen: Selectively copy in array addresses for OpenMP code
The detection of values that need to be copied in to the generated OpenMP
subfunction also detects the array base addresses needed in the SCoP. Hence, it
is not necessary to unconditionally copy all the base addresses to the generated
function.

Test cases are modified to reflect this change. Arrays which are global
variables do not occur in the struct passed to the subfunction anymore. A test
case for base address copy-in is added in copy_in_array.{c,ll}.

Committed with slight modifications

Contributed by:  Armin Groesslinger <armin.groesslinger@uni-passau.de>

llvm-svn: 167215
2012-11-01 05:34:55 +00:00
Tobias Grosser 177982c478 CodeGen: Add scop-parameters to the OpenMP context
In addition to the arrays and clast variables a SCoP statement may also refer to
values defined before the SCoP or to function arguments. Detect these values and
add them to the set of values passed to the function generated for OpenMP
parallel execution of a clast.

Committed with additional test cases and some refactoring.

Contributed by:  Armin Groesslinger  <armin.groesslinger@uni-passau.de>

llvm-svn: 167214
2012-11-01 05:34:48 +00:00
Tobias Grosser a17f666f99 Codegen: Copy and restore the ValueMap and ClastVars explicitly
When generating OpenMP or GPGPU code the original ValueMap and ClastVars must be
kept. We already recovered the original ClastVars by reverting the changes, but
we did not keep the content of the ValueMap. This patch keeps now an explicit
copy of both maps and restores them after generating OpenMP or GPGPU code.

This is an adapted version of a patch contributed by:
Armin Groesslinger  <armin.groesslinger@uni-passau.de>

llvm-svn: 167213
2012-11-01 05:34:35 +00:00
Chandler Carruth f6562ed2d3 Another speculative commit to try to fix Polly's build. This is more delta than
I like to make w/o being able to build, but I don't have the dependencies to
build and test polly. I'll revert if the build bots don't like it.

llvm-svn: 166670
2012-10-25 08:43:18 +00:00
Chandler Carruth acdc5e812d Another fix for a build-bot reported API mismatch.
llvm-svn: 166668
2012-10-25 07:42:03 +00:00
Chandler Carruth 2435330ead Try to revive the Polly builders after this LLVM API change.
llvm-svn: 166666
2012-10-25 07:25:56 +00:00
Tobias Grosser 0c55514a43 autoconf/cmake: Always require isl code generation.
This change ensures that isl is only detected if it includes code generation
support. This allows us to remove a lot of conditional compilation and also
avoids missing test cases in case the feature is not available.

llvm-svn: 166403
2012-10-21 21:48:21 +00:00
Tobias Grosser 56ac181189 RegisterPasses: Remove unreachable default case in switch
llvm-svn: 166397
2012-10-21 18:31:27 +00:00
Tobias Grosser 28781423b2 isl scheduler: Do not fail when returning an empty band list
The bug was within isl. To fix it, we simply update the isl version that
is used by Polly. We still have some changes within Polly to be able to
write a proper test case.

Reported-by: Sameer Sahasrabuddhe <Sameer.Sahasrabuddhe@amd.com>
llvm-svn: 166021
2012-10-16 07:29:19 +00:00
Tobias Grosser c967d8e6e9 isl-codegen: Support '<' and '>'
Previously isl always generated '<=' or '>='. However, in many cases '<' or '>'
leads to simpler code. This commit updates isl and adds the relevant code
generation support to Polly.

llvm-svn: 166020
2012-10-16 07:29:13 +00:00
Micah Villmow 7a3d8209c3 Move TargetData to DataLayout to fix build breakage caused by LLVM r16540
llvm-svn: 165408
2012-10-08 17:26:19 +00:00
Tobias Grosser 660b58ddab Rename TargetData -> DataLayout
Contributed by: Sameer Sahasrabuddhe <sameer.sahasrabuddhe@amd.com>

llvm-svn: 165387
2012-10-08 08:56:52 +00:00
Tobias Grosser 6a2617b874 ScopLib: Support negated access functions.
Scoplib only supports access functions, but not the more generic
access relations. This commit now also supports access functions
that where not directly expresses as A[sub] with sub = i + 5b,
but with A[sub] with -sub = -i + (-5b).

Test case to come.

Contributed by: Dustin Feld <d3.feld@gmail.com>

llvm-svn: 165379
2012-10-07 17:43:23 +00:00
Tobias Grosser 8a5bc6edca Add a new isl based code generation
This pass implements a new code generator that uses the code generation
algorithm included in isl.

For the moment the new code generation is limited to sequential code.

llvm-svn: 165037
2012-10-02 19:50:43 +00:00
Tobias Grosser 0934e70e6e Add an ast pretty printer pass based on the isl code generator
llvm-svn: 165036
2012-10-02 19:50:38 +00:00
Tobias Grosser 29ebecb11a Bailout if libpluto finds no schedule
Older versions of libpluto crashed, if no schedule was found. Recent
versions return NULL. We detect this and keep the original schedule.

llvm-svn: 164376
2012-09-21 16:24:13 +00:00
Tobias Grosser ed29566c4e ScopInfo: Align parameters when using -polly-allow-nonaffine
This ensures that the isl sets/maps we operate on have the same parameter
dimensions. Operations on objects with different parameter dimensions are not
allow and trigger assertions.

llvm-svn: 163618
2012-09-11 13:50:21 +00:00
Tobias Grosser eeb776a41f SCEVValidator: Add debug output that gives the reason for invalid expressions
llvm-svn: 163472
2012-09-08 14:00:37 +00:00
Tobias Grosser 6eaafb7288 Remove dead code
This code has been replaced by the SCEVValidator a while ago.

llvm-svn: 163471
2012-09-08 14:00:32 +00:00
Tobias Grosser 0b5a1959f4 ScopGraphPrinter: Escape error message
Otherwise a '"' in the error message, yields an invalid .dot file.

llvm-svn: 163466
2012-09-08 08:31:55 +00:00
Tobias Grosser ad41c4ce20 Add dependency to intrinsics_gen
The IndVarSimplify pass in Polly uses the intrinsics header. We need to ensure
that the header is generated, before we use it. This patch fixes the problem
for the cmake build (it did not show up in the autoconf one).

Contributed by:   Sameer Sahasrabuddhe  <sameer.sahasrabuddhe@amd.com>

llvm-svn: 163130
2012-09-04 08:19:12 +00:00
Tobias Grosser cd95b77330 Pocc: Fix some bugs in the PoCC optimizer pass
This includes:
  - The isl_id of the domain of the scattering must be copied from the original
    domain
  - Remove outdated references to a 'FinalRead' statement
  - Print of the Pocc output, if -debug is provided.
  - Add line breaks to some error messages.

Reported and Debugged by:  Dustin Feld  <d3.feld@gmail.com>

llvm-svn: 162901
2012-08-30 11:49:38 +00:00
Tobias Grosser 4a7527e0eb Pluto: Print pluto input in debugging mode
llvm-svn: 162900
2012-08-30 11:49:31 +00:00
Tobias Grosser 882a283946 Dependences: Print dependences in -analyze output
The dependency printing was accidentally removed in during a previous
restructuring.

llvm-svn: 162662
2012-08-27 08:44:15 +00:00
Tobias Grosser 6f9465591e PoCC: Simplify condition
llvm-svn: 162555
2012-08-24 13:56:56 +00:00
Tobias Grosser 4a67e01216 Sort includes
llvm-svn: 162554
2012-08-24 13:54:40 +00:00
Tobias Grosser c8fc2d7045 PoCC: Adapt to earlier vectorizer changes
llvm-svn: 162553
2012-08-24 13:54:36 +00:00
Tobias Grosser 6217e18a7d Add preliminary implementation for GPGPU code generation.
Translate the selected parallel loop body into a ptx string and run it with the
cuda driver API. We limit this preliminary implementation to target the
following special test cases:

  - Support only 2-dimensional parallel loops with or without only one innermost
    non-parallel loop.
  - Support write memory access to only one array in a SCoP.

The patch was committed with smaller changes to the build system:

There is now a flag to enable gpu code generation explictly. This was required
as we need the llvm.codegen() patch applied on the llvm sources, to compile this
feature correctly. Also, enabling gpu code generation does not require cuda.
This requirement was removed to allow 'make polly-test' runs, even without an
installed cuda runtime.

Contributed by:  Yabin Hu  <yabin.hwu@gmail.com>

llvm-svn: 161239
2012-08-03 12:50:07 +00:00
Tobias Grosser 5a2925c6a1 cmake: Fix building of Polly on Apple system
The Apple linker fails by default, if some function calls can not be resolved at
link time. However, all functions that are part of LLVM itself will not be
linked into Polly, but will be provided by the compiler that Polly is loaded
into.  Hence, during linking we need to ignore failures due to unresolved
function calls.

llvm-svn: 161234
2012-08-03 07:12:07 +00:00
Tobias Grosser 8ea010b6b1 Add missing dependency to cmake system
llvm-svn: 161158
2012-08-02 07:47:37 +00:00
Tobias Grosser c11349c55a Add support for libpluto as the scheduling optimizer.
llvm-svn: 161157
2012-08-02 07:47:26 +00:00
Hongbin Zheng 7aee737062 IndependentBLocks: Do not visit the same instruction twice when moving the
operand tree.

This patch fix Bug 13491, and the original "FIXME" in IndependentBlocks.cpp.

Patched by Kevin Fan<kevin.fan@gmail.com>.

llvm-svn: 161105
2012-08-01 08:46:11 +00:00
Tobias Grosser 25184fe925 Allow cast instructions within scops
Cast instruction do not have side effects and can consequently be part of a
scop. We special cased them earlier, as they may be problematic within array
subscripts or loop bounds. However, the scalar evolution validator already
checks for them such that there is no need to also check the instructions within
the basic blocks.  Checking them is actually overly conservative as the precence
of casts may invalidate a scop, even though scalar evolution is not influenced
by it.

llvm-svn: 160261
2012-07-16 10:57:32 +00:00
Tobias Grosser 6cc23b07e6 Revert "Add preliminary implementation for GPGPU code generation."
I did not take into account, that this patch fails to compile without the
llvm.codegen patch applied. This breaks buildbots.

I revert this until we found a solution to commit this without buildbots
complaining.

This reverts commit cb43ab80e94434e780a66be3b9a6ad466822fe33.

llvm-svn: 160165
2012-07-13 07:44:56 +00:00
Tobias Grosser b299d28181 Add preliminary implementation for GPGPU code generation.
Translate the selected parallel loop body into a ptx string and run it
with cuda driver API. We limit this preliminary implementation to
target the following special test cases:
  - Support only 2-dimensional parallel loops with or without only one
    innermost non-parallel loop.
  - Support write memory access to only one array in a SCoP.

Contributed by:  Yabin Hu <yabin.hwu@gmail.com>

llvm-svn: 160164
2012-07-13 07:21:00 +00:00
Hongbin Zheng cea35f60d5 Add an Instruction member to MemoryAccess Class.
Patched by TangKK <dengjunqi06323011@hotmail.com>.

llvm-svn: 159808
2012-07-06 06:47:03 +00:00
Hongbin Zheng 454e8f9ee8 Add stringFromIslObj support for various isl_objs.
Patched by JunQi<dengjunqi06323011@hotmail.com>.

llvm-svn: 159735
2012-07-05 08:55:31 +00:00
Hongbin Zheng 5205e0c40e Refactor: Use generic internal function template in GICHelper.cpp to avoid duplication.
llvm-svn: 159734
2012-07-05 08:42:39 +00:00
Chandler Carruth c55b598dc2 Speculative update to Polly for LLVM r159421 which moved IRBuilder.h.
llvm-svn: 159423
2012-06-29 12:39:49 +00:00
Tobias Grosser 3cc99748b6 Fix some coding convention problems.
llvm-svn: 158081
2012-06-06 16:33:15 +00:00
Tobias Grosser baa1ac260b CLooG: Do not take into account the context
CLooG and the CLooG based code generation does not yet correctly derive the
types of the expressions, but just uses i64 for everything. This is incorrect,
but works normally pretty well. However, the recent change of adding parameter
bounds to the context made CLooG generate expressions that contain a lot of very
large integers that possibly don't fit into an i64. This broke the code
generation for several benchmarks.

To get the CLooG based code generation working again, we just don't take into
account any constraints in the context. This brings us back to the theoretical
incorrect, but in practice generally correct code.

The next step will be the isl based code generation. Here we will derive
automatically correct types.

llvm-svn: 158015
2012-06-05 19:31:08 +00:00
Tobias Grosser 084d8f7d4c ScopInfo: Store ScopStmt pointer in the domain
Store a pointer to each ScopStmt in the isl_id associated with the space of its
domain. This will later allow us to recover the statement during code
generation with isl.

llvm-svn: 157607
2012-05-29 09:29:44 +00:00
Tobias Grosser 400a4ac658 Mark the increments of the generated induction variables 'NSW'
In general, all code that we produce is NSW.

llvm-svn: 157606
2012-05-29 09:11:59 +00:00
Tobias Grosser 3a275d20dd Move executeScopConditionally() into its own file
We will reuse this function for the isl code generator.

llvm-svn: 157605
2012-05-29 09:11:54 +00:00
Tobias Grosser 0a91f3220b Move CLooG.h into include/polly/CodeGen/
llvm-svn: 157604
2012-05-29 09:11:46 +00:00
Tobias Grosser 29666113fd ScheduleOptimizer: Simplify some code
We now use isl_map_equate, which makes the code a lot simpler.

llvm-svn: 157246
2012-05-22 10:47:31 +00:00
Tobias Grosser 18daacad61 ScopInfo: Add parameter bounds to context
Derive the maximal and minimal values of a parameter from the type it has. Add
this information to the scop context. This information is needed, to derive
optimal types during code generation.

llvm-svn: 157245
2012-05-22 10:47:27 +00:00
Tobias Grosser 3b2cf96bae Replace some asserts with llvm_unreachable
llvm-svn: 157244
2012-05-22 10:47:21 +00:00
Tobias Grosser 42b69e5745 ScopInfo: SCEVUnknowns are always parameters
There is no need for special code to handle SCEVUnknowns. SCEVUnkowns are always
parameters and will be handled by the generic parameter handling code in
visit().

llvm-svn: 157243
2012-05-22 10:47:17 +00:00
Tobias Grosser e192b23f5e Move isParallelFor into CodeGeneration
This removes another include of CLooG header files.

llvm-svn: 157242
2012-05-22 08:46:07 +00:00
Sebastian Pop 8b7f01c6a1 make registerPollyPreoptPasses static
llvm-svn: 156326
2012-05-07 21:27:11 +00:00
Sebastian Pop 5cc8caf88d make registerPollyPasses static, remove param
llvm-svn: 156325
2012-05-07 21:27:09 +00:00
Sebastian Pop e1f6554ed8 add some more missing ifdef CLOOG_FOUND
llvm-svn: 156306
2012-05-07 16:35:11 +00:00
Sebastian Pop 082cea8616 add a check for ISL codegen at configure time
llvm-svn: 156305
2012-05-07 16:20:07 +00:00
Hongbin Zheng 6879421727 Allow polly ask bb-vectorizer to vectorize the loop body.
llvm-svn: 156254
2012-05-06 10:22:19 +00:00
Sebastian Pop 775d8e65e8 fix typo
llvm-svn: 156210
2012-05-04 21:36:08 +00:00
Chandler Carruth 30dfdfca3b Try to fix the Polly build while I'm trying to get it to build at all locally.
llvm-svn: 156207
2012-05-04 21:24:27 +00:00
Chandler Carruth d6447953f2 Update Polly to match the LLVM interface change in r156196.
llvm-svn: 156203
2012-05-04 20:57:29 +00:00
Sebastian Pop c200977905 compile cloog code only when CLOOG_FOUND is set
llvm-svn: 156199
2012-05-04 20:30:03 +00:00
Sebastian Pop de613265c5 move Cloog.cpp to CodeGen
llvm-svn: 156184
2012-05-04 18:15:57 +00:00
Tobias Grosser 14afc07577 Fix typo.
Reported by: Andreas Simbuerger

llvm-svn: 156171
2012-05-04 12:11:01 +00:00
Tobias Grosser 913fa54836 ScopDection: Improve status message for non-affine memory accesses.
llvm-svn: 156170
2012-05-04 11:26:52 +00:00
Tobias Grosser ca9a2913b7 Remove unused function
Suggested by: Sebastian Pop

llvm-svn: 155863
2012-04-30 23:49:05 +00:00