Commit Graph

2069 Commits

Author SHA1 Message Date
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
Tobias Grosser ce9ef39c10 IslExprBuilder: Provide PointerLikeTypeTraits for isl_id
Providing an explicit PointerLikeTypeTraits implementation became necessary
since LLVM started in https://llvm.org/svn/llvm-project/llvm/trunk@256620
to automatically derive the pointer alignment from the pointer element type,
which does not work for incomplete types as used by isl. To ensure our code
still compiles, we provide an instantiation of PointerLikeTypeTraits for isl_id
which assumes no minimal alignment. isl pointers are likely to have a "higher"
alignment. We can exploit this later in case this becomes performance relevant.

llvm-svn: 256650
2015-12-30 20:11:48 +00:00
Tobias Grosser 5a90a985b9 ScopDetection: Add include to make complete type of llvm::Region available
This is necessary for the recent ptr-traits work in LLVM, which now requires
complete type definitions.

llvm-svn: 256649
2015-12-30 20:11:43 +00:00
Michael Kruse 58fa3bb63a Do not store scalar accesses in InstructionToAccess
At code generation, scalar reads are generated before the other
statement's instructions, respectively scalar writes after them, in
contrast to array accesses which are "executed" with the instructions
they are linked to. Therefore it makes sense to not map the scalar
accesses to a place of execution. Follow-up patches will also remove
some of the directs links from a scalar access to a single instruction,
such that only having array accesses in InstructionToAccess ensures
consistency.

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

llvm-svn: 256298
2015-12-22 23:25:11 +00:00
Johannes Doerfert 5dced2693e Refactor canSynthesize in the BlockGenerators [NFC]
llvm-svn: 256269
2015-12-22 19:08:49 +00:00
Johannes Doerfert 28f8ac1db2 Treat inline assembly as a constant in the code generation.
llvm-svn: 256267
2015-12-22 19:08:24 +00:00
Johannes Doerfert 42df8d1db6 Reduce indention in BlockGenerator::trySynthesizeNewValue [NFC]
llvm-svn: 256266
2015-12-22 19:08:01 +00:00
Tobias Grosser c6424ae46c ScopDetection: Simplify std::distance(....) to BB->size()
Suggested by: Johannes Doerfert <doerfert@cs.uni-saarland.de>

llvm-svn: 256260
2015-12-22 17:38:59 +00:00
Tobias Grosser fcabb155c1 BlockGenerators: Remove unnecessary const_cast
llvm-svn: 256227
2015-12-22 01:41:25 +00:00
Tobias Grosser c900633d60 ScopInfo: Small improvement to schedule construction [NFC]
We clarify that certain code is only executed if LSchedule is != nullptr.
Previously some of these functions have been executed, but they only passed
a nullptr through. This caused some confusion when reading the code.

llvm-svn: 256209
2015-12-21 23:01:53 +00:00
Tobias Grosser cbf7ae8fef ScopInfo: Polish the implementation of mapToDimension
Besides improving the documentation and the code we now assert in case the input
is invalid (N < 0) and also do not any more return a nullptr in case USet is
empty. This should make the code more readable.

llvm-svn: 256208
2015-12-21 22:45:53 +00:00
Tobias Grosser c1a269bf0e Add option to assume single-loop scops with sufficient compute are profitable
If a loop has a sufficiently large amount of compute instruction in its loop
body, it is unlikely that our rewrite of the loop iterators introduces large
performance changes. As Polly can also apply beneficical optimizations (such
as parallelization) to such loop nests, we mark them as profitable.

This option is currently "disabled" by default, but can be used to run
experiments. If enabled by setting it e.g. to 40 instructions, we currently
see some compile-time increases on LNT without any significant run-time
changes.

llvm-svn: 256199
2015-12-21 21:00:43 +00:00
Tobias Grosser 5624d3c978 Adjust formatting to clang-format changes in 256149
llvm-svn: 256151
2015-12-21 12:38:56 +00:00
Tobias Grosser 97fc5bb7f7 ScopDetect: Extract profitability check into subfunction
.. and add some documentation. We also simplify the code by dropping an early
check that is also covered by the the later checks. This might have a small
compile time impact, but as the scops that are skipped are small we should
probably only add this back in the unlikely case that this has a notable
compile-time cost.

No functional change intended.

llvm-svn: 256149
2015-12-21 12:14:48 +00:00
Tobias Grosser 594882573e ScopInfo: Return immediately if scop is unprofitable and marked invalid
As we already log an error when calling invalid, scops unprofitable scops are in
any case marked invalid, but returning immediately safes (a tiny bit of) compile
time and is consistent with our use of 'invalid' in the remainder of the file.

Found by inspection.

llvm-svn: 256140
2015-12-21 09:09:44 +00:00
Tobias Grosser bfaf1ae309 ScopInfo: Return in case we found an invalid array size
Without this return we still log the incorrect array size (and do not detect
this scop), but we would unnecessarily continue to verify that access functions
are affine. As we do not need to do this, we can return right ahead and
consequently safe compile time.

This issue was found by inspection.

llvm-svn: 256139
2015-12-21 09:09:39 +00:00
Tobias Grosser 949e8c6ac6 ScopInfo: Check for the existance of a single memory accesses
Instead of counting all array memory accesses associated with a load
instruction, we now explicitly check that the single array access that could
(potentially) be associated with a load instruction does not exist. This helps
to document the current behavior of Polly where load instructions can indeed
have at most one associated array access. In the unlikely case this changes
in the future, we add an assert for the case where two load accesses would
prevent us to return a single memory access, but we still should communicate
that not all array memory accesses have been removed.

