Commit Graph

2199 Commits

Author SHA1 Message Date
Hongbin Zheng 2ac7ee7139 Add more isl object printing functions
llvm-svn: 261402
2016-02-20 03:40:19 +00:00
Hongbin Zheng 86f43eab8b Assign meaningful name to MemoryAccess. NFC
Now the name of MemoryAccess is <StatementName>_[Read|Write|MayWrite]<Number>_<BaseName>,
e.g. Stmt_for_body_4_Read0_MemRef_A

llvm-svn: 261401
2016-02-20 03:40:15 +00:00
Tobias Grosser 58e585444a Codegen: Print error in Polly code verification and allow to disable verfication.
We now always print the reason why the code did not pass the LLVM verifier and
we also allow to disable verfication with -polly-codegen-verify=false. Before
this change the first assertion had generally no information why or what might
have gone wrong and it was also impossible to -view-cfg without recompile. This
change makes debugging bugs that result in incorrect IR a lot easier.

llvm-svn: 261320
2016-02-19 11:07:12 +00:00
Johannes Doerfert 4d9bb8d594 Allow all combinations of types and subscripts for memory accesses
To support non-aligned accesses we introduce a virtual element size
  for arrays that divides each access function used for this array. The
  adjustment of the access function based on the element size of the
  array was therefore moved after this virtual element size was
  determined, thus after all accesses have been created.

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

llvm-svn: 261226
2016-02-18 16:50:12 +00:00
Hongbin Zheng a7bdd29c9c Add more isl object printing function
llvm-svn: 261216
2016-02-18 15:24:42 +00:00
Hongbin Zheng 0169ae8ed5 Add the missing __isl_give to MemoryAccess::getAccessRelation
llvm-svn: 261215
2016-02-18 15:24:38 +00:00
Hongbin Zheng 8831eb7db4 [Refactor] Move isl_ctx into Scop.
After we moved isl_ctx into Scop, we need to free the isl_ctx after
  freeing all isl objects, which requires the ScopInfo pass to be freed
  at last. But this is not guaranteed by the PassManager, and we need
  extra code to free the isl_ctx at the right time.

  We introduced a shared pointer to manage the isl_ctx, and distribute
  it to all analyses that create isl objects. As such, whenever we free
  an analyses with the shared_ptr (and also free the isl objects which
  are created by the analyses), we decrease the (shared) reference
  counter of the shared_ptr by 1. Whenever the reference counter reach
  0 in the releaseMemory function of an analysis, that analysis will
  be the last one that hold any isl objects, and we can safely free the
  isl_ctx with that analysis.

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

llvm-svn: 261100
2016-02-17 15:49:21 +00:00
Tobias Grosser a2ee003239 ScopDectect: Allow memory accesses with different element types by default (try 3)
First support for this feature was committed in r259784. Support for
loop invariant load hoisting with different types was added by
Johannes Doerfert in r260045 and r260886.

llvm-svn: 260965
2016-02-16 14:37:24 +00:00
Johannes Doerfert 2c3ffc04f3 Replace getLoopForInst by getLoopForStmt
This patch was extracted from http://reviews.llvm.org/D13611.

llvm-svn: 260958
2016-02-16 12:36:14 +00:00
Johannes Doerfert 6a7c3e4bac Set AST Build for all statements [NFC]
llvm-svn: 260956
2016-02-16 12:11:03 +00:00
Johannes Doerfert 13637678b1 [FIX] LICM test case
llvm-svn: 260955
2016-02-16 12:10:42 +00:00
Johannes Doerfert 4cf1580f0c [FIX] Check the next base pointer for possible invariant loads
A load can only be invariant if its base pointer is invariant too. To
  this end, we check if the base pointer is defined inside the region or
  outside. In the former case we recursively check if we can (and
  therefore will) hoist the base pointer too. Only if that happends we
  can hoist the load.

llvm-svn: 260886
2016-02-15 12:42:05 +00:00
Johannes Doerfert f69162486b Revert "[FIX] Hoist accesses if AA stated they are invariant"
This reverts commit 98efa006c96ac981c00d2e386ec1102bce9f549a.

  The fix was broken since we do not use AA in the ScopDetection anymore to
  check for invariant accesses.

