Commit Graph

1413 Commits

Author SHA1 Message Date
Tobias Grosser 31441c4614 ScopInfo: Add MemoryAccess::isScalar()
Suggested-by: Michael Kruse <llvm@meinersbur.de>
llvm-svn: 254921
2015-12-07 18:06:08 +00:00
Tobias Grosser a5d9e65e17 Update isl to isl-0.15-142-gf101714
This update brings in improvements to isl's 'isolate' option that reduce the
number of code versions generated. This results in both code-size and compile
time reduction for outer loop vectorization.

Thanks to Roman Garev and Sven Verdoolaege for working on this improvement.

llvm-svn: 254706
2015-12-04 08:46:14 +00:00
Michael Kruse aed1e03888 Update isl to isl-0.15-140-g9279e30
The motivation is to fix a compilation error with Visual Studio 2013.
See http://reviews.llvm.org/D14886.

Thanks to Sumanth Gundapaneni for finding the issue and suggesting a
patch.

llvm-svn: 254498
2015-12-02 09:35:04 +00:00
Michael Kruse 054729b420 Add script to update isl
The script will checkout the most recent master from
http://repo.or.cz/isl.git into /tmp, create a distribution tarball, and
extract it as replacement of lib/External/isl. After that it can be
committed to the Polly repository.

llvm-svn: 254497
2015-12-02 09:34:46 +00:00
Tobias Grosser 2fd89da90d Remove non-debug printing of domain set
Contributed-by: Chris Jenneisch <chrisj@codeaurora.org>

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

llvm-svn: 254343
2015-11-30 22:59:41 +00:00
Tobias Grosser 3a6ac9f9b5 ScopInfo: Further simplify code
Acc==MA implies Acc->getAccessInstruction() == MA->getAccessInstruction().

Suggested as post-commit review for 254305 by Michael Kruse.

llvm-svn: 254327
2015-11-30 21:13:43 +00:00
Tobias Grosser ef9ca5db16 ScopInfo: Replace while/iterator construct with std::remove_if
The use of C++'s high-level iterator functionality instead of two while loops
and explicit iterator handling improves readability of this code.

Proposed-by: Michael Kruse <llvm@meinersbur.de>

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

llvm-svn: 254305
2015-11-30 17:20:40 +00:00
Michael Kruse 4c86a1d97b IR cleanup after CodeGeneration
Re-run canonicalization passes after Polly's code generation.

The set of passes currently added here are nearly all the passes between
--polly-position=early and --polly-position=before-vectorizer, i.e. all
passes that would usually run after Polly.

In order to run these only if Polly actually modified the code, we add a
function attribute "polly-optimzed" to a function that contains
generated code. The cleanup pass is skipped if the function does not
have this attribute.

There is no support by the (legacy) PassManager to run passes only under
some conditions. One could have wrapped all transformation passes to run
only when CodeGeneration changed the code, but the analyses would run
anyway. This patch creates an independent pass manager. The
disadvantages are that all analyses have to re-run even if preserved and
it does not honor compiler switches like the PassManagerBuilder does.

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

llvm-svn: 254150
2015-11-26 12:36:25 +00:00
Michael Kruse cba170e4d0 Introduce origin/kind for exit PHI node accesses
Previously, accesses that originate from PHI nodes in the exit block
were registered as SCALAR. In some context they are treated as scalars,
but it makes a difference in others. We used to check whether the
AccessInstruction is a terminator to differentiate the cases.

This patch introduces an MemoryAccess origin EXIT_PHI and a
ScopArrayInfo kind KIND_EXIT_PHI to make this case more explicit. No
behavioural change intended.

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

llvm-svn: 254149
2015-11-26 12:26:06 +00:00
Tobias Grosser 2f8e43d677 ScopInfo: Add support for delinearizing fortran arrays
gfortran (and fortran in general?) does not compute the address of an array
element directly from the array sizes (e.g., %s0, %s1), but takes first the
maximum of the sizes and 0 (e.g., max(0, %s0)) before multiplying the resulting
value with the per-dimension array subscript expressions. To successfully
delinearize index expressions as we see them in fortran, we first filter 'smax'
expressions out of the SCEV expression, use them to guess array size parameters
and only then continue with the existing delinearization.