This addresses post-commit comments from Johannes Doerfert for commit 255776.

llvm-svn: 256136
2015-12-21 07:10:39 +00:00
Johannes Doerfert 30e2307f61 [FIX] Schedule generation for block exiting multiple loops.
This fixes bug PR25604.

llvm-svn: 256125
2015-12-20 17:12:22 +00:00
Michael Kruse 8fc2896ee0 Compile fix: Use "&&" operator instead of "and"
llvm-svn: 256124
2015-12-20 14:42:32 +00:00
Tobias Grosser 75dc40c3be ScopInfo: Bail out in case of complex branch structures
Scops that contain many complex branches are likely to result in complex domain
conditions that consist of a large (> 100) number of conjucts.  Transforming
such domains is expensive and unlikely to result in efficient code.  To avoid
long compile times we detect this case and skip such scops. In the future we may
improve this by either using non-affine subregions to hide such complex
condition structures or by exploiting in certain cases properties (e.g.,
dominance) that allow us to construct the domains of a scop in a way that
results in a smaller number improving conjuncts.

Example of a code that results in complex iteration spaces:

      loop.header
     /    |    \ \
   A0    A2    A4 \
     \  /  \  /    \
      A1    A3      \
     /  \  /  \     |
   B0    B2    B4   |
     \  /  \  /     |
      B1    B3      ^
     /  \  /  \     |
   C0    C2    C4   |
     \  /  \  /    /
      C1    C3    /
       \   /     /
    loop backedge

llvm-svn: 256123
2015-12-20 13:31:48 +00:00
Roman Gareev 22803d4488 Fix of a comment.
llvm-svn: 255923
2015-12-17 20:47:10 +00:00
Roman Gareev 8aa437503c Fix delinearization of fortran arrays
The patch fixes Bug 25759 produced by inappropriate handling of unsigned
maximum SCEV expressions by SCEVRemoveMax. Without a fix, we get an infinite
loop and a segmentation fault, if we try to process, for example,
'((-1 + (-1 * %b1)) umax {(-1 + (-1 * %yStart)),+,-1}<%.preheader>)'.
It also fixes a potential issue related to signed maximum SCEV expressions.

Tested-by: Roman Gareev <gareevroman@gmail.com>
Fixed-by: Tobias Grosser <tobias@grosser.es>

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

llvm-svn: 255922
2015-12-17 20:37:17 +00:00
Tobias Grosser deb4abb409 Fix formatting
llvm-svn: 255892
2015-12-17 13:04:30 +00:00
Tobias Grosser eb2eebe486 ScopGraphPrinter: Only show functions that contain at least one scop
When running 'clang -O3 -mllvm -polly -mllvm -polly-show' we now only show the
CFGs of functions with at least one detected scop. For larger files/projects
this reduces the number of graphs printed significantly and is likely what
developers want to see. The new option -polly-view-all enforces all graphs to be
printed and the exiting option -poll-view-only limites the graph printing to
functions that match a certain pattern.

This patch requires https://llvm.org/svn/llvm-project/llvm/trunk@255889 (and
vice versa) to compile correctly.

llvm-svn: 255891
2015-12-17 12:55:26 +00:00
Tobias Grosser 10120189ab ScopInfo: Directly store MemoryAccessList in InstructionToAccess
This avoids the need for explicit memory management, simplifies the code and
also fixes a memory leak in removeMemoryAccesses.

llvm-svn: 255777
2015-12-16 16:14:03 +00:00
Tobias Grosser 2ed317383b ScopInfo: Introduce getNumberOfArrayAccesses
Use the new function to clarify that we indeed only want to know it at least
one array access is associated with an instruction.

llvm-svn: 255776
2015-12-16 16:14:00 +00:00
Tobias Grosser 04d4964462 ScopInfo: Delete code that has been made dead by previous commits
In case this functionality is needed in later patches, it should probably be
(re)added by these patches.

llvm-svn: 255717
2015-12-15 23:50:09 +00:00
Tobias Grosser 35ec5fbb8c ScopInfo: Use getArrayAccessFor in reduction detection
Load instructions may possibly be related to multiple memory accesses, but we
are only interested in the array read access that describes the memory location
the load instructions loads from. By using getArrayAccessfor we ensure to always
obtain the right memory access.

This issue was found by inspection without having a failing test case.

llvm-svn: 255716
2015-12-15 23:50:04 +00:00
Tobias Grosser 184a4926b3 BlockGenerator: Use getArrayAccessFor for vector code generation
getAccessFor does not guarantee a certain access to be returned in case an
instruction is related to multiple accesses. However, in the vector code
generation we want to know the stride of the array access of a store
instruction. By using getArrayAccessFor we ensure we always get the correct
memory access.

This patch fixes a potential bug, but I was unable to produce a failing test
case. Several existing test cases cover this code, but all of them already
passed out of luck (or the specific but not-guaranteed order in which we build
memory accesses).

llvm-svn: 255715
2015-12-15 23:50:01 +00:00
Tobias Grosser a69d4f0d83 VectorBlockGenerator: Generate scalar loads for vector statements
When generating scalar loads/stores separately the vector code has not been
updated. This commit adds code to generate scalar loads for vector code as well
as code to assert in case scalar stores are encountered within a vector loop.

llvm-svn: 255714
2015-12-15 23:49:58 +00:00
Tobias Grosser 0921477248 ScopInfo: Look up first (and only) array access
When rewriting the access functions of load/store statements, we are only
interested in the actual array memory location. The current code just took
the very first memory access, which could be a scalar or an array access. As
a result, we failed to update access functions even though this was requested
via .jscop.

llvm-svn: 255713
2015-12-15 23:49:53 +00:00