llvm-svn: 260884
2016-02-15 12:21:11 +00:00
Hongbin Zheng 226232044a [Refactor] Eliminate the global variable "InsnToMemAcc".
Eliminate the global variable "InsnToMemAcc" to make Scop/ScopInfo become
  more protable, such that we can safely use them in a CallGraphSCC pass.

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

llvm-svn: 260863
2016-02-15 00:20:58 +00:00
Johannes Doerfert 2353e39e1f [FIX] Hoist accesses if AA stated they are invariant
Before this patch it could happen that we did not hoist a load that
  was a base pointer of another load even though AA already declared the
  first one as invariant (during ScopDetection). If this case arises we
  will now skipt the "can be overwriten" check because in this case the
  over-approximating nature causes us to generate broken code.

llvm-svn: 260862
2016-02-14 23:37:14 +00:00
Johannes Doerfert 3ff2221cfc Split ScopArrayInfo::updateSizes into two functions
The former ScopArrayInfo::updateSizes was implicitly divided into an
  updateElementType and an updateSizes. Now this partitioning is
  explicit.

llvm-svn: 260860
2016-02-14 22:31:39 +00:00
Johannes Doerfert 965edde695 Separate more constant factors of parameters
So far we separated constant factors from multiplications, however,
  only when they are at the outermost level of a parameter SCEV. Now,
  we also separate constant factors from the parameter SCEV if the
  outermost expression is a SCEVAddRecExpr. With the changes to the
  SCEVAffinator we can now improve the extractConstantFactor(...)
  function at will without worrying about any other code part. Thus,
  if needed we can implement a more comprehensive
  extractConstantFactor(...) function that will traverse the SCEV
  instead of looking only at the outermost level.

  Four test cases were affected. One did not change much and the other
  three were simplified.

llvm-svn: 260859
2016-02-14 22:30:56 +00:00
Tobias Grosser 652f780894 CodeGeneration: Add back verification of generated code
This got accidentally dropped in r260025

llvm-svn: 260857
2016-02-14 20:56:49 +00:00
Tobias Grosser 5e27ec33ea Revert "[ScopDectect] Allow memory accesses with different element types by default"
This reverts commit https://llvm.org/svn/llvm-project/polly/trunk@260853

We unfortunately still have two bugs left which show only up with
-polly-process-unprofitable and which I forgot to test before committing.

llvm-svn: 260854
2016-02-14 19:59:29 +00:00
Tobias Grosser 5f105f9bdd [ScopDectect] Allow memory accesses with different element types by default
First support for this feature was committed in r259784. Support for
loop invariant load hoisting with different types was added by Johannes
Doerfert in r260045. This fixed the last known bug.

llvm-svn: 260853
2016-02-14 19:11:16 +00:00
Hongbin Zheng fec328083a Use unique_ptr to manage Scop inside ScopInfo.
llvm-svn: 260821
2016-02-13 15:13:02 +00:00
Hongbin Zheng 660f3ccfa5 Move AccFuncMap from ScopInfo into Scop
Since the origin AccFuncMap in ScopInfo is used by the underlying Scop
  only, and it must stay alive until we delete the Scop. It will be better
  if we simply move the origin AccFuncMap in ScopInfo into the Scop class.

llvm-svn: 260820
2016-02-13 15:12:58 +00:00
Hongbin Zheng 192f69a0fb Do not carry LoopInfo along with a Scop.
Make Scop become more portable such that we can use it in a CallGraphSCC pass.
  The first step is to drop the analyses that are only used during Scop construction.
  This patch drop LoopInfo from Scop.

llvm-svn: 260819
2016-02-13 15:12:54 +00:00
Hongbin Zheng f53ffa6dc3 Do not carry DominatorTree along with a Scop.
Make Scop become more portable such that we can use it in a CallGraphSCC pass.
  The first step is to drop the analyses that are only used during Scop construction.
  This patch drop DominatorTree from Scop.

llvm-svn: 260818
2016-02-13 15:12:51 +00:00
Hongbin Zheng 7dddfba7dc Do not carry ScopDetection along with a Scop.
Make Scop become more portable such that we can use it in a CallGraphSCC pass.
  The first step is to drop the analyses that are only used during Scop construction.
  This patch drop ScopDecection from Scop.

