Commit Graph

1958 Commits

Author SHA1 Message Date
Tobias Grosser b09455dee0 Store EscapeMap as Value* instead of AllocInst
This currently does not change the behavior in Polly, but it allows us to later
also overwrite the EscapeMap with our GlobalMap.

llvm-svn: 247970
2015-09-18 06:01:11 +00:00
Tobias Grosser 6f36d9ab01 Delinearize multi-dimensional arrays through bitcasts
In some cases instcombine introduces bitcasts that slightly obfuscate the
multi-dimensionality of an array. This patch teaches our fixed-size
delinearization how to look through bitcasts.

llvm-svn: 247928
2015-09-17 20:16:21 +00:00
Tobias Grosser 0537f41de5 Do not use the assumed context in the dependence analysis any more
This information is implicitly available through the multi-dimensionality of
memory accesses. This reduces compile time for 3mm from 430ms to 400ms and
should generally benefit compile time for cases where the assumed context
is complex.

llvm-svn: 247907
2015-09-17 17:28:19 +00:00
Tobias Grosser 5fd8c0961e Model fixed-size multi-dimensional arrays if possible multi-dimensional
If the GEP instructions give us enough insights, model scalar accesses as
multi-dimensional (and generate the relevant run-time checks to ensure
correctness). This will allow us to simplify the dependence computation in
a subsequent commit.

llvm-svn: 247906
2015-09-17 17:28:15 +00:00
Tobias Grosser faf8f6f62e Extract function that derives the index expressions of a GEP instruction [NFC]
We currently use this functionality to add run-time assumptions that check its
in-bound property.

llvm-svn: 247893
2015-09-17 15:47:52 +00:00
Tobias Grosser e375d8058a Add option to enable/disable reduction usage in dependence analysis
llvm-svn: 247781
2015-09-16 09:50:17 +00:00
Johannes Doerfert 883f8c1d2f Use modulo semantic to generate non-integer-overflow assumptions
This will allow to generate non-wrap assumptions for integer expressions
  that are part of the SCoP. We compare the common isl representation of
  the expression with one computed with modulo semantic. For all parameter
  combinations they are not equal we can have integer overflows.

  The nsw flags are respected when the modulo representation is computed,
  nuw and nw flags are ignored for now.

  In order to not increase compile time to much, the non-wrap assumptions
  are collected in a separate boundary context instead of the assumed
  context. This helps compile time as the boundary context can become
  complex and it is therefor not advised to use it in other operations
  except runtime check generation. However, the assumed context is e.g.,
  used to tighten dependences. While the boundary context might help to
  tighten the assumed context it is doubtful that it will help in practice
  (it does not effect lnt much) as the boundary (or no-wrap assumptions)
  only restrict the very end of the possible value range of parameters.

  PET uses a different approach to compute the no-wrap context, though lnt runs
  have shown that this version performs slightly better for us.

llvm-svn: 247732
2015-09-15 22:52:53 +00:00
Johannes Doerfert cef616fe2d Use blocks instead of domains in SCEVAffinator
Due to the new domain generation, the SCoP keeps track of the domain
  for all blocks, thus the SCEVAffinator can now work with blocks to avoid
  duplication of the domains.

llvm-svn: 247731
2015-09-15 22:49:04 +00:00
Johannes Doerfert b20f151d56 Coalesce the constructed domains early
llvm-svn: 247728
2015-09-15 22:11:49 +00:00
Michael Kruse da8d6203f4 Fix after renamed CMake cache entry
LLVM_EXTERNAL_CLANG_BUILD was changed to LLVM_TOOL_CLANG_BUILD in
r242059.

llvm-svn: 247675
2015-09-15 10:51:15 +00:00
Michael Kruse fa62b1763c Run polly-check-format with unit tests
Add polly-check-format as dependency of check-polly if clang-format is 
available in the same build.

Differential Revision: http://reviews.llvm.org/D12850

llvm-svn: 247600
2015-09-14 19:11:48 +00:00
Michael Kruse 69f3788c36 Revise polly-{update|check}-format targets
Summary:
Make clang-format run on each file independently using
add_custom_format (instead using a shell script in utils/). The targets
polly-{update|check}-format depend on these.

The primary motivation is to make them work on Windows, but also
improves them generally:
- Each file update/check can run in parallel (Although they do not take
  long to run anyway)
- Implicit dependency on clang-format, so it recompiles if necessary
- polly-check-format shows the formatting difference if failing

Differential Revision: http://reviews.llvm.org/D12837

llvm-svn: 247581
2015-09-14 16:59:50 +00:00
Michael Kruse 2846877d88 Replace some SmallVector-typed parameters by ArrayRef
ArrayRef avoids making implementation details such as the number of stack elements to be part of the function signature.

llvm-svn: 247572
2015-09-14 15:45:33 +00:00
Tobias Grosser aaadc5302c [test] Load Polly before using the polly flags
llvm-svn: 247551
2015-09-14 11:49:05 +00:00
Johannes Doerfert 334f9e87c6 [FIX] XFAIL test that depends on pending LLVM commit
llvm-svn: 247550
2015-09-14 11:45:34 +00:00
Tobias Grosser 0b13890042 Fix formatting
llvm-svn: 247549
2015-09-14 11:38:06 +00:00
Johannes Doerfert e114dc024e [FIX] Handle error blocks in non-affine regions correctly
llvm-svn: 247545
2015-09-14 11:15:58 +00:00
Johannes Doerfert 40fa56f59f [FIX] Allow the whole SCoP to be a non-affine subregion
llvm-svn: 247544
2015-09-14 11:15:07 +00:00
Johannes Doerfert 36255eecd8 Revert r247278 "Disable support for modulo expressions"
This reverts commit 00c5b6ca8832439193036aadaaaee92a43236219.

  We can handle modulo expressions in the domain again.

llvm-svn: 247542
2015-09-14 11:14:23 +00:00
Johannes Doerfert ca1e38fa43 Propagate exit conditions as described in the PET paper
At some point we build loop trip counts using this method. It was replaced by
  a simpler trick that works only for affine (e.g., not modulo) constraints and
  relies on the removal of unbounded parts. In order to allow modulo constrains
  again we go back to the former, more accurate method.

llvm-svn: 247540
2015-09-14 11:12:52 +00:00
Michael Kruse 9d08009dff Merge TempScop into Scop
Summary:
TempScop is basically a holder for AccFuncMap, the dictionary from BasicBlocks to IRAccess lists. We move the list into polly::Scop and remove the polly::TempScop class.

There is one small change in behavior: If ScopInfo finds that its AssumedContext is impossible, it bails out by deleting the Scop object. The TempScop::print (invoked with opt -polly-scops -analyze) cannot print the AccFuncMap anymore as it would with a separate TempScop.

Differential Revision: http://reviews.llvm.org/D12803

llvm-svn: 247480
2015-09-11 21:41:48 +00:00
Michael Kruse 84bf8a3bc4 Introspect llvm-config --assertion-mode in cmake out-of-tree builds
When compiling Polly without LLVM sources but with system-installed
LLVM, the build process would not honor the LLVM_ENABLE_ASSERTIONS
setting LLVM was compiled with, but effectively assume that it is
switched off when compiling. During unit-tests llvm-lit would still
query the LLVM_ENABLE_ASSERTIONS flag and enable tests which require
assertions. Even if enabled for LLVM, Polly does not output its debug
info and statistics in this this mode such that 7 tests fail.

To fix, we query llvm-config --assertion-mode and if on, enable
assertions as HandleLLVMOptions.cmake would do.

We cannot reliably use HandleLLVMOptions.cmake itself as the host's
LLVM build might have been built using automake and distributions
change file locations (e.g. Debian to
/usr/share/llvm-${VERSION}/cmake/HandleLLVMOptions.cmake).

llvm-svn: 247470
2015-09-11 20:47:14 +00:00
Tobias Grosser 98cf5696fa Fix some typos in comments
llvm-svn: 247441
2015-09-11 18:26:59 +00:00
Sylvestre Ledru 3e94031632 Update autoconf too: Analysis/TempScopInfo.cpp has been removed
llvm-svn: 247419
2015-09-11 15:05:29 +00:00
Michael Kruse 07d5df4db8 Fix out-of-range access in test case
The function use_after_scop would iterate from 0 to 1024 and accessing element A[1024] where A has only valid indexes from 0 to 1023. Polly detects the situation of unconditionally undefined behavior and bail out in ScopInfo as non-feasible for optimization.

Other tests add impossible context assumptions as well, hance might show the same problem.

llvm-svn: 247412
2015-09-11 13:45:05 +00:00
Michael Kruse ef3cf01d1c Add Polly header files to IDE projects
llvm-svn: 247398
2015-09-11 09:01:55 +00:00
David Blaikie 0afc1e4ecc Update polly for explicit type parameter to global alias change
llvm-svn: 247382
2015-09-11 03:42:32 +00:00
Tobias Grosser 34b11fc197 XFAIL tests that require an additional LLVM patch to work
llvm-svn: 247338
2015-09-10 21:32:29 +00:00
Johannes Doerfert 90db75ed24 Runtime error check elimination
Hoist runtime checks in the loop nest if they guard an "error" like event.
  Such events are recognized as blocks with an unreachable terminator or a call
  to the ubsan function that deals with out of bound accesses. Other "error"
  events can be added easily.

  We will ignore these blocks when we detect/model/optmize and code generate SCoPs
  but we will make sure that they would not have been executed using the assumption
  framework.

llvm-svn: 247310
2015-09-10 17:51:27 +00:00
Johannes Doerfert f4fa9879fb [FIX] Do not assume only one loop can be left at a time
llvm-svn: 247291
2015-09-10 15:53:59 +00:00
Johannes Doerfert b68cffb5df Allow general loops with one latch
As we do not rely on ScalarEvolution any more we do not need to get
  the backedge taken count. Additionally, our domain generation handles
  everything that is affine and has one latch and our ScopDetection will
  over-approximate everything else.

  This change will therefor allow loops with:
    - one latch
    - exiting conditions that are affine

  Additionally, it will not check for structured control flow anymore.
  Hence, loops and conditionals are not necessarily single entry single
  exit regions any more.

Differential Version: http://reviews.llvm.org/D12758

llvm-svn: 247289
2015-09-10 15:27:46 +00:00
Michael Kruse d868b5d509 Merge TempScopInfo into ScopInfo
The TempScopInfo (-polly-analyze-ir) pass is removed and its work taken
over by ScopInfo (-polly-scops). Several tests depend on
-polly-analyze-ir and use -polly-scops instead which for the moment
prints the output of both passes. This again is not expected by some
other tests, especially those with negative searches, which have been
adapted.

Differential Version: http://reviews.llvm.org/D12694

llvm-svn: 247288
2015-09-10 15:25:24 +00:00
Michael Kruse 9cc1b9d31e Clean-up unit tests
Remove redundant flags and duplicate invocations of the same test.

llvm-svn: 247285
2015-09-10 14:42:09 +00:00
Johannes Doerfert 32ae76e7f9 [NFC] Remove obsolete arguments
Remove some arguments that survived the recent changes but are not
  used any more.

