Commit Graph

1769 Commits

Author SHA1 Message Date
Johannes Doerfert e526de5a47 Make MIN_LOOP_TRIP_COUNT a static constant
llvm-svn: 248192
2015-09-21 19:10:11 +00:00
Tobias Grosser b1c39429d9 Do not model delinearized and linearized access relation for a single access
A missing return statement that previously did not have a visibly negative
effect caused after some data-structure changes in r248024 multi-dimensional
accesses to be modeled both multi-dimensional as well as linearized. This
commit adds the missing return to avoid the incorrect double modeling as
well as the compile time increases it caused.

llvm-svn: 248171
2015-09-21 16:19:25 +00:00
Johannes Doerfert 6a72a2af13 Use <nsw> AddRecs in the affinator to avoid bounded assumptions
If we encounter a <nsw> tagged AddRec for a loop we know the trip count of
  that loop has to be bounded or the semantics is undefined anyway. Hence, we
  only need to add unbounded assumptions if no such AddRec is known.

llvm-svn: 248128
2015-09-20 16:59:23 +00:00
Johannes Doerfert 707a406078 Add bounded loop assumption
So far we ignored the unbounded parts of the iteration domain, however
  we need to assume they do not occure at all to remain sound if they do.

llvm-svn: 248126
2015-09-20 16:38:19 +00:00
Johannes Doerfert f2cc86edae Simplify domain generation
We now add loop carried information during the second traversal of the
  region instead of in a intermediate step in-between. This makes the
  generation simpler, removes code and should even be faster.

llvm-svn: 248125
2015-09-20 16:15:32 +00:00
Johannes Doerfert 0c1123a831 [FIX] Repair test case that was unprofitable
llvm-svn: 248124
2015-09-20 16:14:41 +00:00
Johannes Doerfert 06c57b594c Allow loops with multiple back edges
In order to allow multiple back edges we:
    - compute the conditions under which each back edge is taken
    - build the union over all these conditions, thus the condition that
      any back edge is taken
    - apply the same logic to the union we applied to a single back edge

llvm-svn: 248120
2015-09-20 15:00:20 +00:00
Johannes Doerfert 7175bdfbe4 Add loop trip count based heuristic for SCoP detection
As we currently do not perform any optimizations that targets (or is
  even aware) small trip counts we will skip them when we count the
  loops in a region.

llvm-svn: 248119
2015-09-20 14:56:54 +00:00
Johannes Doerfert b276bde162 [NFC] Remove obsolete diagnostic for unstructured control flow
llvm-svn: 248118
2015-09-20 14:55:50 +00:00
Michael Kruse 84f70acd68 Remove unused variable Dimension [NFC]
llvm-svn: 248026
2015-09-18 20:03:32 +00:00
Michael Kruse e2bccbbfb2 Merge IRAccess into MemoryAccess
All MemoryAccess objects will be owned by ScopInfo::AccFuncMap which 
previously stored the IRAccess objects. Instead of creating new 
MemoryAccess objects, the already created ones are reused, but their 
order might be different now. Some fields of IRAccess and MemoryAccess 
had the same meaning and are merged.

This is the last step of fusioning TempScopInfo.{h|cpp} and 
ScopInfo.{h.cpp}. Some refactoring might still make sense.

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

llvm-svn: 248024
2015-09-18 19:59:43 +00:00
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