llvm-svn: 260817
2016-02-13 15:12:47 +00:00
Johannes Doerfert 96e5471139 Separate invariant equivalence classes by type
We now distinguish invariant loads to the same memory location if they
  have different types. This will cause us to pre-load an invariant
  location once for each type that is used to access it. However, we can
  thereby avoid invalid casting, especially if an array is accessed
  though different typed/sized invariant loads.

  This basically reverts the changes in r260023 but keeps the test
  cases.

llvm-svn: 260045
2016-02-07 17:30:13 +00:00
Johannes Doerfert e708790c59 [FIX] Two "off-by-one" error in constant range usage
llvm-svn: 260031
2016-02-07 13:59:03 +00:00
Johannes Doerfert adeab372ca Simplify code [NFC]
llvm-svn: 260030
2016-02-07 13:57:32 +00:00
Tobias Grosser 8ebdc2dd53 Make memory accesses with different element types optional
We also disable this feature by default, as there are still some issues in
combination with invariant load hoisting that slipped through my initial
testing.

llvm-svn: 260025
2016-02-07 08:48:57 +00:00
Tobias Grosser 46bafbd0fe Do not yet consider loads with non-canonical element size for load hoisting.
Invariant load hoisting of memory accesses with non-canonical element
types lacks support for equivalence classes that contain elements of
different width/size. This support should be added, but to get our buildbots
back to green, we disable load hoisting for memory accesses with non-canonical
element size for now.

llvm-svn: 260023
2016-02-07 08:11:36 +00:00
Tobias Grosser 107cd5f5f6 IslNodeBuilder: Invariant load hoisting of elements with differing sizes
Always use access-instruction pointer type to load the invariant values.
Otherwise mismatches between ScopArrayInfo element type and memory access
element type will result in invalid casts. These type mismatches are after
r259784 a lot more common and also arise with types of different size, which
have not been handled before.

Interestingly, this change actually simplifies the code, as we now have only
one code path that is always taken, rather then a standard code path for the
common case and a "fixup" code path that replaces the standard code path in
case of mismatching types.

llvm-svn: 260009
2016-02-06 21:23:39 +00:00
Michael Kruse 2e02d560aa Follow uses to create value MemoryAccesses
The previously implemented approach is to follow value definitions and
create write accesses ("push defs") while searching for uses. This
requires the same relatively validity- and requirement conditions to be
replicated at multiple locations (PHI instructions, other instructions,
uses by PHIs).