llvm-svn: 247280
2015-09-10 13:12:02 +00:00
Johannes Doerfert 5b9ff8b667 Replace ScalarEvolution based domain generation
This patch replaces the last legacy part of the domain generation, namely the
ScalarEvolution part that was used to obtain loop bounds. We now iterate over
the loops in the region and propagate the back edge condition to the header
blocks. Afterwards we propagate the new information once through the whole
region. In this process we simply ignore unbounded parts of the domain and
thereby assume the absence of infinite loops.

  + This patch already identified a couple of broken unit tests we had for
    years.
  + We allow more loops already and the step to multiple exit and multiple back
    edges is minimal.
  + It allows to model the overflow checks properly as we actually visit
    every block in the SCoP and know where which condition is evaluated.
  - It is currently not compatible with modulo constraints in the
    domain.

Differential Revision: http://reviews.llvm.org/D12499

llvm-svn: 247279
2015-09-10 13:00:06 +00:00
Johannes Doerfert 171f07ed71 Disable support for modulo expressions
The support for modulo expressions is not comlete and makes the new
  domain generation harder. As the currently broken domain generation
  needs to be replaced, we will first swap in the new, fixed domain
  generation and make it compatible with the modulo expressions later.

llvm-svn: 247278
2015-09-10 12:56:46 +00:00
Michael Kruse 7bf3944d23 Merge TempScopInfo.{cpp|h} into ScopInfo.{cpp|h}
This prepares for a series of patches that merges TempScopInfo into ScopInfo to
reduce Polly's code complexity. Only ScopInfo.{cpp|h} will be left thereafter.
Moving the code of TempScopInfo in one commit makes the mains diffs simpler to
understand.

In detail, merging the following classes is planned:
TempScopInfo into ScopInfo
TempScop into Scop
IRAccess into MemoryAccess

Only moving code, no functional changes intended.

Differential Version: http://reviews.llvm.org/D12693

llvm-svn: 247274
2015-09-10 12:46:52 +00:00
Chandler Carruth 66ef16b289 [PM] Update Polly for the new AA infrastructure landed in r247167.
llvm-svn: 247198
2015-09-09 22:13:56 +00:00
Michael Kruse d16550de92 Fix typo: zycle -> cycle [NFC]
llvm-svn: 247172
2015-09-09 18:20:31 +00:00
Johannes Doerfert 7ca8dc2d2d Disable support for pointer expressions
The support for pointer expressions is broken as it can only handle
  some patterns in the IslExprBuilder. We should to treat pointers in
  expressions the same as integers at some point and revert this patch.

llvm-svn: 247147
2015-09-09 14:19:04 +00:00
Michael Kruse da943ce613 Generate gitversion.h in autoconf builds
Add a custom makefile rule to generate lib/External/isl/gitversion.h
from GIT_HEAD_ID and trigger it using BULIT_SOURCES to ensure the file
exists before compilation starts.

The latest ISL creates gitversion.h from Makefile.am only, instead also
from configure.ac in previous version. While the Polly build invokes
configure, it does not invoke ISL's make such that the file was missing.

Invoking ISL's make would come with additional problems such as
triggering automake because of not preserved file time stamps.
Re-running automake might not be successful on other system
configurations for instance because it was preconfigured without
--with-clang option.

llvm-svn: 247142
2015-09-09 13:15:11 +00:00
Tobias Grosser f1ac57c6cd IslNodeBuilder: Add virtual function to obtain the schedule of an ast node
Not all users of our IslNodeBuilder will attach scheduling information to the
AST in the same way IslAstInfo is doing it today. By going through a virtual
function when extracting the schedule of an AST node other users can provide
their own functions for extract scheduling information in case they attach
scheduling information in a different way to the AST nodes.

No functional change for Polly itself intended.

llvm-svn: 247126
2015-09-09 09:24:38 +00:00
Johannes Doerfert 717b866798 Allow PHI nodes in the region exit block
While we do not need to model PHI nodes in the region exit (as it is not part
  of the SCoP), we need to prepare for the case that the exit block is split in
  code generation to create a single exiting block. If this will happen, hence
  if the region did not have a single exiting block before, we will model the
  operands of the PHI nodes as escaping scalars in the SCoP.

Differential Revision: http://reviews.llvm.org/D12051

llvm-svn: 247078
2015-09-08 21:44:27 +00:00
Tobias Grosser 02e6589bda Move more compile-time bailouts into -polly-detect-unprofitable
Instead of having two separate options
-polly-detect-scops-in-functions-without-loops and
-polly-detect-scops-in-regions-without-loops we now just use
-polly-detect-unprofitable to force the detection of scops ignoring any compile
time saving bailout heuristics.

llvm-svn: 247057
2015-09-08 19:46:41 +00:00
Tobias Grosser b8f3690e15 Add first run-time bounds elimination test case
llvm-svn: 247020
2015-09-08 16:02:19 +00:00
Tobias Grosser a89dc57b41 Do not use '.' in subfunction names
Certain backends, e.g. NVPTX, do not support '.' in function names. Hence,
we ensure all '.' are replaced by '_' when generating function names for
subfunctions. For the current OpenMP code generation, this is not strictly
necessary, but future uses cases (e.g. GPU offloading) need this issue to be
fixed.

llvm-svn: 246980
2015-09-08 06:22:17 +00:00
Tobias Grosser 12e650d682 Drop alias metadata in checks of RuntimeDebugBuilder test
Our alias metadata is currently not emitted in a deterministic order. As it
is not needed in this test, we just drop it for now (but keep in mind to fix
this).

llvm-svn: 246942
2015-09-06 08:59:50 +00:00
Tobias Grosser 86bc93a9b2 Add option -polly-codegen-add-debug-printing
When this option is enabled, Polly will emit printf calls for each scalar
load/and store which dump the scalar value loaded/stored at run time.

This patch also refactors the RuntimeDebugBuilder to use variadic templates
when generating CPU printfs. As result, it now becomes easier to print
strings that consist of a set of arguments. Also, as a single printf
call is emitted, it is more likely for such strings to be emitted atomically
if executed multi-threaded.

llvm-svn: 246941
2015-09-06 08:47:57 +00:00
Tobias Grosser e58d358171 RuntimeDebugPrinter: Simplify code [NFC]
llvm-svn: 246940
2015-09-06 07:17:54 +00:00
Tobias Grosser e3d8c05c5f Add some more documentation and structure to the collection of subtree references
Some of the structures are renamed, subfunction introduced to clarify the
individual steps and comments are added describing their functionality.

llvm-svn: 246929
2015-09-05 15:45:25 +00:00
Tobias Grosser abcec37f64 IslNodeBuilder: Only obtain the isl_ast_build, when needed
In the common case, the access functions are not modified, hence there is no
need to obtain the IslAstBuild context at all. This should not only be minimally
faster, but this also allows the IslNodeBuilder to work on asts that are not
annotated with isl_ast_builds as long as the memory accesses are not modified.

llvm-svn: 246928
2015-09-05 13:03:57 +00:00
Tobias Grosser 8eae8361fc RegionGenerator: Do not modify GlobalMaps
By inspection the update of the GlobalMaps in the RegionGenerator seems unneed,
and is removed as also no test cases fail when dropping this. Johannes Doerfert
confirmed that this is indeed save:

"I think that code was needed when we did not use the scalar codegen by default.
Now everything defined in a non-affine region should be communicated via memory
and reloaded in the user block. Hence, we should be good removing this code."

llvm-svn: 246926
2015-09-05 11:26:30 +00:00
Tobias Grosser 113a4a4cbb Add forgotten .jscop file
llvm-svn: 246925
2015-09-05 10:58:13 +00:00
Tobias Grosser 72b80672d9 OpenMP: Name the values passed to the subfunciton according to the original llvm::Values
llvm-svn: 246924
2015-09-05 10:41:19 +00:00
Tobias Grosser 0d8874c0f6 OpenMP codegen: support generation of multi-dimensional access functions
When computing the index expressions for new, multi-dimensional memory accesses
these new index expressions may reference original llvm::Values that are not
transfered into the OpenMP subfunction. Using GlobalMap we now replace
references to such values with the rewritten values that have e.g. been passed
to the OpenMP subfunction.

llvm-svn: 246923
2015-09-05 10:32:56 +00:00
Tobias Grosser bc13260775 BlockGenerator: Make GlobalMap a member variable
The GlobalMap variable used in BlockGenerator should always reference the same
list througout the entire code generation, hence we can make it a member
variable to avoid passing it around through every function call.

History: Before we switched to the SCEV based code generation the GlobalMap
also contained a mapping form old to new induction variables, hence it was
different for each ScopStmt, which is why we passed it as function argument
to copyStmt. The new SCEV based code generation now uses a separate mapping
called LTS -> LoopToSCEV that maps each original loop to a new loop iteration
variable provided as a SCEVExpr. The GlobalMap is currently mostly used for
OpenMP code generation, where references to parameters in the original function
need to be rewritten to the locations of these variables after they have been
passed to the subfunction.

Suggested-by: Johannes Doerfert <doerfert@cs.uni-saarland.de>
llvm-svn: 246920
2015-09-05 09:56:54 +00:00
Tobias Grosser 6f73008506 Allow the import of multi-dimensional access functions
Originally, we disallowed the import of multi-dimensional access functions due
to our code generation not supporting the generation of new address expressions
for multi-dimensional memory accesses. When building our run-time alias check
infrastructure we added code generation support for multi-dimensional address
calculations.  Hence, we can now savely allow the import of new
multi-dimensional access functions.

llvm-svn: 246917
2015-09-05 07:46:47 +00:00
Tobias Grosser 166c422952 Use uppercase variable names [NFC]
llvm-svn: 246916
2015-09-05 07:46:40 +00:00
Tobias Grosser 2df884f95a ScopInfo: use project_out instead of remove_dims
By just removing dimensions (and the constraints they are involved in) we
may loose information about the dimensions we do not remove. By instead
using project_out, we are sure all constraints on the outer dimensions are
preserved.

No test case, as this error condition is very unlikely to be triggered by
isl's current code. We still 'fix' this, as isl gives little guarantees
regarding the behavior of remove_divs.

llvm-svn: 246567
2015-09-01 18:17:41 +00:00
Tobias Grosser f560ca90ef Update isl to isl-0.15-129-gb086c90
llvm-svn: 246552
2015-09-01 15:42:13 +00:00
Tobias Grosser 1dcfb7a1e6 ScopInfo: Add test case for two loops following right after each other
This case probably does not happen for LLVM generated code that is in loop
simplify form, but Polly does support such kind of loops. This commit ensures we
have test coverage as well.

llvm-svn: 246543
2015-09-01 11:33:13 +00:00
Tobias Grosser 40820ca286 Fix another typo in the subloop counting
... as well as the corresponding test cases.

Thank's Johannes for finding this bug.

llvm-svn: 246483
2015-08-31 21:04:51 +00:00
Johannes Doerfert 5f912d3797 Do Not Model Unbounded Loops
Code generation currently does not expect unbounded loops. When
  using ISL to compute the loop trip count, if we find that the
  iteration domain remains unbounded, we invalidate the Scop by
  creating an infeasible context.

Contributed-by: Matthew Simpson <mssimpso@codeaurora.org>

This fixes PR24634.

Differential Revision: http://reviews.llvm.org/D12493