llvm-svn: 253995
2015-11-24 17:06:38 +00:00
Tobias Grosser 4927c8e606 ScopInfo: Add option to ignore integer wrapping
llvm-svn: 253976
2015-11-24 12:50:02 +00:00
Tobias Grosser d68ba42556 ScopInfo: Split hasAffineMemoryAccesses() into multiple functions [NFC]
This makes the overall code more readable.

llvm-svn: 253951
2015-11-24 05:00:36 +00:00
Tobias Grosser 5ef2bc316d Use SmallVector instead of std::vector
This was proposed as post-commit review comment for commit r253818.

Suggested by: Johannes Doerfert <doerfert@cs.uni-saarland.de>

llvm-svn: 253862
2015-11-23 10:18:23 +00:00
Tobias Grosser 9737c7b431 ScopInfo: Remove domains of error blocks (and blocks they dominate) early on
Trying to build up access functions for any of these blocks is likely to fail,
as error blocks may contain invalid/non-representable instructions, and blocks
dominated by error blocks may reference such instructions, which wil also cause
failures. As all of these blocks are anyhow assumed to not be executed, we can
just remove them early on.

This fixes http://llvm.org/PR25596

llvm-svn: 253818
2015-11-22 11:06:51 +00:00
Tobias Grosser fb3fb0a309 isl: Update to isl-0.15-136-g4d5654a
The most interesting change for Polly in this isl update is 4d5654af which
in certain cases can speed up the construction of run-time checks from an isl
set consisting of several disjuncts significantly.

llvm-svn: 253794
2015-11-21 20:48:39 +00:00
Johannes Doerfert a2a74f09fc Do not enforce lcssa
At some point we enforced lcssa for the loop surrounding the entry block.
  This is not only questionable as it does not check any other loop but also
  not needed any more.

llvm-svn: 253789
2015-11-21 17:00:02 +00:00
Johannes Doerfert dec27df588 [FIX] Get the correct loop that surrounds a region
llvm-svn: 253788
2015-11-21 16:56:13 +00:00
Tobias Grosser b39c96aa19 ScopInfo: Ensure unique names for parameter names coming from load instructions
In case the original parameter instruction does not have a name, but it comes
from a load instruction where the base pointer has a name we used the name of
the load instruction to give some more intuition of where the parameter came
from. To ensure this works also through GEPs which may have complex offsets,
we originally just dropped the offsets and _only_ used the base pointer name.
As this can result in multiple parameters to get the same name, we now prefix
the parameter ID to ensure parameter names are unique. This will make it easier
to understand debug output.

This change does not affect correctness, as parameter IDs (even of the same
name) can always be distinguished through the SCEV pointer stored inside them.

llvm-svn: 253330
2015-11-17 11:54:51 +00:00
Tobias Grosser f920fb19f1 ScopInfo: Reset compute operations before starting compute out region
Without this change we may start to refuse scops in larger compilation units
just because a lot of code has already been compiled earlier.

Found by inspection. I do not yet have a good test case for this.

llvm-svn: 253050
2015-11-13 16:56:13 +00:00
Johannes Doerfert a4b77c079b [FIX] Bail if access function is not divisible by element size.
llvm-svn: 252942
2015-11-12 20:15:32 +00:00
Johannes Doerfert 55b3d8b831 Consistenly use getTypeAllocSize for size estimation.
Only when we check for wrapping we want to use the store size, for all
  other cases we use the alloc size now.

Suggested by: Tobias Grosser <tobias@grosser.es>