We replace this by iterating over the uses in a SCoP ("pull in
requirements"), and add writes only when at least one read has been
added. It turns out to be simpler code because each use is only iterated
over once and writes are added for the first access that reads it. We
need another iteration to identify escaping values (uses not in the
SCoP), which also makes the difference between such accesses more
obvious. As a side-effect, the order of scalar MemoryAccess can change.

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

llvm-svn: 259987
2016-02-06 09:19:40 +00:00
Tobias Grosser d840fc7277 Support accesses with differently sized types to the same array
This allows code such as:

void multiple_types(char *Short, char *Float, char *Double) {
  for (long i = 0; i < 100; i++) {
    Short[i] = *(short *)&Short[2 * i];
    Float[i] = *(float *)&Float[4 * i];
    Double[i] = *(double *)&Double[8 * i];
  }
}

To model such code we use as canonical element type of the modeled array the
smallest element type of all original array accesses, if type allocation sizes
are multiples of each other. Otherwise, we use a newly created iN type, where N
is the gcd of the allocation size of the types used in the accesses to this
array. Accesses with types larger as the canonical element type are modeled as
multiple accesses with the smaller type.

For example the second load access is modeled as:

  { Stmt_bb2[i0] -> MemRef_Float[o0] : 4i0 <= o0 <= 3 + 4i0 }

To support code-generating these memory accesses, we introduce a new method
getAccessAddressFunction that assigns each statement instance a single memory
location, the address we load from/store to. Currently we obtain this address by
taking the lexmin of the access function. We may consider keeping track of the
memory location more explicitly in the future.

We currently do _not_ handle multi-dimensional arrays and also keep the
restriction of not supporting accesses where the offset expression is not a
multiple of the access element type size. This patch adds tests that ensure
we correctly invalidate a scop in case these accesses are found. Both types of
accesses can be handled using the very same model, but are left to be added in
the future.

We also move the initialization of the scop-context into the constructor to
ensure it is already available when invalidating the scop.

Finally, we add this as a new item to the 2.9 release notes

Reviewers: jdoerfert, Meinersbur

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

llvm-svn: 259784
2016-02-04 13:18:42 +00:00
Tobias Grosser dae306d2e4 ScopInfo: Improve documentation of ScopArrayInfo
This adds more information about how dimensions are incrementally updated and
what exactly the canonical element type is.

llvm-svn: 259772
2016-02-04 09:27:34 +00:00
Tobias Grosser a91684d554 Add 3.9 release notes document
llvm-svn: 259768
2016-02-04 08:10:29 +00:00
Tobias Grosser 719f843e67 Add 'Using Polly with Clang' to Spinx
llvm-svn: 259767
2016-02-04 07:45:32 +00:00
Tobias Grosser d7ccafe35f Add Sphinx configuration
This just adds the basic configuration with an empty index/welcome page

llvm-svn: 259765
2016-02-04 07:27:57 +00:00
Tobias Grosser b6948c1289 Add basic doxygen infrastructure for Polly
llvm-svn: 259764
2016-02-04 07:16:36 +00:00
Tobias Grosser 2a969e043a www: Remove some spaces
llvm-svn: 259761
2016-02-04 06:41:03 +00:00
Tobias Grosser 0ef8fa2528 www: Add Michael's thesis
llvm-svn: 259760
2016-02-04 06:40:59 +00:00
Tobias Grosser b9d4b24624 www: Add Felix-Antoine's master thesis
llvm-svn: 259759
2016-02-04 06:36:50 +00:00
Tobias Grosser 71c250445a www: Drop outdated dragonegg documentation
Even though the commands still work, dragonegg has not been updated to work with
recent versions of LLVM. Consequently, only very old Polly versions (which we
do not support any more), can be used in this way.

This simplifies our documentation page.

llvm-svn: 259758
2016-02-04 06:23:53 +00:00
Tobias Grosser a7f1e04031 Update to isl-0.16.1-20-gee54b48
This includes some (optional) improvements to the isl scheduler, which we do not
use yet, as well as a fix for a bug previously also affecting Polly:

commit 662ee9b7d45ebeb7629b239d3ed43442e25bf87c
Author: Sven Verdoolaege <skimo@kotnet.org>
Date:   Mon Jan 25 16:59:32 2016 +0100

    isl_basic_map_realign: perform Gaussian elimination on result

    Many parts of isl assume that Gaussian elimination has been
    applied to the equality constraints.  In particular singleton_extract_point
    makes this assumption.  The input to singleton_extract_point
    may have undergone parameter alignment.  This parameter alignment
    (ultimately performed by isl_basic_map_realign) therefore
    needs to make sure the result preserves this property

llvm-svn: 259757
2016-02-04 06:19:12 +00:00
Wei Mi eb14ac5396 Polly tests update contributed by Tobias Grosser for SCEV patch in r259736.
llvm-svn: 259737
2016-02-04 01:34:28 +00:00
Tobias Grosser ba043143a9 test: make test case more robust against removal of unrelated instructions
llvm-svn: 259693
2016-02-03 21:10:11 +00:00
Tobias Grosser bea6c54723 Properly build shared libraries if LLVM_LINK_LLVM_DYLIB is enabled.
Contributed-by: Jack Howarth <howarthjw@gmail.com>
llvm-svn: 259659
2016-02-03 16:29:04 +00:00
Tobias Grosser 05514e4d7f www: Simplify 'build & install' descriptions
We remove information for older versions of Polly and also shorten the overall
text. This should make it a lot easier for people to get to the important code
wight away.

llvm-svn: 259658
2016-02-03 16:18:24 +00:00
Tobias Grosser 23aea0d5d0 tScopInfo: Shorten comment slightly
llvm-svn: 259653
2016-02-03 15:42:38 +00:00
Tobias Grosser f4a97d0772 ScopInfo: Extend description of the access relation.
llvm-svn: 259633
2016-02-03 06:37:38 +00:00
Tobias Grosser e2c31210b2 Revert "Support loads with differently sized types from a single array"
This reverts commit (@259587). It needs some further discussions.

llvm-svn: 259629
2016-02-03 05:53:27 +00:00
Tobias Grosser 5d3fc1ea43 Support loads with differently sized types from a single array
We support now code such as:

void multiple_types(char *Short, char *Float, char *Double) {
  for (long i = 0; i < 100; i++) {
    Short[i] = *(short *)&Short[2 * i];
    Float[i] = *(float *)&Float[4 * i];
    Double[i] = *(double *)&Double[8 * i];
  }
}

To support such code we use as element type of the modeled array the smallest
element type of all original array accesses. Accesses with larger types are
modeled as multiple accesses with the smaller type.

For example the second load access is modeled as:

  { Stmt_bb2[i0] -> MemRef_Float[o0] : 4i0 <= o0 <= 3 + 4i0 }

To support jscop-rewritable memory accesses we need each statement instance to
only be assigned a single memory location, which will be the address at which
we load the value. Currently we obtain this address by taking the lexmin of
the access function. We may consider keeping track of the memory location more
explicitly in the future.

llvm-svn: 259587
2016-02-02 22:05:29 +00:00
Tobias Grosser db543ede7e ScopInfo: Split memory access construction into different cases
We create separate functions for fixed-size multi-dimensional, parameteric-sized
multi-dimensional, as well as single-dimensional memory accesses to reduce the
complexity of a large monolithic function.

Suggested-by: Michael Kruse <llvm@meinersbur.de>
llvm-svn: 259522
2016-02-02 16:46:49 +00:00
Tobias Grosser 5d51afedd8 ScopInfo: Do not track element-size as additional array size dimension [NFC]
There is no need to pass the size of the elements as the last size dimension
to ScopArrayInfo. This information is already available through the ElementType.
Tracking it twice is not only redundant but may result in inconsistencies.

llvm-svn: 259521
2016-02-02 16:46:45 +00:00
Johannes Doerfert 7c38b3296b [WWW] Add our Polly/OpenCL paper
llvm-svn: 259511
2016-02-02 15:03:31 +00:00
Johannes Doerfert 46d771c93f Remove unneeded definition [NFC]
llvm-svn: 259505
2016-02-02 14:16:22 +00:00
Johannes Doerfert 800e17a75c Add const keyword to MemoryAccess argument [NFC]
llvm-svn: 259504
2016-02-02 14:16:01 +00:00
Johannes Doerfert e0de09682e Sort analysis members and unifiy documentation [NFC]
llvm-svn: 259503
2016-02-02 14:15:37 +00:00
Johannes Doerfert a1f291ed18 Rename the DataLayout member [NFC]
llvm-svn: 259502
2016-02-02 14:15:13 +00:00
Johannes Doerfert a87810351c Remove helper function [NFC]
llvm-svn: 259501
2016-02-02 14:14:40 +00:00
Johannes Doerfert c36d39b7a8 Remove unnecessary getAnalysis call [NFC]
llvm-svn: 259500
2016-02-02 14:14:20 +00:00
Tobias Grosser cc77950b2b ScopInfo: Rename AccessType -> ElementType to unify naming with method declaration
llvm-svn: 259495
2016-02-02 13:22:54 +00:00
Tobias Grosser f5e239c4c3 www: Mark full/partial tile separation for vectorization as 'done'
Roman contributed this

llvm-svn: 259486
2016-02-02 09:55:59 +00:00
Tobias Grosser 0720570eee www: Update statistic code
llvm-svn: 259485
2016-02-02 09:55:55 +00:00
Tobias Grosser 6c2ae4592d www: update formatting of polyhedral.info news
llvm-svn: 259483
2016-02-02 09:30:01 +00:00
Tobias Grosser 542625eb6e www: Fix overlapping lines II
llvm-svn: 259477
2016-02-02 08:49:34 +00:00
Tobias Grosser 0dcafe94f8 Avoid overlapping lines
llvm-svn: 259476
2016-02-02 08:47:56 +00:00
Tobias Grosser c2fd8b411d ScopInfo: Correct schedule construction
For schedule generation we assumed that the reverse post order traversal used by
the domain generation is sufficient, however it is not. Once a loop is
discovered, we have to completely traverse it, before we can generate the
schedule for any block/region that is only reachable through a loop exiting
block.

To this end, we add a "loop stack" that will keep track of loops we
discovered during the traversal but have not yet traversed completely.
We will never visit a basic block (or region) outside the most recent
(thus smallest) loop in the loop stack but instead queue such blocks
(or regions) in a waiting list. If the waiting list is not empty and
(might) contain blocks from the most recent loop in the loop stack the
next block/region to visit is drawn from there, otherwise from the
reverse post order iterator.

We exploit the new property of loops being always completed before additional
loops are processed, by removing the LoopSchedules map and instead keep all
information in LoopStack. This clarifies that we indeed always only keep a
stack of in-process loops, but will never keep incomplete schedules for an
arbitrary set of loops. As a result, we can simplify some of the existing code.

This patch also adds some more documentation about how our schedule construction
works.

This fixes http://llvm.org/PR25879

This patch is an modified version of Johannes Doerfert's initial fix.

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

llvm-svn: 259354
2016-02-01 11:54:13 +00:00
Tobias Grosser ccbe383594 ScopInfo: Drop dead code in schedule description
In https://llvm.org/svn/llvm-project/polly/trunk@251870 code was committed to
avoid a failure in the presence of infinite loops, but the test case committed
along with this change passes without the actual change. I looked back into the
code and also checked with the original committer (Johannes), but could not find
the reason why the code is needed. The introduction of LoopStacks for
buildSchedule in one of the next commits will make it even more clear that this
code is not needed, but I remove this ahead of time to facilitate bisecting in
case I missed something.

llvm-svn: 259347
2016-02-01 10:07:43 +00:00
Tobias Grosser 0dd4a9a9f4 ScopInfo: use std::distance to shorten code [NFC]
llvm-svn: 259337
2016-02-01 01:55:08 +00:00
Craig Topper 7fb6e47101 Replace utostr_32 use with utostr to match removal from llvm.
llvm-svn: 259333
2016-01-31 20:36:20 +00:00
Tobias Grosser ed873cd3c1 cmake: Add additional libraries to fix the darwin shared library build
darwin requires the additional linkages of...

LLVMBitReader
LLVMMCParser
LLVMObject
LLVMProfileData
LLVMTarget
LLVMVectorize

as the darwin requires all of the weak undefined symbols in a library to be
resolved when linking it against an executable (unless
-Wl,-undefined,dynamic_lookup is used to override the default behavior of
-Wl,-undefined,error).

Contributed-by: Jack Howarth
llvm-svn: 259332
2016-01-31 20:25:46 +00:00
Michael Kruse 26311f00e8 Remove autotools build system
The autotools build system is based on and requires LLVM's autotools
build system to work, which has been depricated and finally removed in
r258861. Consequently we also remove the autotools build system from
Polly.

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

llvm-svn: 259041
2016-01-28 12:00:33 +00:00
Michael Kruse fd46308de4 ScopInfo: Never add read accesses for synthesizable values
Before adding a MK_Value READ MemoryAccess, check whether the read is
necessary or synthesizable. Synthesizable values are later generated by
the SCEVExpander and therefore do not need to be transferred
explicitly. This can happen because the check for synthesizability has
presumbly been forgotten in the case where a phi's incoming value has
been defined in a different statement.

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

llvm-svn: 258998
2016-01-27 22:51:56 +00:00
Michael Kruse 70131d3416 Introduce MemAccInst helper class; NFC
MemAccInst wraps the common members of LoadInst and StoreInst. Also use
of this class in:
- ScopInfo::buildMemoryAccess
- BlockGenerator::generateLocationAccessed
- ScopInfo::addArrayAccess
- Scop::buildAliasGroups
- Replace every use of polly::getPointerOperand

Reviewers: jdoerfert, grosser

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

llvm-svn: 258947
2016-01-27 17:09:17 +00:00
Michael Kruse ee6a4fc680 Unique phi write accesses
Ensure that there is at most one phi write access per PHINode and
ScopStmt. In particular, this would be possible for non-affine
subregions with multiple exiting blocks. We replace multiple MAY_WRITE
accesses by one MUST_WRITE access. The written value is constructed
using a PHINode of all exiting blocks. The interpretation of the PHI
WRITE's "accessed value" changed from the incoming value to the PHI like
for PHI READs since there is no unique incoming value.

Because region simplification shuffles around PHI nodes -- particularly
with exit node PHIs -- the PHINodes at analysis time does not always
exist anymore in the code generation pass. We instead remember the
incoming block/value pair in the MemoryAccess.

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

llvm-svn: 258809
2016-01-26 13:33:27 +00:00
Michael Kruse ad28e5a589 Unique value read accesses
Keep at most one value read MemoryAccess per value and statement;
multiple generated loads do not have any additional effect. As one such
MemoryAccess can cater multiple uses within the statement, the
AccessInstruction property is not unique any more and set to nullptr.

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

llvm-svn: 258808
2016-01-26 13:33:15 +00:00
Michael Kruse 436db620e7 Unique value write accesses
Ensure there is at most one write access per definition of an
llvm::Value. Keep track of already created value write access by using
a (dense) map.

Replace addValueWriteAccess by ensureValueStore which can be uses more
liberally without worrying to add redundant accesses. It will be used,
e.g. in a logical correspondant for value reads -- ensureValueReload --
to ensure that the expected definition has been written when loading it.

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

llvm-svn: 258807
2016-01-26 13:33:10 +00:00
Johannes Doerfert 6f50c29ab2 [FIX] Domain generation error due to loops in non-affine regions
llvm-svn: 258803
2016-01-26 11:03:25 +00:00
Johannes Doerfert 432658d7b8 [FIX] Build correct domain for non-affine region SCoPs
llvm-svn: 258802
2016-01-26 11:01:41 +00:00
Tobias Grosser f2cdd144e5 BlockGenerators: Replace getNewScalarValue with getNewValue
Both functions implement the same functionality, with the difference that
getNewScalarValue assumes that globals and out-of-scop scalars can be directly
reused without loading them from their corresponding stack slot. This is correct
for sequential code generation, but causes issues with outlining code e.g. for
OpenMP code generation. getNewValue handles such cases correctly.

Hence, we can replace getNewScalarValue with getNewValue. This is not only more
future proof, but also eliminates a bunch of code.

The only functionality that was available in getNewScalarValue that is lost
is the on-demand creation of scalar values. However, this is not necessary any
more as scalars are always loaded at the beginning of each basic block and will
consequently always be available when scalar stores are generated. As this was
not the case in older versions of Polly, it seems the on-demand loading is just
some older code that has not yet been removed.

Finally, generateScalarLoads also generated loads for values that are loop
invariant, available in GlobalMap and which are preferred over the ones loaded
in generateScalarLoads. Hence, we can just skip the code generation of such
scalar values, avoiding the generation of dead code.

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

llvm-svn: 258799
2016-01-26 10:01:35 +00:00
Tobias Grosser 232905089e test: Name instructions in a test case [NFC]
llvm-svn: 258662
2016-01-24 17:51:37 +00:00
Tobias Grosser 5c7f16be6b BlockGenerators: Avoid redundant map lookup [NFC]
llvm-svn: 258660
2016-01-24 14:16:59 +00:00
Tobias Grosser c9abde8c51 ScopInfo: Simplify code by folding definition into if
llvm-svn: 258632
2016-01-23 20:23:06 +00:00
Tobias Grosser 1c3a6d7808 ScopDetection: Do not detect regions with irreducible control as scops
Polly currently does not support irreducible control and it is probably not
worth supporting. This patch adds code that checks for irreducible control
and refuses regions containing irreducible control.

Polly traditionally had rather restrictive checks on the control flow structure
which would have refused irregular control, but within the last couple of months
most of the control flow restrictions have been removed. As part of this
generalization we accidentally allowed irregular control flow.

Contributed-by: Karthik Senthil and Ajith Pandel
llvm-svn: 258497
2016-01-22 09:44:37 +00:00
Tobias Grosser b3a9538e95 Remove irreducible control flow from test case
The test case we look at does not necessarily require irreducible control flow,
but a normal loop is sufficient to create a non-affine region containing more
than one basic block that dominates the exit node. We replace this irreducible
control flow with a normal loop for the following reasons:

  1) This is easier to understand
  2) We will subsequently commit a patch that ensures Polly does not process
     irreducible control flow.