llvm-svn: 246477
2015-08-31 19:58:24 +00:00
Johannes Doerfert f08bd00229 Build the domains with correct number of dimensions
Instead of building domains with MaxLoopDepth dimensions, we now build
  the domains such that they have the right amount of dimensions all the
  time.

llvm-svn: 246443
2015-08-31 13:56:32 +00:00
Johannes Doerfert 4e8907f495 [NFC] Add isl_set output stream operator
llvm-svn: 246442
2015-08-31 13:54:36 +00:00
Tobias Grosser d213d52d0e Always use the branch instructions to model the PHI-node writes
Before this commit we did this only for Arguments or Constants, but indeed
an instruction may define a value a lot higher up in the dominance tree, but
the actual write generally needs to happen right before branching to the
PHI node. Otherwise, the writes of different branches into PHI nodes may get
intermixed if they lay higher up in the dominance tree.

llvm-svn: 246441
2015-08-31 13:45:54 +00:00
Tobias Grosser 050e0cbc0e ScopDetection: Correctly count the loops in a region
There is no reason the loops in a region need to touch either entry or exit
block. Hence, we need to look through all loops that may touch the region as
well as their children to understand if our region has at least two loops.

llvm-svn: 246433
2015-08-31 12:08:11 +00:00
Tobias Grosser 44b34b0e8a Also build scalar dependences for store instructions
While ignoring read-only scalar dependences it was not necessary to consider
store instructins, but as store instructions can be the target of a scalar
read-only dependency we need to consider them for the construction of scalar
read-only dependences.

llvm-svn: 246429
2015-08-31 11:15:00 +00:00
Tobias Grosser 9f3d55cf3d Generate scalar initialization loads at the beginning of the start BB
Our OpenMP code generation generated part of its launching code directly into
the start basic block and without this change the scalar initialization was
run _after_ the OpenMP threads have been launched. This resulted in
uninitialized scalar values to be used.

llvm-svn: 246427
2015-08-31 11:06:19 +00:00
Tobias Grosser f93451802a OpenMP-codegen: Correctly pass function arguments to subfunctions
Before we only checked if certain instructions can be expanded by us. Now we
check any value, including function arguments.

llvm-svn: 246425
2015-08-31 09:05:43 +00:00
Tobias Grosser 58758ef4ea Enable modeling of scalar read-only dependences
Even though these are not strictly necessary for sequential code generation,
we still model both for sequential and parallel code generation to reduce
the set of configurations that needs to be tested. If this turns out, against
what we currently see, to be significant overhead, we can decide to limit this
feature again to parallel code-generation use cases only.

llvm-svn: 246420
2015-08-31 06:46:32 +00:00
Tobias Grosser d86bf4271c Do not model scalar references to constant values
llvm-svn: 246418
2015-08-31 06:37:25 +00:00
Tobias Grosser 64c0ff4141 Add support for scalar dependences to OpenMP code generation
Scalar dependences between scop statements have caused troubles during parallel
code generation as we did not pass on the new stack allocation created for such
scalars to the parallel subfunctions. This change now detects all scalar
reads/writes in parallel subfunctions, creates the allocas for these scalar
objects, passes the resulting memory locations to the subfunctions and ensures
that within the subfunction requests for these memory locations will return the
rewritten values.

Johannes suggested as a future optimization to privatizing some of the scalars
in the subfunction.

llvm-svn: 246414
2015-08-31 05:52:24 +00:00
Johannes Doerfert 96425c2574 Traverse the SCoP to compute non-loop-carried domain conditions
In order to compute domain conditions for conditionals we will now
  traverse the region in the ScopInfo once and build the domains for
  each block in the region. The SCoP statements can then use these
  constraints when they build their domain.

  The reason behind this change is twofold:
    1) This removes a big chunk of preprocessing logic from the
       TempScopInfo, namely the Conditionals we used to build there.
       Additionally to moving this logic it is also simplified. Instead
       of walking the dominance tree up for each basic block in the
       region (as we did before), we now traverse the region only
       once in order to collect the domain conditions.
    2) This is the first step towards the isl based domain creation.
       The second step will traverse the region similar to this step,
       however it will propagate back edge conditions. Once both are in
       place this conditional handling will allow multiple exit loops
       additional logic.

Reviewers: grosser

Differential Revision: http://reviews.llvm.org/D12428

llvm-svn: 246398
2015-08-30 21:13:53 +00:00
Johannes Doerfert b1e3bbb7c9 [FIX] Keep a copy of the Domain set in the SCEVAffinator
llvm-svn: 246397
2015-08-30 19:52:06 +00:00
Tobias Grosser 2fc50df900 Do not store into a temporary twine
For some reason, this causes memory corruption issues. Let's just avoid it.

llvm-svn: 246396
2015-08-30 19:51:01 +00:00
Tobias Grosser c0091a77f9 Store scalar dependences from outside the scop into alloca locations
We already modeled read-only dependences to scalar values defined outside the
scop as memory reads and also generated read accesses from the corresponding
alloca instructions that have been used to pass these scalar values around
during code generation. However, besides for PHI nodes that have already been
handled, we failed to store the orignal read-only scalar values into these
alloc. This commit extends the initialization of scalar values to all read-only
scalar values used within the scop.

llvm-svn: 246394
2015-08-30 19:19:34 +00:00
Tobias Grosser b649e26a50 getNewScalarValue: Get ScalarMap directly from member variable [NFC]
There is no need to pass the ScalarMap to getNewScalarValue as this
map is (indirectly) used when calling getOrCreateScalarAlloca.

llvm-svn: 246390
2015-08-30 17:37:55 +00:00
Tobias Grosser 655a4570cd createScalarInitialization: Always store PHI-node value
The current code really tries hard to use getNewScalarValue(), which checks if
not the original value, but a possible copy or demoted value needs to be stored.
In this calling context it seems, that we _always_ use the ScalarValue that
comes from the incoming PHI node, but never any other value. As also no test
cases fail, it seems right to just drop this call to getNewScalarValue and
remove the parameters that are not needed any more.

Johannes suggested that code like this might be needed for parallel code
generation with offloading, but it was still unclear if/what exactly would
be needed. As the parallel code generation does currently not support scalars
at all, we will remove this code for now and add relevant code back when
complitng the support of scalars in the parallel code generation.

Reviewers: jdoerfert

Subscribers: pollydev, llvm-commits

Differential Revision: http://reviews.llvm.org/D12470

llvm-svn: 246389
2015-08-30 17:32:39 +00:00
Tobias Grosser e83a396b1d Ignore debug intrinsics and do not model their potential scalar metadata reads
Our code generation currently does not support scalar references to metadata
values. Hence, it would crash if we try to model scalar dependences to metadata
values. Fortunately, for one of the common uses, debug information, we can
for now just ignore the relevant intrinsics and consequently the issue of how
to model scalar dependences to metadata.

llvm-svn: 246388
2015-08-30 16:57:20 +00:00
Tobias Grosser 9c0ffe3a1d Remove some code duplication [NFC]
llvm-svn: 246387
2015-08-30 16:57:15 +00:00
Tobias Grosser fcfac082ea Minor code style improvement [NFC]
llvm-svn: 246386
2015-08-30 16:01:58 +00:00
Tobias Grosser 2985400a0e Remove isNew from getOrCreateAlloca
This commit drops some dead code. Specifically, there is no need to initialize
the virtual memory locations of scalars in BlockGenerator::handleOutsideUsers,
the function that initalizes the escape map that keeps track of out-of-scope
uses of scalar values. We already model instructions inside the scop that
are used outside the scope (escaping instructions) as scalar memory writes at
the position of the instruction. As a result, the virtual memory location of
this instructions is already initialized when code-generating the corresponding
virtual scalar write and consequently does not need to be initialized later on
when generating the set of escaping values.

Code references:

In TempScopInfo::buildScalarDependences we detect scalar cross-statement
dependences for all instructions (including PHIs) that have uses outside of the
scop's region:

  // Check whether or not the use is in the SCoP.
  if (!R->contains(UseParent)) {
    AnyCrossStmtUse = true;
    continue;
  }

We use this information in TempScopInfo::buildAccessFunctions were we build
scalar write memory accesses for all these instructions:

  if (!isa<StoreInst>(Inst) &&
    buildScalarDependences(Inst, &R, NonAffineSubRegion)) {
    // If the Instruction is used outside the statement, we need to build the
    // write access.
    IRAccess ScalarAccess(IRAccess::MUST_WRITE, Inst, ZeroOffset, 1, true,
                          Inst);
    Functions.push_back(std::make_pair(ScalarAccess, Inst));
  }

Reviewers: jdoerfert

Subscribers: pollydev, llvm-commits

Differential Revision: http://reviews.llvm.org/D12472

llvm-svn: 246383
2015-08-30 15:03:59 +00:00
Tobias Grosser 51b65d9370 Drop alias tags from vector test case
They are not really part of what is tested here.

llvm-svn: 246382
2015-08-30 14:06:30 +00:00
Tobias Grosser f8d55f7e4e Remove some code duplication when creating Allocas [NFC]
llvm-svn: 246364
2015-08-29 18:12:03 +00:00
Duncan P. N. Exon Smith adbcf12029 DI: Fix testcases after LLVM r246327
I ran the script from r246327 and it touched all the right files;
committing now to hopefully right the bots, but if my check-polly
doesn't come back clean I'll keep looking.

http://lab.llvm.org:8011/builders/polly-amd64-linux/builds/33648

llvm-svn: 246341
2015-08-28 22:01:49 +00:00
Johannes Doerfert b409fdc0d7 [NFC] Make SCEVAffinator work without a statement
llvm-svn: 246290
2015-08-28 09:24:35 +00:00
Tobias Grosser 6dc4441884 IslNodeBuilder: Make functionality available to subclasses
llvm-svn: 246287
2015-08-28 08:30:52 +00:00
Tobias Grosser 3f2783b254 IslNodeBuilder: Add function to export BlockGenerator
llvm-svn: 246286
2015-08-28 08:23:38 +00:00
Tobias Grosser b79a67df78 BlockGenerator: Make scalar memory locations accessible
For external users, the memory locations into which we generate scalar values
may be of interest. This change introduces two functions that allow to obtain
(or create) the AllocInsts for a given BasePointer.

We use this change to simplify the code in BlockGenerators.

llvm-svn: 246285
2015-08-28 08:23:35 +00:00
Tobias Grosser 1e5a8c1a5c Virtualize the IslNodeBuilder
This allows users to extend the IslNodeBuilder to create their own optimization
passes. This feature is not used in Polly's codebase itself, but as these
funtions are not performance critical, the cost of making experiments of
external users easier seems low enough to do so.

llvm-svn: 246281
2015-08-28 07:07:04 +00:00
Tobias Grosser ed21a1fc7e Do not detect Scops with only one loop.
If a region does not have more than one loop, we do not identify it as
a Scop in ScopDetection. The main optimizations Polly is currently performing
(tiling, preparation for outer-loop vectorization and loop fusion) are unlikely
to have a positive impact on individual loops. In some cases, Polly's run-time
alias checks or conditional hoisting may still have a positive impact, but those
are mostly enabling transformations which LLVM already performs for individual
loops. As we do not focus on individual loops, we leave them untouched to not
introduce compile time regressions and execution time noise. This results in
good compile time reduction (oourafft: -73.99%, smg2000: -56.25%).