llvm-svn: 252941
2015-11-12 20:15:08 +00:00
Tobias Grosser 2ac2338a03 ScopInfo: Add function to retrieve all memory accesses in a scop
llvm-svn: 252894
2015-11-12 14:07:13 +00:00
Tobias Grosser e5a3514e4a ScopInfo: Use lambda functions to reduce code duplication.
llvm-svn: 252893
2015-11-12 14:07:09 +00:00
Tobias Grosser bc29e0b27c RegionGenerator: Only introduce subregion.ivs for loops fully within a subregion
IVs of loops for which the loop header is in the subregion, but not the entire
loop may be incremented outside of the subregion and can consequently not be
kept private to the subregion. Instead, they need to and are modeled as virtual
loops in the iteration domains. As this is the case, generating new subregion
induction variables for such loops is not needed and indeed wrong as they would
hide the virtual induction variables modeled in the scop.

This fixes a miscompile in MultiSource/Benchmarks/Ptrdist/bc and
MultiSource/Benchmarks/nbench/. Thanks Michael and Johannes for their
investiagations and helpful observations regarding this bug.

llvm-svn: 252860
2015-11-12 07:34:09 +00:00
Johannes Doerfert 2af10e2eed Use parameter constraints provided via llvm.assume
If an llvm.assume dominates the SCoP entry block and the assumed condition
  can be expressed as an affine inequality we will now add it to the context.

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

llvm-svn: 252851
2015-11-12 03:25:01 +00:00
Johannes Doerfert d84493e52e Emit remarks for taken assumptions
Differential Revision: http://reviews.llvm.org/D14412

llvm-svn: 252848
2015-11-12 02:33:38 +00:00
Johannes Doerfert 0cf4e0aa42 Emit remark about aliasing pointers
llvm-svn: 252847
2015-11-12 02:32:51 +00:00
Johannes Doerfert 48fe86f1ff Emit SCoP source location as remark during ScopInfo
This removes a similar feature from ScopDetection, though with
  -polly-report that feature present twice anyway.

llvm-svn: 252846
2015-11-12 02:32:32 +00:00
Johannes Doerfert fdbf201fc9 [FIX] Do not generate code for parameters referencing dead values
Check if a value that is referenced by a parameter is dead and do not
generate code for the parameter in such a case.

llvm-svn: 252813
2015-11-11 22:40:51 +00:00
Tobias Grosser e19fca4525 ScopInfo: Bailing out means assigning isl_set_empty to the AssumedContext
I got this the other way around in 252750. Thank you Johannes for noticing.

llvm-svn: 252795
2015-11-11 20:21:39 +00:00
Tobias Grosser 910cf26811 ScopInfo: Do not try to model the memory accesses in an error block
Error blocks may contain arbitrary instructions, among them some which we can
not modeled correctly. As we do not generate ScopStmts for error blocks anyhow
there is no point in trying to generate access functions for them.

This fixes llvm.org/PR25494

llvm-svn: 252794
2015-11-11 20:15:49 +00:00
Johannes Doerfert 9d7899ef9c [NFC] Simplify code
llvm-svn: 252792
2015-11-11 20:01:31 +00:00
Tobias Grosser 316b5b2507 ScopInfo: Remove unused return value [NFC]
llvm-svn: 252780
2015-11-11 19:28:14 +00:00
Tobias Grosser a52b4da039 ScopInfo: Free set after compute out has been triggered
In certain cases isl will not free the return values of operations for which
a computeout has been triggered. Hence, make sure we free it explicitly.

No test, as I did not manage to reduce one yet.

llvm-svn: 252766
2015-11-11 17:59:53 +00:00
Tobias Grosser 4cd07b1188 ScopInfo: Bound compute time spent in boundary context construction
For complex inputs our current approach of construction the boundary context
may in rare cases become computationally so expensive that it is better to
abort. This change adds a compute out check that bounds the compuations we
spend on boundary context construction and bails out if this limit is reached.

We can probably make our boundary construction algorithm more efficient, but
this requires some more investigation and probably also some additional changes
to isl. Until these have been added, we bound the compile time to ensure our
buildbots are green.