Within non-affine regions, we could possibly handle irreducible control flow.

llvm-svn: 258496
2016-01-22 09:33:33 +00:00
Tobias Grosser 40038d2d1e www: Update links to LLVM bug tracker
Polly recently got its own product in LLVM's bug tracker, which will make it
easier for people to file Polly bugs. This change updates the bugtracker links
on the Polly website.

llvm-svn: 258494
2016-01-22 08:19:54 +00:00
Sumanth Gundapaneni 4b1472fb2b Fix the error in non-asserts Release mode build. NFC
llvm-svn: 258318
2016-01-20 15:41:30 +00:00
Johannes Doerfert 370cf00c9f Make sure we preserve alignment information after hoisting invariant load
In Polly, after hoisting loop invariant loads outside loop, the alignment
information for hoisted loads are missing, this patch restore them.

Contributed-by: Lawrence Hu <lawrence@codeaurora.org>

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

llvm-svn: 258105
2016-01-19 00:17:21 +00:00
Michael Kruse dc8508e72a Do not check JSON alignment of scalar accesses
When importing a schedule, do not verify the load/store alignment of
scalar accesses. Scalar loads/store are always created newly in code
generation with no alignment restrictions. Previously, scalar alignment
was checked if the access instruction happened to be a LoadInst or
StoreInst, but only its array (MK_Array) access is relevant.