Contributed-by: Pratik Bhatu <cs12b1010@iith.ac.in>

Reviewers: grosser

Differential Revision: http://reviews.llvm.org/D12268

llvm-svn: 246161
2015-08-27 16:55:18 +00:00
Tobias Grosser 2d1ed0bfa7 BlockGenerator: Add the possiblity to pass a set of new access functions
This change allows the BlockGenerator to be reused in contexts where we want to
provide different/modified isl_ast_expressions, which are not only changed to
a different access relation than the original statement, but which may indeed
be different for each code-generated instance of the statement.

We ensure testing of this feature by moving Polly's support to import changed
access functions through a jscop file to use the BlockGenerators support for
generating arbitary access functions if provided.

This commit should not change the behavior of Polly for now. The diff is rather
large, but most changes are due to us passing the NewAccesses hash table through
functions. This style, even though rather verbose, matches what is done
throughout the BlockGenerator with other per-statement properties.

llvm-svn: 246144
2015-08-27 07:28:16 +00:00
Johannes Doerfert d020b77295 Use ISL to Determine Loop Trip Count
Use ISL to compute the loop trip count when scalar evolution is unable to do
  so.

Contributed-by: Matthew Simpson <mssimpso@codeaurora.org>

Differential Revision: http://reviews.llvm.org/D9444

llvm-svn: 246142
2015-08-27 06:53:52 +00:00
Tobias Grosser 01c8f5f354 [Vectorizer] Detect strides in multi-dimensional arrays
The original code was only correct for one-dimensional arrays, but derived
incorrect strides for multi-dimensional arrays.

llvm-svn: 245888
2015-08-24 22:20:46 +00:00
Tobias Grosser 39f9f30e8b Only derive number of loop iterations for loops we can actually vectorize
llvm-svn: 245870
2015-08-24 20:11:34 +00:00
Tobias Grosser fa57e9b7e6 Make our data-locality schedule tree transforms externally accessible
Other passes which perform different optimizations might be interested in
also applying data-locality transformations as part of their overall
transformation.

llvm-svn: 245824
2015-08-24 06:01:47 +00:00
Tobias Grosser 1ac884d73a Use marker nodes to annotate the different levels of tiling
Currently, marker nodes are ignored during AST generation, but visible in the
-debug-only=polly-ast output.

llvm-svn: 245809
2015-08-23 09:11:00 +00:00
Tobias Grosser 75296901f7 Fix 'unused variable' warning in NASSERTS build
llvm-svn: 245723
2015-08-21 19:23:21 +00:00
Roman Gareev c49724f008 Manually check a loop form
Add manual check of a loop form and return non-negative number of iterations
in case of trivially vectorizable loop.

llvm-svn: 245680
2015-08-21 09:08:14 +00:00
Tobias Grosser daaed0e19f Do not intersect with AssumedContext in calculateMinMaxAccess
Originally, we intersected the iteration space with the AssumedContext before
computing the minimal/maximal memory offset in our run-time alias checks. With
this patch we drop this intersection as the AssumedContext can - for larger or
more complex scops - become very complicated (contain many disjuncts). When
intersecting an object with many disjuncts with other objects, the number of
disjuncts in these other objects also increases quickly. As a result, the
compile time is unnecessarily increased. This patch now drops the intersection
with the assumed context to ensure we do not pay unnecessary compile time
costs.

With this patch we see -3.17% reduction in compile time for 3mm with default
flags and -17.87% when compiling 3mm with -DPOLYBENCH_USE_C99_PROTO flag. We
did not observe any regressions in LNT.

Contributed-by: Pratik Bhatu <cs12b1010@iith.ac.in>

Reviewers: grosser

Differential Revision: http://reviews.llvm.org/D12198

llvm-svn: 245617
2015-08-20 21:29:26 +00:00
Tobias Grosser fc490a99f5 Do really not unroll the vector loop in combination with register tiling
The previous commit lacked a test case for register tiling + pre-vectorization
and we obviously got it immediately wrong.

llvm-svn: 245599
2015-08-20 19:08:16 +00:00
Tobias Grosser d83b8a83ec Add option to control reduction detection
llvm-svn: 245598
2015-08-20 19:08:11 +00:00
Tobias Grosser 40985016b2 Fix formatting
llvm-svn: 245597
2015-08-20 19:08:05 +00:00
Johannes Doerfert 120de4be96 Simplify the SCoP creation and bookkeeping
To avoid multiple exits and the resulting complicated conditions when
  creating a SCoP we now use the single hasFeasibleRuntimeContext()
  check to decide if a SCoP should be dismissed right after
  construction. If building runtime checks failed the assumed context is
  made infeasible, hence the optimized version will never be executed
  and the SCoP can be dismissed.

llvm-svn: 245593
2015-08-20 18:30:08 +00:00
Johannes Doerfert 5d5b30649a Check feasibility for the runtime check context wrt. the domain.
If nothing is executed we can bail out early. Otherwise we can use the
  constraints that ensure at least one statement is executed for
  simplification.

llvm-svn: 245585
2015-08-20 18:06:30 +00:00
Johannes Doerfert 4eed5bea54 Link ScopArrayInfo objects
We will record if a SAI is the base of another SAI or derived from it.
  This will allow to reason about indirect base pointers later on and
  allows a clearer picture of indirection also in the SCoP dump.

llvm-svn: 245584
2015-08-20 18:04:22 +00:00
Tobias Grosser 42e2489553 Add experimental support for trivial register tiling
Register tiling in Polly is for now just an additional level of tiling which
is fully unrolled. It is disabled by default. To make this useful for more than
experiments, we still need a cost function as well as possibly further
optimizations that teach LLVM to actually put some of the values we got into
scalar registers.

llvm-svn: 245564
2015-08-20 13:45:05 +00:00
Tobias Grosser 0483271662 Add support for two-level tiling
By default we only use one level of tiling for loops, but in general tiling
for multiple levels is trivial for us. Hence, we add a set of options that
allow people to play with a second level of tiling. If this is profitable for
some cases we can work on heuristics that allow us to identify these cases
and use two-level tiling for them.

llvm-svn: 245563
2015-08-20 13:45:02 +00:00
Tobias Grosser 862b9b5239 Factor out check for tileable band node.
llvm-svn: 245559
2015-08-20 12:32:45 +00:00
Tobias Grosser 9bdea573bd Introduce tileBand function to simplify code
llvm-svn: 245558
2015-08-20 12:22:37 +00:00
Tobias Grosser d891b54132 Add some forgotten isl memory annotations
llvm-svn: 245557
2015-08-20 12:16:23 +00:00
Johannes Doerfert 43788c5783 Check for feasible runtime check context early
Instead of generating code for an empty assumed context we bail out
  early. As the number of assumptions we generate increases this becomes
  more and more important. Additionally, this change will allow us to
  hide internal contexts that are only used in runtime checks e.g., a
  boundary context with constraints not suited for simplifications.

llvm-svn: 245540
2015-08-20 05:58:56 +00:00
Tobias Grosser b0da42fb55 Generate alias metadata even in OpenMP mode
To make alias scope metadata generation work in OpenMP mode we now provide
the ScopAnnotator with information about the base pointer rewrite that happens
when passing arrays into the OpenMP subfunction.