llvm-svn: 252758
2015-11-11 17:34:02 +00:00
Tobias Grosser 20a4c0c205 ScopInfo: Limit the number of disjuncts in assumed context
In certain rare cases (mostly -polly-process-unprofitable on large sequences
of conditions - often without any loop), we see some compile-time timeouts due
to the construction of an overly complex assumption context. This change limits
the number of disjuncts to 150 (adjustable), to prevent us from creating
assumptions contexts that are too large for even the compilation to finish.

The limit has been choosen as large as possible to make sure we do not
unnecessarily drop test coverage. If such cases also appear in
-polly-process-unprofitable=false mode we may need to think about this again,
as the current limitations may still allow assumptions that are way to complex
to be checked profitably at run-time.

There is also certainly room for improvement regarding how (and how efficient)
we construct an assumed context, but this requires some more thinking.

This completes llvm.org/PR25458

llvm-svn: 252750
2015-11-11 16:22:36 +00:00
Tobias Grosser e3d1f1c0b0 ScopDetection: Tighten the check for always executed 'error blocks'
Basic blocks that are always executed can not be error blocks as their execution
can not possibly be an unlikely event. In this commit we tighten the check
if an error block to basic blcoks that do not dominate the exit condition, but
that dominate all exiting blocks of the scop.

llvm-svn: 252726
2015-11-11 13:25:13 +00:00
Tobias Grosser b12b006c4b ScopDetection: Do not allow blocks to reference operands in error blocks
r252713 introduced a couple of regressions due to later basic blocks refering
to instructions defined in error blocks which have not yet been modeled.

This commit is currently just encoding limitations of our modeling and code
generation backends to ensure correctness. In theory, we should be able to
generate and optimize such regions, as everything that is dominated by an error
region is assumed to not be executed anyhow. We currently just lack the code
to make this happen in practice.

llvm-svn: 252725
2015-11-11 12:44:18 +00:00
Tobias Grosser b76cd3cc56 ScopInfo: Pass domain constraints through error blocks
Previously, we just skipped error blocks during scop construction. With
this change we make sure we can construct domains for error blocks such that
these domains can be forwarded to subsequent basic blocks.

This change ensures that basic blocks that post-dominate and are dominated by
a basic block that branches to an error condition have the very same iteration
domain as the branching basic block. Before, this change we would construct
a domain that excludes all error conditions. Such domains could become _very_
complex and were undesirable to build.

Another solution would have been to drop these constraints using a
dominance/post-dominance check instead of modeling the error blocks. Such
a solution could also work in case of unreachable statements or infinite
loops in the scop. However, as we currently (to my believe incorrectly) model
unreachable basic blocks in the post-dominance tree, such a solution is not
yet feasible and requires first a change to LLVM's post-dominance tree
construction.

This commit addresses the most sever compile time issue reported in:
http://llvm.org/PR25458

llvm-svn: 252713
2015-11-11 08:42:20 +00:00
Johannes Doerfert dcfedf3505 [FIX] Cast pre-loaded values correctly or reload them with adjusted type.
Especially for structs, the SAI object of a base pointer does not
describe all the types that the user might expect when he loads from
that base pointer. While we will still cast integers and pointers we
will now reload the value with the correct type if floating point and
non-floating point values are involved. However, there are now TODOs
where we use bitcasts instead of a proper conversion or reloading.

This fixes bug 25479.

llvm-svn: 252706
2015-11-11 06:20:25 +00:00
Johannes Doerfert fc4bfc465a [FIX] Create empty invariant equivalence classes
We now create all invariant equivalence classes for required invariant loads
  instead of creating them on-demand. This way we can check if a parameter
  references an invariant load that is actually not executed and was therefor
  not materialized. If that happens the parameter is not materialized either.

This fixes bug 25469.