This will be implicitly unit-tested when the access instruction of a
value read can be nullptr.

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

llvm-svn: 257904
2016-01-15 16:49:33 +00:00
Michael Kruse 959a8dc39f Update to ISL 0.16.1
llvm-svn: 257898
2016-01-15 15:54:45 +00:00
Michael Kruse f7d5e40860 Add option to update-isl.sh for specific commit
This is used e.g. to update specifically to ISL 0.16.1 although newer
revisions exist in the official repository.

llvm-svn: 257895
2016-01-15 15:41:59 +00:00
Michael Kruse 5a9a65e43f Prepare unit tests for update to ISL 0.16
ISL 0.16 will change how sets are printed which breaks 117 unit tests
that text-compare printed sets. This patch re-formats most of these unit
tests using a script and small manual editing on top of that. When
actually updating ISL, most work is done by just re-running the script
to adapt to the changed output.

Some tests that compare IR and tests with single CHECK-lines that can be
easily updated manually are not included here.

The re-format script will also be committed afterwards. The per-test
formatter invocation command lines options will not be added in the near
future because it is ad hoc and would overwrite the manual edits.
Ideally it also shouldn't be required anymore because ISL's set printing
has become more stable in 0.16.

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

llvm-svn: 257851
2016-01-15 00:48:42 +00:00
Roman Gareev b0c4e49a37 Fix of r257495.
Remove redundant "FPM->add(createDemoteRegisterToMemoryPass());"