llvm-svn: 245451
2015-08-19 16:04:35 +00:00
Tobias Grosser d8e3c8c665 Fix typo
llvm-svn: 245441
2015-08-19 14:22:48 +00:00
Tobias Grosser 07c1c2fcc9 Make prevectorization width configurable
Polly uses 'prevectorization' to enable outer loop vectorization. When
vectorizing an outer loop, we strip-mine <number-of-prevec-dims> loop
iterations which are than interchanged to the innermost level such that LLVM's
inner loop vectorizer (or Polly's simple vectorizer) can easily vectorize this
loop. The number of loop iterations to strip-mine is now configurable with the
option -polly-prevect-width=<number-of-prevec-dims>.

This is mostly a debugging option. We should probably add a heuristic that
derives the number of prevectorization dimensions from the target data and
the data types used.

llvm-svn: 245424
2015-08-19 08:46:11 +00:00
Tobias Grosser 161c9081e5 Do not use negative option name
Instead of -polly-no-tiling, we use -polly-tiling=false to disable tiling.

llvm-svn: 245423
2015-08-19 08:22:06 +00:00
Tobias Grosser f10f4636ff Simplify tiling code a bit
We only need to allocate the tile size vector if we actually want to perform
a tiling.

llvm-svn: 245422
2015-08-19 08:03:37 +00:00
Michael Kruse d568a3e20d Update test case multidim_indirect_access.ll
This test was written to check the workings of IndependentBlocks on
arrays which doesn't do such transformations anymore. The test itself
is still useful to check that the region is rejected as SCoP.  

llvm-svn: 245353
2015-08-18 21:08:41 +00:00
Michael Kruse acb6ade757 Move early exit to the beginning of the function
If the function exits early there is no reason to enter the loop.

llvm-svn: 245316
2015-08-18 17:25:48 +00:00
Roman Gareev f2bd72e00d Use isl_set_is_subset instead of isl_set_is_equal
It helps to detect correct strides in case of parametric constraints of Stride
in MemoryAccess::isStrideX.

Reviewers: grosser
llvm-svn: 245303
2015-08-18 16:12:05 +00:00
Tobias Grosser c0f8452592 Fix test cases which fail due to changes in isl's set representation
llvm-svn: 245301
2015-08-18 15:28:02 +00:00
Tobias Grosser cf9ebb63d6 Use schedule trees to compute dependences
This patch changes Polly to compute the data-dependences on the schedule tree
instead of a flat schedule representation. Calculating dependences directly on
the schedule tree results in some good compile-time improvements (adi : -23.35%,
3mm : -9.57%), as the structure of the schedule can be exploited for increased
efficiency.

Earlier experiments with schedule tree based dependence analysis in Polly showed
some compile-time regressions. These regressions arose due to the schedule tree
based dependence analysis not taking into account the domain constraints of the
schedule tree. As a result, the computed dependences were different and this
difference caused in some cases the schedule optimizer to take a very long time.
Since isl version fe865996 the schedule tree based dependence analysis takes
domain constraints into account, which fixes the earlier compile-time issues.

Contributed-by: Pratik Bhatu <cs12b1010@iith.ac.in>
llvm-svn: 245300
2015-08-18 15:05:29 +00:00
Roman Gareev 079968e4cf test commit revert
test commit revert

llvm-svn: 245299
2015-08-18 14:56:50 +00:00
Roman Gareev 6753df4bb6 test commit
test commit

llvm-svn: 245298
2015-08-18 14:54:27 +00:00
Michael Kruse d2b0360197 Fix Codegen adding a second exit out of region
executeScopConditionally would destroy a predecessor region if it the
scop's entry was the region's exit block by forking it to polly.start
and thus creating a secnd exit out of the region. This patch "shrinks"
the predecessor region s.t. polly.split_new_and_old is not the 
region's exit anymore. 

llvm-svn: 245294
2015-08-18 13:14:42 +00:00
Johannes Doerfert e69e1141d9 Introduce the ScopExpander as a SCEVExpander replacement
The SCEVExpander cannot deal with all SCEVs Polly allows in all kinds
  of expressions. To this end we introduce a ScopExpander that handles
  the additional expressions separatly and falls back to the
  SCEVExpander for everything else.

Reviewers: grosser, Meinersbur

Subscribers: #polly

Differential Revision: http://reviews.llvm.org/D12066

llvm-svn: 245288
2015-08-18 11:56:00 +00:00
Tobias Grosser 77c0f5a3b7 Drop dead and disable code from IndependentBlocks
Since Polly has now support for the code generation of scalar and PHI
dependences this code was unused and is now dropped.

llvm-svn: 245284
2015-08-18 09:30:28 +00:00
Johannes Doerfert d86f2157e5 Add a field to the memory access class for a related value.
The new field in the MemoryAccess allows us to track a value related
  to that access:
    - For real memory accesses the value is the loaded result or the
      stored value.
    - For straigt line scalar accesses it is the access instruction
      itself.
    - For PHI operand accesses it is the operand value.

  We use this value to simplify code which deduced information about the value
  later in the Polly pipeline and was known to be error prone.

Reviewers: grosser, Meinsersbur

Subscribers: #polly

Differential Revision: http://reviews.llvm.org/D12062

llvm-svn: 245213
2015-08-17 10:58:17 +00:00
Tobias Grosser c5bcf246d1 Fix Polly after SCEV port to new pass manager
This fixes compilation after LLVM commit r245193.

llvm-svn: 245211
2015-08-17 10:57:08 +00:00
Johannes Doerfert e1fa6da356 [FIX] Create location if a needed value was not yet demoted
This allows the code generation to continue working even if a needed
  value (that is reloaded anyway) was not yet demoted. Instead of
  failing it will now create the location for future demotion to memory
  and load from that location. The stores will use the same location and
  by construction execute before the load even if the textual order in
  the generated AST is otherwise.

Reviewers: grosser, Meinersbur

Subscribers: #polly

Differential Revision: http://reviews.llvm.org/D12072

llvm-svn: 245203
2015-08-17 09:38:46 +00:00
Tobias Grosser 3278b7cd7c Add 2nd test case for sdiv/srem instructions in a SCEV
llvm-svn: 245186
2015-08-16 19:53:21 +00:00
Johannes Doerfert eca5282dd0 [FIX] Add XFAIL to crashing test case
llvm-svn: 245180
2015-08-16 14:54:16 +00:00
Johannes Doerfert 45545ff782 Build the ScopStmt domain in-place.
This will build the statement domains in-place, hence using the
  ScopStmt::Domain member instead of some intermediate isl_set.

llvm-svn: 245179
2015-08-16 14:36:01 +00:00
Johannes Doerfert c594dc9ed0 Add a crashing test case for the scalar code generation
This test case crashes the scalar code generation as we are not
  consistent with the usage of the assumed context. To be precise, we
  use the assumed context for the dependence analysis but not to
  restrict the domains of the statements.

  A step by step explanation of the problem is given in the test case.

llvm-svn: 245176
2015-08-16 11:12:22 +00:00
Tobias Grosser 8a9c2353f9 Add -polly-context option to provide additional context information
This option allows the user to provide additional information about parameter
values as an isl_set. To specify that N has the value 1024, we can provide
the context -polly-context='[N] -> {: N = 1024}'.

llvm-svn: 245175
2015-08-16 10:19:29 +00:00
Johannes Doerfert ddb83d0f6d Remove trivially true condition
llvm-svn: 245174
2015-08-16 08:35:40 +00:00
Tobias Grosser 234a48270e AST Generation Paper published in TOPLAS
The July issue of TOPLAS contains a 50 page discussion of the AST generation
techniques used in Polly. This discussion gives not only an in-depth
description of how we (re)generate an imperative AST from our polyhedral based
mathematical program description, but also gives interesting insights about:

- Schedule trees: A tree-based mathematical program description that enables us
to perform loop transformations on an abstract level, while issues like the
generation of the correct loop structure and loop bounds will be taken care of
by our AST generator.

- Polyhedral unrolling: We discuss techniques that allow the unrolling of
non-trivial loops in the context of parameteric loop bounds, complex tile
shapes and conditionally executed statements. Such unrolling support enables
the generation of predicated code e.g. in the context of GPGPU computing.

- Isolation for full/partial tile separation: We discuss native support for
handling full/partial tile separation and -- in general -- native support for
isolation of boundary cases to enable smooth code generation for core
computations.

- AST generation with modulo constraints: We discuss how modulo mappings are
lowered to efficient C/LLVM code.

- User-defined constraint sets for run-time checks We discuss how arbitrary
sets of constraints can be used to automatically create run-time checks that
ensure a set of constrainst actually hold. This feature is very useful to
verify at run-time various assumptions that have been taken program
optimization.

Polyhedral AST generation is more than scanning polyhedra
Tobias Grosser, Sven Verdoolaege, Albert Cohen
ACM Transations on Programming Languages and Systems (TOPLAS), 37(4), July 2015

llvm-svn: 245157
2015-08-15 09:34:33 +00:00
Tobias Grosser 4c45542595 Update link to Polly paper
By going through my personal website, people can go directly to the paper.

llvm-svn: 245156
2015-08-15 09:34:28 +00:00
Michael Kruse 82a1c7de09 Make TempScopInfo a RegionPass
This modifies the order in which Polly passes are executed.

Assuming a function has two scops (A and B), the order before was:

FunctionPassManager
  ScopDetection
  IndependentBlocks
  TempScopInfo for A and B
  RegionPassManager
    ScopInfo for A
    DependenceInfo for A
    IslScheduleOptimizer for A
    IslAstInfo for A
    CodeGeneration for A
    ScopInfo for B
    DependenceInfo for B
    IslScheduleOptimizer for B
    IslAstInfo for B
    CodeGeneration for B

After this patch:

FunctionPassManager
  ScopDetection
  IndependentBlocks
  RegionPassManager
    TempScopInfo for A
    ScopInfo for A
    DependenceInfo for A
    IslScheduleOptimizer for A
    IslAstInfo for A
    CodeGeneration for A
    TempScopInfo for B
    ScopInfo for B
    DependenceInfo for B
    IslScheduleOptimizer for B
    IslAstInfo for B
    CodeGeneration for B

TempScopInfo for B might store information and references to the IR
that CodeGeneration for A might modify. Changing the order ensures that
the IR is not modified from the analysis of a region until code
generation.

Reviewers: grosser

Differential Revision: http://reviews.llvm.org/D12014

llvm-svn: 245091
2015-08-14 20:10:27 +00:00
Tobias Grosser bccd1b0af0 Fix test case after recent LLVM changes
llvm-svn: 244954
2015-08-13 21:08:15 +00:00
Tobias Grosser 7e584168ab Manuallt simplify test case
llvm-svn: 244907
2015-08-13 16:33:32 +00:00
Michael Kruse 5a8ddd74a5 Remove unimplemented private method getTempScop
llvm-svn: 244906
2015-08-13 16:28:04 +00:00
Michael Kruse 2da3872a99 Add test case for SCEV synthesizing
CodeGenerator currently tries to generate code for a parameter using
values values that are computed later.

llvm-svn: 244903
2015-08-13 15:53:53 +00:00
Tobias Grosser 0164b8ff70 Enable code generation of scalar dependences from function arguments
This change extends the BlockGenerator to not only allow Instructions as
base elements of scalar dependences, but any llvm::Value. This allows
us to code-generate scalar dependences which reference function arguments, as
they arise when moddeling read-only scalar dependences.

llvm-svn: 244874
2015-08-13 08:07:39 +00:00
Tobias Grosser 72e8f5999e Make sure we increment the reference counter when passing out the isl_pw_aff
llvm-svn: 244758
2015-08-12 15:45:41 +00:00
Tobias Grosser d46fd5ed95 Make the dimension sizes of in ScopArrayInfo available as isl_pw_affs
This makes it easier to reason about the size of an array dimension with isl.

llvm-svn: 244757
2015-08-12 15:27:16 +00:00
Johannes Doerfert 5451544a17 Remove identity operation from SCEVAffinator
llvm-svn: 244736
2015-08-12 10:58:01 +00:00
Johannes Doerfert 33d98a3f45 Revert r244459 'Make StmtSet a list'
llvm-svn: 244735
2015-08-12 10:55:52 +00:00
Johannes Doerfert 3f0a2a325f Add caching to the SCEVAffinator
While the compile time is not affected by this patch much it will
  allow us to look at all translated expressions after the SCoP is build
  in a convenient way. Additionally, bigger SCoPs or SCoPs with
  repeating complicated expressions might benefit from the cache later
  on.

Reviewers: grosser, Meinersbur

Subscribers: #polly

Differential Revision: http://reviews.llvm.org/D11975

llvm-svn: 244734
2015-08-12 10:46:33 +00:00
Johannes Doerfert f363bfb730 [FIX] Typo
llvm-svn: 244733
2015-08-12 10:45:20 +00:00
Johannes Doerfert 916736ef73 Expose the SCEVAffinator and make it a member of a SCoP (cont'd)
Added missing documentation and linked to the correct revision.

Differential Revision: http://reviews.llvm.org/D11974

llvm-svn: 244731
2015-08-12 10:28:45 +00:00
Johannes Doerfert 574182d394 Expose the SCEVAffinator and make it a member of a SCoP.
This change has three major advantages:
    - The ScopInfo becomes smaller.
    - It allows to use the SCEVAffinator from outside the ScopInfo.
    - A member object allows state which in turn allows e.g., caching.

Differential Revision: http://reviews.llvm.org/D9099

llvm-svn: 244730
2015-08-12 10:19:50 +00:00
Johannes Doerfert 9e0daff91e Make arc unit work with ninja builds
In order to find the llvm-obj directory it has to be (or a soft link
  to it) at one of the following locations:

    ${POLLY_SRC_DIR}/build
    ${POLLY_SRC_DIR}.build
    ${POLLY_SRC_DIR}-build
    s/${POLLY_SRC_DIR}/src/build

  Alternatively, the environment variable $POLLY_BIN_DIR can point to it.

llvm-svn: 244727
2015-08-12 09:02:20 +00:00
Johannes Doerfert a7ba98caa2 Adjusted arc linter config for modern version of arcanist
llvm-svn: 244726
2015-08-12 09:01:16 +00:00
Tobias Grosser a77cea49d1 Always model PHI nodes in scop (if not in same nonaffine subregion)
Before we only modeled PHI nodes if at least one incoming basic block was itself
part of the region, now we always model them except if all of their operands are
part of a single non-affine subregion which we model as a black-box.

This change only affects PHI nodes in the entry block, that have exactly one
incoming edge. Before this change, we did not model them and as a result code
generation would not know how to code generate them. With this change, code
generation can code generate them like any other PHI node.

This issue was exposed by r244606. Before this change simplifyRegion would have
moved these PHI nodes out of the SCoP, so we would never have tried to code
generate them. We could implement this behavior again, but changing the IR
after the scop has been modeled and transformed always adds a risk of us
invalidating earlier analysis results. It seems more save and overall also more
consistent to just model and handle this one-entry-edge PHI nodes like any
other PHI node in the scop.

Solution proposed by:  Michael Kruse  <llvm@meinersbur.de>

llvm-svn: 244721
2015-08-12 07:48:54 +00:00
Michael Kruse fba24b3775 Add another test case with trival PHI in entry BB
This one was extracted from the test-suite's pifft and caused a
miscompilation because a scalar was not written to its alloca address.

llvm-svn: 244720
2015-08-12 07:34:55 +00:00
Michael Kruse 4f9caf2b28 Add test case for entry node with trivial PHI
This is a break-down from the test-suite's oggenc where Polly currently
crashes. 

llvm-svn: 244692
2015-08-11 23:09:19 +00:00
Michael Kruse 9c483c5834 Assign regions to all BBs from CodeGeneration
In order to have a valid region analysis, we assign all newly created blocks to the parent of the scop's region. This is correct for any pre-existing regions (including the scop's region and its parent), but does not discover any region inside the generated code. For Polly this is not necessary because we do not want to re-run Polly on its own generated code anyway.

Reviewers: grosser

Part of Differential Revision: http://reviews.llvm.org/D11867

llvm-svn: 244608
2015-08-11 14:47:37 +00:00
Michael Kruse 22370884c4 Revise the simplification of regions
The previous code had several problems:

For newly created BasicBlocks it did not (always) call RegionInfo::setRegionFor in order to update its analysis. At the moment RegionInfo does not verify its BBMap, but will in the future. This is fixed by determining the region new BBs belong to and set it accordingly. The new executeScopConditionally() requires accurate getRegionFor information. 

Which block is created by SplitEdge depends on the incoming and outgoing edges of the blocks it connects, which makes handling its output more difficult than it needs to be. Especially for finding which block has been created an to assign a region to it for the setRegionFor problem above. This patch uses an implementation for splitEdge that always creates a block between the predecessor and successor. simplifyRegion has also been simplified by using SplitBlockPredecessors instead of SplitEdge. Isolating the entries and exits have been refectored into individual functions.

Previously simplifyRegion did more than just ensuring that there is only one entering and one exiting edge. It ensured that the entering block had no other outgoing edge which was necessary for executeScopConditionally(). Now the latter uses the alternative splitEdge implementation which can handle this situation so simplifyRegion really only needs to simplify the region.

Also, executeScopConditionally assumed that there can be no PHI nodes in blocks with one incoming edge. This is wrong and LCSSA deliberately produces such edges. However, previous passes ensured that there can be no such PHIs in exit nodes, but which will no longer hold in the future.

The new code that the property that it preserves the identity of region block (the property that the memory address of the BasicBlock containing the instructions remains the same; new blocks only contain PHI nodes and a terminator), especially the entry block. As a result, there is no need to update the reference to the BasicBlock of ScopStmt that contain its instructions because they have been moved to other basic blocks.

Reviewers: grosser

Part of Differential Revision: http://reviews.llvm.org/D11867 

llvm-svn: 244606
2015-08-11 14:39:21 +00:00
Michael Kruse 23d0e83aa3 Introduce splitBlock and use it in splitEntryBlockForAlloca
RegionInfo::splitBlock did not update RegionInfo correctly. Specifically, it tried to make the new block the entry block if possible. This breaks for nested regions that have edges to the old block. 

We simply do not change the entry block. Updating RegionInfo becomes trivial as both block will always be in the same region.

splitEntryBlockForAlloca makes use of the new splitBlock.

Reviewers: grosser

Part of Differential Revision: http://reviews.llvm.org/D11867

llvm-svn: 244600
2015-08-11 14:04:06 +00:00
Tobias Grosser 6e3ba33b07 Update isl to isl-0.15-117-ge42acfe
Besides other changes this version of isl contains a fundamental fix to memory
corruption issues we have seen with imath-32 backed isl_ints.

This update also contains a fix that ensures that the schedule-tree based
version of isl's dependence analysis takes the domain of the schedule into
account.

llvm-svn: 244585
2015-08-11 11:31:18 +00:00
Tobias Grosser c186ac7aea BlockGenerator: Do not store 'store' statements in BBMap
A store statement has no return value and can consequently not be referenced
from another statement.

llvm-svn: 244576
2015-08-11 08:13:15 +00:00
Michael Kruse 874b5c2197 Correct non-existing past participle of split in filename
llvm-svn: 244478
2015-08-10 18:37:34 +00:00
Johannes Doerfert d6c30160e7 Make StmtSet a list.
With a deque (or any other sequential container) it is not sound to
  take the address of the elements when the container is still under
  construction. With a pointer based container this is save.

llvm-svn: 244459
2015-08-10 16:47:20 +00:00
Michael Kruse 4adb0279a8 Add test case with PHI node in exit block
The PHI node with multiple incoming edges from inside the region.

Thanks Tobias for coming up with the example. 

llvm-svn: 244456
2015-08-10 16:17:59 +00:00
Michael Kruse 1d3c9b54fb Remove leftover comment
The function to which this commit applies has been removed in a
previous commit.

llvm-svn: 244450
2015-08-10 15:07:16 +00:00
Michael Kruse 046dde40c5 [Polly] Refactor buildScop
Summary: The extracted function buildBBScopStmt will be needed later to be invoked individually on the region's exit block.

Reviewers: grosser, jdoerfert

Subscribers: jdoerfert, llvm-commits, pollydev

Projects: #polly

Differential Revision: http://reviews.llvm.org/D11878

llvm-svn: 244443
2015-08-10 13:01:57 +00:00
Michael Kruse fd613545cb [Polly] Remove dead code in IndependentBlocks
Summary: The splitExitBlock function is never called. Going to replace its functionality in successive patches that do not modify the IR.

Reviewers: grosser

Subscribers: pollydev

Projects: #polly

Differential Revision: http://reviews.llvm.org/D11865

llvm-svn: 244404
2015-08-08 20:31:20 +00:00
Michael Kruse 9bb8ef03a2 Add an assertion
Check whether a block is a direct predecessor.

llvm-svn: 244401
2015-08-08 18:10:54 +00:00
Michael Kruse 27aae88d76 Do not use -fvisibility option with Visual C
It doesn't know the option and prints a warning. 

llvm-svn: 244363
2015-08-07 22:16:44 +00:00
Tanya Lattner 62dba3b7b6 Update links to lists.llvm.org.
llvm-svn: 244009
2015-08-05 04:19:04 +00:00
Tobias Grosser dcc3b435ab Optionally model read-only scalars
Even though read-only accesses to scalars outside of a scop do not need to be
modeled to derive valid transformations or to generate valid sequential code,
but information about them is useful when we considering memory footprint
analysis and/or kernel offloading.

llvm-svn: 243981
2015-08-04 13:54:20 +00:00
Tobias Grosser fbe7a2e841 Run ScopInfo after the ScopViewers
This change is required to see the detected scops even in cases where there is
no other ScopInfo user after the ScopViewers. Before this change, when
running with -polly-optimizer=none -polly-code-generator=none detected scops
have not been shown.

llvm-svn: 243971
2015-08-04 11:49:39 +00:00
Tobias Grosser ac3a95f347 Do not add spaces into memory-access identifiers
llvm-svn: 243889
2015-08-03 17:53:21 +00:00
Duncan P. N. Exon Smith 20b50f2b2a Update testcases after LLVM r243885
llvm-svn: 243887
2015-08-03 17:28:43 +00:00
Tobias Grosser 14e67e43a7 Add option -polly-view-only
If set, this option instructs -view-scops and -polly-show to only print
functions that contain the specified string in their name. This allows to
look at the scops of a specific function in a large .ll file, without flooding
the screen with .dot graphs.

llvm-svn: 243882
2015-08-03 16:39:56 +00:00
Tobias Grosser 6213913244 Use the branch instruction to define the location of a PHI-node write
We use the branch instruction as the location at which a PHI-node write takes
place, instead of the PHI-node itself. This allows us to identify the
basic-block in a region statement which is on the incoming edge of the PHI-node
and for which the write access was originally introduced. As a result we can,
during code generation, avoid generating PHI-node write accesses for basic
blocks that do not preceed the PHI node without having to look at the IR
again.

This change fixes a bug which was introduced in r243420, when we started to
explicitly model PHI-node reads and writes, but dropped some additional checks
that where still necessary during code generation to not emit PHI-node writes
for basic-blocks that are not on incoming edges of the original PHI node.
Compared to the code before r243420 the new code does not need to inspect the IR
any more and we also do not generate multiple redundant writes.

llvm-svn: 243852
2015-08-02 16:17:41 +00:00
Tobias Grosser d2d15a8c65 Dependences: Zero pad the schedule map
The schedule map we derive from a schedule tree map may map statements into
schedule spaces of different dimensionality. This change adds zero padding
to ensure just a single schedule space is used and the translation from
a union_map to an isl_multi_union_pw_aff does not fail.

llvm-svn: 243849
2015-08-02 13:30:33 +00:00
Tobias Grosser 45e7944bcf Only use instructions as insert locations for SCEVExpander
SCEVExpander, which we are using during code generation, only allows
instructions as insert locations, but breaks in case BasicBlock->end() iterators
are passed to it due to it trying to obtain the basic block in which code should
be generated by calling Instruction->getParent(), which is not defined for
->end() iterators.

This change adds an assert to Polly that ensures we only pass valid instructions
to SCEVExpander and it fixes one case, where we used IRBuilder->SetInsertBlock()
to set an ->end() insert location which was later passed to SCEVExpander.

In general, Polly is always trying to build up the CFG first, before we actually
insert instructions into the CFG sceleton. As a result, each basic block should
already have at least one branch instruction before we start adding code. Hence,
always requiring the IRBuilder insert location to be set to a real instruction
should always be possible.

Thanks Utpal Bora <cs14mtech11017@iith.ac.in> for his help with test case
reduction.

llvm-svn: 243830
2015-08-01 09:07:57 +00:00
Tobias Grosser d3f21833b9 Fix typo
llvm-svn: 243829
2015-08-01 06:26:51 +00:00
Duncan P. N. Exon Smith c51714a0c6 Fix polly tests after LLVM IR change in r243774
llvm-svn: 243801
2015-07-31 23:58:50 +00:00
Michael Kruse 471a5e3388 Move computations out of constructors
It is common practice to keep constructors lightweight. The reasons
include:

- The vtable during the constructor's execution is set to the static
type of the object, not to the vtable of the derived class. That is,
method calls behave differently in constructors and ordinary methods.
This way it is possible to call unimplemented methods of abstract
classes, which usually results in a segmentation fault.

- If an exception is thrown in the constructor, the destructor is not
called, potentially leaking memory.

- Code in constructors cannot be called in a regular way, e.g. from
non-constructor methods of derived classes.

- Because it is common practice, people may not expect the constructor
to do more than initializing data and skip them when looking for bugs.

Not all of these are applicable to LLVM (e.g. exceptions are disabled).

This patch refactors out the computational work in the constructors of
Scop and IslAst into regular init functions and introduces static
create-functions as replacement. 

Differential revision: http://reviews.llvm.org/D11491

Reviewers: grosser, jdoerfert
llvm-svn: 243677
2015-07-30 19:27:04 +00:00
Tobias Grosser 80e237bd53 Do not detect scops that are delinearized to arrays with "undef" size
Such codes are not interesting to optimize and most likely never appear in the
normal compilation flow. However, they show up during test case reduction with
bugpoint and trigger -- without this change -- an assert in
polly::MemoryAccess::foldAccess(). It is better to detect them in
ScopDetection itself and just bail out.

Contributed-by:  Utpal Bora  <cs14mtech11017@iith.ac.in>

Reviewers: grosser

Subscribers: pollydev, llvm-commits

Differential Revision: http://reviews.llvm.org/D11425

llvm-svn: 243515
2015-07-29 13:52:05 +00:00
Tobias Grosser d20aba7047 Remove some dead code
llvm-svn: 243465
2015-07-28 19:16:46 +00:00
Tobias Grosser 2be13913bb Do not end lines with '\'
This fixes 'warning: multi-line comment [-Wcomment]'

llvm-svn: 243464
2015-07-28 19:16:42 +00:00
Tobias Grosser b241d928bd Rewrite getPrevectorMap using schedule trees operations
Schedule trees are a lot easier to work with, for both humans and machines. For
humans the more structured schedule representation is easier to reason about.
Together with the more abstract isl programming interface this can result in a
lot cleaner code (see this changeset). For machines, the structured schedule and
the fact that we now use explicit piecewise affine expressions instead of
integer maps makes it easier to generate code from this schedule tree. As a
result, we can already see a slight compile-time improvement -- for 3mm from
0m0.593s to 0m0.551s seconds (-7 %). More importantly, future optimizations such
as full-partial tile separation will most likely result in more streamlined code
to be generated.

Contributed-by: Roman Gareev <gareevroman@gmail.com>
llvm-svn: 243458
2015-07-28 18:03:36 +00:00
Tobias Grosser 922452285a Keep track of ScopArrayInfo objects that model PHI node storage
Summary:
When translating PHI nodes into memory dependences during code generation we
require two kinds of memory. 'Normal memory' as for all scalar dependences and
'PHI node memory' to store the incoming values of the PHI node. With this
patch we now mark and track these two kinds of memories, which we previously
incorrectly marked as a single memory object.

Being aware of PHI node storage makes code generation easier, as we do not need
to guess what kind of storage a scalar reference requires. This simplifies the
code nicely.

Reviewers: jdoerfert

Subscribers: pollydev, llvm-commits

Differential Revision: http://reviews.llvm.org/D11554

llvm-svn: 243420
2015-07-28 14:53:44 +00:00
Tobias Grosser 9696a3f903 Do not compile GPU library with sanitizers
llvm-svn: 243411
2015-07-28 12:51:23 +00:00
Tobias Grosser 43bf4553fd Extend documentation of scalar code generation [NFC]
No functional change intended

--
Reviewers: jdoerfert

Projects: #polly

Differential Revision: http://reviews.llvm.org/D11536

llvm-svn: 243410
2015-07-28 12:12:04 +00:00
Tobias Grosser d4dd6ec74d Simplify code in BlockGenerator::generateScalarLoads [NFC]
We hoist statements that are used on both branches of an if-condition, shorten
and unify some variable names and fold some variable declarations into their
only uses. We also drop a comment which just describes the elements the loop
iterates over.

No functional change intended.

llvm-svn: 243291
2015-07-27 17:57:58 +00:00
Tobias Grosser 2764794ba4 Simplify some isl expression we use
Suggested-by: Sven Verdoolaege <skimo-polly@kotnet.org>
llvm-svn: 243254
2015-07-26 19:22:35 +00:00
Johannes Doerfert 210b09aa21 Remove explicit heap allocation to fix and prevent memory leaks
llvm-svn: 243245
2015-07-26 13:14:38 +00:00
Tobias Grosser bb853c24b1 Fix formatting of recent alias-analysis commit
llvm-svn: 243215
2015-07-25 12:31:03 +00:00
Tobias Grosser 3b10c94062 Prevectorize the schedule of the band (or the point loop in case of tiling)
Contributed-by: Roman Gareev <gareevroman@gmail.com>
llvm-svn: 243214
2015-07-25 12:28:56 +00:00
Michael Kruse be16d22f04 Normalize whitespace in makefiles
Tabs for rules and space for line continuations.

llvm-svn: 243179
2015-07-24 23:30:31 +00:00
Michael Kruse 392417808d Add isl_ffs.c to file list in autoconf builds
In most configurations it doesn't contain any symbol, but add for
completeness.

llvm-svn: 243168
2015-07-24 21:40:22 +00:00
Michael Kruse 1bbe346cef Make the lit configuration Python 3 compatible
by using the same techniques as LLVM's lit configuration.

llvm-svn: 243154
2015-07-24 20:33:22 +00:00
Michael Kruse d3059f3853 Compile fix; add missing ISL files
The last ISL update added two files that we must also add to Polly. 

llvm-svn: 243142
2015-07-24 19:09:27 +00:00
Tobias Grosser 566060d76f Update isl to isl-0.15-86-g595055e
Besides a couple of cleanups and refactorings in isl, this change set fixes a
couple of bugs in isl, that can cause issues during code generation.

llvm-svn: 243110
2015-07-24 13:12:17 +00:00
Michael Kruse 5e9f249c3e Add LICM test cases
These test cases check whether Polly still gives the same results if
LICM runs before.  Currently, it does not and therefore these cases are
expected fails. 

llvm-svn: 243037
2015-07-23 20:05:11 +00:00
Michael Kruse 75b6b0c5bd Always execute polly::CodePreparation before Polly
ScopDetection does not allow scops to begin with the entry block, were
allocas are added at code generation.

llvm-svn: 243036
2015-07-23 20:00:20 +00:00
Johannes Doerfert 338b42c329 Removed redundant alias checks generated during run time.
As specified in PR23888, run-time alias check generation is expensive
  in terms of compile-time. This reduces the compile time by computing
  minimal/maximal access only once for each base pointer

Contributed-by: Pratik Bhatu <cs12b1010@iith.ac.in>
llvm-svn: 243024
2015-07-23 17:04:54 +00:00
Tobias Grosser 6d32f8fbba isl: Translate brisebarre to use UNIX line endings
A similar patch will be upstreamed to ISL. We commit this ahead of time to
unblock people that are annoyed the permanent diffs we see in git.

llvm-svn: 243020
2015-07-23 15:35:45 +00:00
Chandler Carruth e677f7217b [PM/AA] Update to reflect the new LLVM API which no longer requires an
AliasAnalysis pointer.

llvm-svn: 242897
2015-07-22 12:15:33 +00:00
Michael Kruse bc776a7069 Update ISL to isl-0.15-61-gcea776f
The motivation is to fix a wrong use of the inline qualifier. This
fixes the Polly build using Visual Studio 2015 RC.

llvm-svn: 242780
2015-07-21 12:56:36 +00:00
Michael Kruse 6362f5aa0b Unify FOLDER property of Polly targets
Put all Polly targets into a single "Polly" category (i.e.
solution folder). Previously there was no recognizable scheme and most
categories contained just one or two targets or targets didn't belong
to any category.

Reviewers: grosser
llvm-svn: 242779
2015-07-21 12:40:01 +00:00
Michael Kruse 9e0db1d2e8 Remove header project from Visual Studio builds
Remove the polly_headers_do_not_build project. Visual Studio is capable
of finding the headers itself, although they are not listed explicitly.
For explicit listing, the headers should be added to the relevant
target.

Reviewers: grosser
llvm-svn: 242777
2015-07-21 12:33:15 +00:00
Michael Kruse c4ad882daf Remove module LLVMPolly from Windows build
Loadable modules are not supported on Windows.

Reviewers: grosser
llvm-svn: 242776
2015-07-21 12:29:02 +00:00
Michael Kruse 441357dca2 Remove gcc-specific flags from Visual Studio build
Remove the flags -fno-exceptions -fno-rtti and add the equivalent for
compiling with MSVC.

Reviewers: grosser
llvm-svn: 242775
2015-07-21 12:22:36 +00:00
Michael Kruse 99f2db166b Remove /Za flag from Visual Studio compilation
According to Stephan T. Lavavej it is broken. See
http://comments.gmane.org/gmane.comp.compilers.clang.devel/21638

Reviewers: grosser
llvm-svn: 242773
2015-07-21 12:16:00 +00:00
Michael Kruse 9e44f2f1cc Add a test for stdint.h like ISL's configure does
Reviewers: grosser
llvm-svn: 242772
2015-07-21 12:09:41 +00:00
Michael Kruse d2bb9a3a31 Remove gitconfig.h.cmake
It is just one line which can be better generated in the CMakeLists.txt
itself, just as ISL's configure does.

Reviewers: grosser
llvm-svn: 242771
2015-07-21 12:06:27 +00:00
Michael Kruse bf5a711e96 Add configure-time test for latest ISL
Query the isl_config.h macros recently added to ISL. One of it looks for
the ffs (find first set), whose functionality is available in Visual
Studio with _BitScanForward. Also add isl_ffs.c to the source files
which contains the implementation of ffs using _BitScanForward.

Reviewers: grosser
llvm-svn: 242770
2015-07-21 12:01:14 +00:00
Tobias Grosser 495124c4d6 GPURuntimeDebugPrinter: Printer pointer values (except if they are strings)
Only pointer values in constant address space are assumed to be strings. For
all other pointers their address is printed.

llvm-svn: 242524
2015-07-17 13:57:57 +00:00
Tobias Grosser d783a98303 Add option to choose where in the pass pipeline polly is run
These options are useful to play with the location of Polly within LLVM's
pass manager.

llvm-svn: 242390
2015-07-16 08:28:09 +00:00
Tobias Grosser 469609a714 Mark a couple of items as completed
llvm-svn: 242136
2015-07-14 10:52:58 +00:00
Tobias Grosser c268835eca Drop outdated video
llvm-svn: 242135
2015-07-14 10:45:03 +00:00
Tobias Grosser 0241bd2c7e www: Add link to llvm.org
llvm-svn: 242134
2015-07-14 10:44:06 +00:00
Tobias Grosser 808cd69a92 Use schedule trees to represent execution order of statements
Instead of flat schedules, we now use so-called schedule trees to represent the
execution order of the statements in a SCoP. Schedule trees make it a lot easier
to analyze, understand and modify properties of a schedule, as specific nodes
in the tree can be choosen and possibly replaced.

This patch does not yet fully move our DependenceInfo pass to schedule trees,
as some additional performance analysis is needed here. (In general schedule
trees should be faster in compile-time, as the more structured representation
is generally easier to analyze and work with). We also can not yet perform the
reduction analysis on schedule trees.

For more information regarding schedule trees, please see Section 6 of
https://lirias.kuleuven.be/handle/123456789/497238

llvm-svn: 242130
2015-07-14 09:33:13 +00:00
Tobias Grosser 16c4403a91 Make non-affine statement names isl compatible
Named isl sets can generally have any name if they remain within Polly, but only
certain strings can be parsed by isl. The new names we create ensure that we
can always copy-past isl strings from Polly to other isl tools, e.g. for
debugging.

llvm-svn: 241787
2015-07-09 07:31:45 +00:00
Tobias Grosser ec46e5376d Print thread-identifiers in GPU debug output
This helps us to understand which thread prints which information.

llvm-svn: 241452
2015-07-06 15:36:16 +00:00
Tobias Grosser 6c78048b76 Update isl to isl-0.15-35-ga1e44f0
This fixes a memory leak with in the sioimath backend.

llvm-svn: 241247
2015-07-02 07:59:21 +00:00
Tobias Grosser f519a288d5 Remove versions from README and add update instructions
llvm-svn: 241246
2015-07-02 07:59:16 +00:00
Tobias Grosser 4db553199c Update isl to isl-0.15-30-g3518765
This updated contains various changes to isl, including improvements to the
AST generator. For Polly, the most important change is a fix that unbreaks
builds on darwin (reported by: Jack Howard)

llvm-svn: 241048
2015-06-30 08:22:14 +00:00
Michael Kruse acc9ad5991 [Polly] Add -std=c99 flag only to C source files
Summary: Adding the flag to C++ source files emits a warning, hence we set the compile flag depending on the file's language.

Reviewers: grosser

Subscribers: Meinersbur, pollydev, llvm-commits

Projects: #polly

Differential Revision: http://reviews.llvm.org/D10809

llvm-svn: 240986
2015-06-29 19:57:59 +00:00
Tobias Grosser 1b13ddea50 Add first support to delinearize A[t%2][i][j]
This is very preliminary support, but it seems to work for the most common case.
When observing more/different test cases, we can work on generalizing this.

llvm-svn: 240955
2015-06-29 14:44:22 +00:00
Tobias Grosser 23bceb2eec Fix delinearization after it's move to ScalarEvoltion
llvm-svn: 240954
2015-06-29 14:44:17 +00:00
Tobias Grosser 1a07e19180 Increase the dependence-analysis compute out
As Polly got a lot faster after the small-integer-optimization imath
patch, we now increase the compute out to optimize larger kernels. This
should also expose additional slow-downs for us to address.

In LNT this gives us a 3.4x speedup on 3mm, at a cost of a 2x increase in
compile time (now 0.77s). reg_detect, oorafft and adi also show some compile
time increases. This compile time cost is divided between more time in isl and
more time in LLVM's backends due to increased code size (versioning and tiling).

llvm-svn: 240840
2015-06-26 21:58:42 +00:00
Tobias Grosser f54bb7743a Drop divs before adding array-out-of-bounds assumptions
In case we have modulo operations in the access function (supported since
r240518), the assumptions generated to ensure array accesses remain within
bounds can contain existentially quantified dimensions which results in more
complex and more difficult to handle integer sets. As a result LNT's linpack
benchmark started to fail due to excessive compile time.

We now just drop the existentially quantified dimensions. This should be
generally save, but may result in less precise assumptions which may
consequently make us fall back to the original (unoptimized) code more often. In
practice, these cases probably do not appear to often.

I had difficulties to extract a good test case, but fortunately our LNT bots
cover this one well.

llvm-svn: 240775
2015-06-26 12:09:28 +00:00
Tobias Grosser af4e809ca6 Remove code for scalar and PHI to array translation
This removes old code that has been disabled since several weeks and was hidden
behind the flags -disable-polly-intra-scop-scalar-to-array=false and
-polly-model-phi-nodes=false. Earlier, Polly used to translate scalars and
PHI nodes to single element arrays, as this avoided the need for their special
handling in Polly. With Johannes' patches adding native support for such scalar
references to Polly, this code is not needed any more. After this commit both
-polly-prepare and -polly-independent are now mostly no-ops. Only a couple of
simple transformations still remain, but they are scheduled for removal too.

Thanks again to Johannes Doerfert for his nice work in making all this code
obsolete.

llvm-svn: 240766
2015-06-26 07:31:18 +00:00
Michael Kruse f1ac0fcf56 Enable ISL's small integer optimization
Summary:
With small integer optimization (short: sio) enabled, ISL uses 32 bit
integers for its arithmetic and only falls back to a big integer library
(in the case of Polly: IMath) if an operation's result is too large.
This gives a massive performance boost for most application using ISL.
For instance, experiments with ppcg (polyhedral source-to-source
compiler) show speed-ups of 5.8 (compared to plain IMath), respectively
2.7 (compared to GMP).

In Polly, a smaller fraction of the total compile time is taken by ISL,
but the speed-ups are still very significant. The buildbots measure
compilation speed-up up to 1.8 (oourafft, floyd-warshall, symm). All
Polybench benchmarks compile in at least 9% less time, and about 20%
less on average.

Detailed Polybench compile time results (median of 10):
correlation     -25.51%
covariance      -24.82%
2mm             -26.64%
3mm             -28.69%
atax            -13.70%
bicg            -10.78%
cholesky        -40.67%
doitgen         -11.60%
gemm            -11.54%
gemver          -10.63%
gesummv         -11.54%
mvt              -9.43%
symm            -41.25%
syr2k           -14.71%
syrk            -14.52%
trisolv         -17.65%
trmm             -9.78%
durbin          -19.32%
dynprog          -9.09%
gramschmidt     -15.38%
lu              -21.77%
floyd-warshall  -42.71%
reg_detect      -41.17%
adi             -36.69%
fdtd-2d         -32.61%
fdtd-apml       -21.90%
jacobi-1d-imper  -9.41%
jacobi-2d-imper -27.65%
seidel-2d       -31.00%

Reviewers: grosser

Reviewed By: grosser

Subscribers: Meinersbur, llvm-commits, pollydev

Projects: #polly

Differential Revision: http://reviews.llvm.org/D10506

llvm-svn: 240689
2015-06-25 20:47:35 +00:00
Michael Kruse dddfeb6992 Fix autotools build
There were two issues:
* ISL's configure generates include/isl/stdint.h, not isl/stdint.h as
  assumed. This is also changed in the CMake build.

* Need to pass --with-int=imath to ISL's configure; the default is gmp. 

Polly's configure has been regenerated due to changing configure.ac

llvm-svn: 240657
2015-06-25 16:50:13 +00:00
Tobias Grosser 50165ffdee Add support for srem instruction
Remainder operations with constant divisor can be modeled as quasi-affine
expression. This patch adds support for detecting and modeling them. We also
add a test that ensures they are correctly code generated.

This patch was extracted from a larger patch contributed by Johannes Doerfert
in http://reviews.llvm.org/D5293

llvm-svn: 240518
2015-06-24 04:13:29 +00:00
Tobias Grosser a608569856 Replace srem by function call in nonaffine test cases
This makes the test cases nonaffine even if Polly some days gains support for
the srem instruction, an instruction which is currently not modeled but which
can clearly be modeled statically. A call to a function without definition
will always remain non-affine, as there is just insufficient static information
for it to be modeled more precisely.

llvm-svn: 240458
2015-06-23 20:55:05 +00:00
Tobias Grosser 6ca162e6e0 Add git patch files to .gitignore
llvm-svn: 240457
2015-06-23 20:55:01 +00:00
Michael Kruse f22855079a Use C99 to compile ISL
ISL with small integer optimization requires C99 to compile. gcc < 5.0
still uses C89 as default, so we need to enable the options to compile
in C99 mode.

This patch is preparing the actual activation of small integer
optimization.

Differential version: http://reviews.llvm.org/D10610

Reviewers: grosser
llvm-svn: 240322
2015-06-22 20:31:16 +00:00
Michael Kruse 9a4e22eea1 Make CMake generate isl/stdint.h
ISL's ./configure examines the system for the stdint.h to include and
creates a header file that points to it. On C99-compatible system

    #include <stdint.h>

is always valid such there no need for system introspection. This should
unbreak the build bots.

llvm-svn: 240315
2015-06-22 18:47:39 +00:00
Tobias Grosser 967c1e0b93 Handle zero-element ArrayRefs in CUDA run-time debug builder
llvm-svn: 240312
2015-06-22 18:45:23 +00:00
Michael Kruse 0c1c55345d Replace repository version of ISL by 'make dist' output
The 'make dist' archive is not dependent on ./configure output and
contains a GIT_HEAD_ID file that identifies the version of ISL used.

None of the files added or removed are used part of Polly's build
process (except of GIT_HEAD_ID since the previous revision r240301). No
functional change intended.

llvm-svn: 240306
2015-06-22 18:07:42 +00:00
Michael Kruse ee512e58a3 Prepare replacing ISL by its 'make dist' files
Currently the Polly repository contains the ISL sources with bogus
isl_config.h and gitversion.h. This is problematic. In this state a
 macro

    #define __attribute__(x)

becomes active in the source, leading to various problems e.g. when
included before system header files. This patch will instead generate
the two files specific to the host system at configure-time.

For CMake, we replicate the tests that ISL's configure performs using
try_compile(). In autotools build, we just invoke ISL's configure to
generate the two files. This consequently required regenerating
autoconf/configure.

'make dist' distributions of ISL contain a file GIT_HEAD_ID which
contains the version the distribution is derived from. The repository
files themselves do not contain such a hint. In a later commit we will
replace the isl directory by the contents of such a .tar.gz. It does
not contain the files imdrover.c iprime.c pi.c and rsamath.c currently
compiled into Polly, but not used and therefore are removed by this
patch.

In the long term we plan to generate a dedicated library for ISL instead
of adding its files to Polly.

This also does not yet include the switch to small-integer optimized ISL
nor enabling C99 mode required for the former. Those will come as well
in separate patches.

Differential version: http://reviews.llvm.org/D10603

Reviewers: grosser 
llvm-svn: 240301
2015-06-22 17:52:33 +00:00
David Blaikie de867e1ee9 Fix the clang -Werror build (-Wbraced-scalar-init)
llvm-svn: 240172
2015-06-19 20:07:18 +00:00
Tobias Grosser e7e628cc07 Add NVIDIA vprintf printing to RuntimeDebugBuilder
2nd try, this time with the corresponding LLVM IRBuilder changes in place.

llvm-svn: 240119
2015-06-19 02:33:45 +00:00
Michael Kruse 21a24730d0 Update external project versions in README.txt
This was meant to committed in r240027, but was left behind because 
svn, in contrast to git, only commits the changes in the directory you
are currently in.

llvm-svn: 240034
2015-06-18 18:07:06 +00:00
Michael Kruse c59f22c556 Update ISL to isl-0.15-3-g532568a
This version adds small integer optimization, but is not active by
default. It will be enabled in a later commit.
    
The schedule-fuse=min/max option has been replaced by the
serialize-sccs option. Adapting Polly was necessary, but retaining the
name polly-opt-fusion=min/max.

Differential Revision: http://reviews.llvm.org/D10505

Reviewers: grosser
llvm-svn: 240027
2015-06-18 16:45:40 +00:00
Tobias Grosser aa9f575ae1 Adjust to personality function change in 239940
llvm-svn: 239992
2015-06-18 05:02:11 +00:00
Chandler Carruth afa4ea7121 [PM/AA] Update Polly for r239886 which removed UnknownSize from
AliasAnalysis by getting it from its newly canonical home of
MemoryLocation::UnknownSize.

llvm-svn: 239890
2015-06-17 08:29:32 +00:00
Michael Kruse dd6011c494 Orthography: substracting -> subtracting
This is a test commit for being granted commit-after-approval access.

llvm-svn: 239725
2015-06-15 10:52:28 +00:00
Tobias Grosser 039955a44c Revert "Add NVIDIA vprintf printing to RuntimeDebugBuilder"
This reverts commit 239219 which requires some LLVM changes I forgot to commit.

Reported-by: Marshall Clow
llvm-svn: 239306
2015-06-08 16:24:49 +00:00
Tobias Grosser 6091417ebc Add NVIDIA vprintf printing to RuntimeDebugBuilder
llvm-svn: 239219
2015-06-06 08:43:22 +00:00