llvm-svn: 252701
2015-11-11 04:30:07 +00:00
Tobias Grosser 6abc75af4c ScopInfo: Introduce ArrayKind
Since 252422 we do not only distinguish two ScopArrayInfo kinds, PHI nodes
and others, but work with three kind of ScopArrayInfo objects. SCALAR, PHI and
ARRAY objects. Instead of keeping two boolean flags isPHI and isScalar and
wonder what an ScopArrayInfo object of kind (!isScalar && isPHI) is, we
list now explicitly the three different possible types of memory objects.

This change also allows us to remove the confusing nested pairs that have
been used in ArrayInfoMapTy.

llvm-svn: 252620
2015-11-10 17:31:31 +00:00
Tobias Grosser b43cc62fe1 stringFromIslObj: Do not crash when printing 'null' objects
No test case, as this code path is currently only used for debugging.

llvm-svn: 252609
2015-11-10 15:09:44 +00:00
Tobias Grosser 262538435f ScopInfo: Make getDimensionSize better reflect which dimensions carry sizes
In polly the first dimensions of an array as well as all scalars do not carry
any size information. This commit makes this explicit in the interface of
getDimensionSize. Before this commit getDimensionSize(0) returned the size of
the first dimension that carried a size. After this commit getDimensionSize(i)
will either return the size of dimension 'i' or assert in case 'i' does not
carry a size or does not exist at all.

This very same behaviour was already present in getDimensionSizePw(). This
commit also adds assertions that ensure getDimensionSizePw() is called
appropriately.

llvm-svn: 252607
2015-11-10 14:24:21 +00:00
Tobias Grosser 4ea2e07a60 ScopInfo: Make printing of ScopArrayInfo more similar to declarations in C
Memory references are now printed as follows:

           Old                          New
Scalars:   i64 MemRef_val[*]            i64 MemRef_val;
Arrays:    i64 MemRef_A[*][%m][%o][8]   i64 MemRef_A[*][%m][%o];

We do not print any more information about the element size in the type. Such
information has already been available in a comment after the scalar/array
declaration. It was redundant and did not match well with what people were used
from C.

llvm-svn: 252602
2015-11-10 14:02:54 +00:00
Michael Kruse c993739e0d Fix non-affine generated entering node not being recognized as dominating
Scalar reloads in the generated entering block were not recognized as
dominating the subregions locks when there were multiple entering
nodes. This resulted in values defined in there not being copied.

As a fix, we unconditionally add the BBMap of the generated entering
node to the generated entry. This fixes part of llvm.org/PR25439.

This reverts 252449 and reapplies r252445. Its test was failing
indeterministically due to r252375 which was reverted in r252522.

llvm-svn: 252540
2015-11-09 23:33:40 +00:00
Michael Kruse d6fb6f1b0c Fix dominance when subregion exit is outside scop
The dominance of the generated non-affine subregion block was based on
the scop's merge block, therefore resulted in an invalid DominanceTree.
It resulted in some values as assumed to be unusable in the actual
generated exit block.

We detect the case that the exit block has been moved and decide
dominance using the BB at the original exit. If we create another exit
node, that exit nodes is dominated by the one generated from where the
original exit resides. This fixes llvm.org/PR25438 and part of
llvm.org/PR25439.

llvm-svn: 252526
2015-11-09 23:07:38 +00:00
Michael Kruse ebffcbeefa Revert r252375 "Fix non-affine region dominance of implicitely stored values"
It introduced indeterminism as it was iterating over an address-indexed
hashtable. The corresponding bug PR25438 will be fixed in a successive
commit.

llvm-svn: 252522
2015-11-09 22:37:29 +00:00
Johannes Doerfert 7a6e292d86 [FIX] Use same alloca for invariant loads and the scalar users
llvm-svn: 252451
2015-11-09 06:28:45 +00:00
Johannes Doerfert 544b23a1ef Revert "Fix non-affine generated entering node not being recognized as dominating"
This reverts commit 9775824b265e574fc541e975d64d3e270243b59d due to a
failing unit test.

Please check and correct the unit test and commit again.

llvm-svn: 252449
2015-11-09 06:04:05 +00:00