llvm-svn: 257514
2016-01-12 20:47:48 +00:00
Roman Gareev 6ebc01c973 We do not need to schedule another loop interchange pass after Polly, as Polly
should perform loop interchanges itself.

This also fixes a bug we see due to the "loop-interchange" pass producing
incorrect IR when compiling linpack-pc.c from the LLVM test-suite with
"-polly-position=before-vectorizer".

Reviewed-by: Tobias Grosser <tobias@grosser.es>
llvm-svn: 257495
2016-01-12 17:59:06 +00:00
Roman Gareev 10595a1739 Call assumeNoOutOfBound only in updateDimensionality
Call assumeNoOutOfBound only in updateDimensionality to process situations
when new dimensions are added and new bounds checks are required.

Contributed-by: Tobias Grosser, Gareev Roman
llvm-svn: 257170
2016-01-08 14:01:59 +00:00
Tobias Grosser 8362c26113 Define buildScheduleRec on RegionNodes and pull out the tree traversal [NFC]
This change clarifies that for Not-NonAffine-SubRegions we actually iterate over
the subnodes and for both NonAffine-SubRegions and BasicBlocks, we perform the
schedule construction. As a result, the tree traversal becomes trivial, the
special case for a scop consisting just of a single non-affine region
disappears and the indentation of the code is reduced.

No functional change intended.

llvm-svn: 256940
2016-01-06 15:30:06 +00:00
Johannes Doerfert f9711ef922 Extract constant parts of the schedule generation [NFC]
llvm-svn: 256931
2016-01-06 12:59:23 +00:00
Tobias Grosser 05e71b9f61 ScopInfo: use getStmtForRegionNode to simplify code slightly
llvm-svn: 256914
2016-01-06 05:18:20 +00:00
Tobias Grosser c28ae257c0 TODO: Polly can handle boolean expressions (Open->Done)
The necessary support was committed by Johannes in r249971.

llvm-svn: 256826
2016-01-05 11:48:59 +00:00
Tobias Grosser 100ef6b30c TODO: We do not use -independent-blocks any more (Open -> Done)
llvm-svn: 256825
2016-01-05 11:45:26 +00:00