Commit Graph

1031 Commits

Author SHA1 Message Date
Tobias Grosser 6091417ebc Add NVIDIA vprintf printing to RuntimeDebugBuilder
llvm-svn: 239219
2015-06-06 08:43:22 +00:00
Tobias Grosser d8308fbed9 Avoid the use of std::map emplace
This functionality does not yet seem to exist on all buildbots.

llvm-svn: 239133
2015-06-05 05:52:15 +00:00
Tobias Grosser 785ee20cac Free two strings produced by isl
With this commit 'make check-polly' is now address sanitizer clean.

llvm-svn: 239131
2015-06-05 05:31:46 +00:00
Tobias Grosser d5d93ecd03 Use owning pointers to avoid memory leaks
This fixes a memory leak caused by us not freeing the expanded region nodes.

llvm-svn: 239061
2015-06-04 17:59:54 +00:00
Tobias Grosser a5c092d844 Store ArrayShape in shared_ptr and MemAccs as actual objects
This fixes two more memory leaks.

llvm-svn: 239050
2015-06-04 16:03:16 +00:00
Tobias Grosser ff22e9e5f6 Store comparison objects as objects, not pointers
This fixes a memory leak. If we store the actual objects we can not forget to
free them.

llvm-svn: 239033
2015-06-04 11:44:09 +00:00
Tobias Grosser 22adfb4373 Mark sdivs as 'exact' instead of lowering them ourselves
LLVM's instcombine already translates power-of-two sdivs that are known to be
exact to fast ashr instructions. Hence, there is no need to add this logic
ourselves.

Pointed-out-by: Johannes Doerfert
llvm-svn: 239025
2015-06-04 07:45:09 +00:00
Tobias Grosser 5cf7860704 Ensure memory access mappings are defined for full domain
We now verify that memory access functions imported via JSON are indeed defined
for the full iteration domain. Before this change we accidentally imported
memory mappings such as i -> i / 127, which only defined a mapped for values of
i that are evenly divisible by 127, but which did not define any mapping for the
remaining values, with the result that isl just generated an access expression
that had undefined behavior for all the unmapped values.

In the incorrect test cases, we now either use floor(i/127) or we use p/127 and
provide the information that p is indeed a multiple of 127.

llvm-svn: 239024
2015-06-04 07:44:35 +00:00
Chandler Carruth bdb4a39ad8 Update Polly for the AA/MemoryLocation refactoring.
llvm-svn: 239008
2015-06-04 03:49:46 +00:00
Tobias Grosser 244c8297cf Lower signed-divisions without rounding to ashr instructions
llvm-svn: 238929
2015-06-03 15:14:58 +00:00
Tobias Grosser 224b162280 Only convert power-of-two floor-division with non-negative denominator
floord(a,b) === a ashr log_2 (b) holds for positive and negative a's, but
shifting only makes sense for positive values of b. The previous patch did
not consider this as isl currently always produces postive b's. To avoid future
surprises, we check that b is positive and only then apply the optimization.

We also now correctly check the return value of the dyn-cast.

No additional test case, as isl currently does not produce negative
denominators.

Reported-by: David Majnemer <david.majnemer@gmail.com>
llvm-svn: 238927
2015-06-03 14:43:01 +00:00
Tobias Grosser cb73f150d4 Translate power-of-two floor-division into ashr
Power-of-two floor divisions can be translated into an arithmetic shift
operation. This allows us to replace a complex lowering that requires division
operations:

  %pexp.fdiv_q.0 = sub i64 %21, 128
  %pexp.fdiv_q.1 = add i64 %pexp.fdiv_q.0, 1
  %pexp.fdiv_q.2 = icmp slt i64 %21, 0
  %pexp.fdiv_q.3 = select i1 %pexp.fdiv_q.2, i64 %pexp.fdiv_q.1, i64 %21
  %pexp.fdiv_q.4 = sdiv i64 %pexp.fdiv_q.3, 128

with a simple ashr:

  %polly.fdiv_q.shr = ashr i64 %21, 7

llvm-svn: 238905
2015-06-03 06:31:30 +00:00
Tobias Grosser 97d8745087 Dump YAML schedule tree as properly indented tree in DEBUG output
llvm-svn: 238645
2015-05-30 06:46:59 +00:00
Tobias Grosser d6a50b3a1e Add DEBUG output to -polly-scops pass
llvm-svn: 238644
2015-05-30 06:26:21 +00:00
Tobias Grosser 3e77d14563 Add indvar pass to canonicalization sequence
Running indvar before Polly is useful as this eliminates zexts as they commonly
appear when a 32 bit induction variable (type int) was used on a 64 bit system.
These zexts confuse our delinearization and prevent for example the successful
delinearization of the nussinov kernel in polybench-c-4.1.

This fixes http://llvm.org/PR23426

Suggested-by: Xing Su <xsu.llvm@outlook.com>
llvm-svn: 238643
2015-05-30 06:16:41 +00:00
Tobias Grosser cdb38e5625 Exploit non-negative numerators
isl marks known non-negative numerators in modulo (and soon also division)
operations. We now exploit this by generating unsigned operations. This is
beneficial as unsigned operations with power-of-two denominators will be
translated by isl to fast bitshift or bitwise and operations.

llvm-svn: 238577
2015-05-29 17:08:19 +00:00
Tobias Grosser b2f399264d Update isl to 93b8e43d
This update brings mostly interface cleanups, but also fixes two bugs in
imath (a memory leak, some undefined behavior).

llvm-svn: 238422
2015-05-28 13:32:11 +00:00
Tobias Grosser 57411e3fc6 Drop const in front of iterator
David Blaikie:

"find returns an iterator by value, so it's just added complexity/strangeness to
then use reference lifetime extension to give it the same semantics as if you'd
used a value type instead of a reference type."

llvm-svn: 238294
2015-05-27 06:51:34 +00:00
Tobias Grosser 7c3bad52dd Use value semantics for list of ScopStmt(s) instead of std::owningptr
David Blaike suggested this as an alternative to the use of owningptr(s) for our
memory management, as value semantics allow to avoid the additional interface
complexity caused by owningptr while still providing similar memory consistency
guarantees. We could also have used a std::vector, but the use of std::vector
would yield possibly changing pointers which currently causes problems as for
example the memory accesses carry pointers to their parent statements. Such
pointers should not change.

Reviewer: jblaikie, jdoerfert

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

llvm-svn: 238290
2015-05-27 05:16:57 +00:00
Tobias Grosser eeb9f3ce15 Drop unnecessary 'this->' pointers
llvm-svn: 238257
2015-05-26 21:37:31 +00:00
Tobias Grosser 2d7611f45e Remove unnecessary indirection through SCEV
llvm-svn: 238092
2015-05-23 05:58:30 +00:00
Tobias Grosser ab6714464a Use unique_ptr to clarify ownershop of ScopArrayInfoMap
llvm-svn: 238091
2015-05-23 05:58:27 +00:00
Tobias Grosser 679dfafd33 Use unique_ptr to clarify ownership of ScopStmt
llvm-svn: 238090
2015-05-23 05:14:09 +00:00
Tobias Grosser ac60f4594f Enable scalar and PHI code generation for Polly
The feature itself has been committed by Johannes in r238070. As this is the
way forward, we now enable it to ensure we get test coverage.

Thank you Johannes for this nice work!

llvm-svn: 238088
2015-05-23 03:34:41 +00:00
Johannes Doerfert ecff11dcfb Add scalar and phi code generation
To reduce compile time and to allow more and better quality SCoPs in
  the long run we introduced scalar dependences and PHI-modeling. This
  patch will now allow us to generate code if one or both of those
  options are set. While the principle of demoting scalars as well as
  PHIs to memory in order to communicate their value stays the same,
  this allows to delay the demotion till the very end (the actual code
  generation). Consequently:
    - We __almost__ do not modify the code if we do not generate code
      for an optimized SCoP in the end. Thus, the early exit as well as
      the unprofitable option will now actually preven us from
      introducing regressions in case we will probably not get better
      code.
    - Polly can be used as a "pure" analyzer tool as long as the code
      generator is set to none.
    - The original SCoP is almost not touched when the optimized version
      is placed next to it. Runtime regressions if the runtime checks
      chooses the original are not to be expected and later
      optimizations do not need to revert the demotion for that part.
    - We will generate direct accesses to the demoted values, thus there
      are no "trivial GEPs" that select the first element of a scalar we
      demoted and treated as an array.

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

llvm-svn: 238070
2015-05-22 23:43:58 +00:00
Tobias Grosser 1b6ea573f2 Replace low-level constraint building with higher level functions
Instead of explicitly building constraints and adding them to our maps we
now use functions like map_order_le to add the relevant information to the
maps.

llvm-svn: 237934
2015-05-21 19:02:44 +00:00
Tobias Grosser a8512b1784 Add diagnostic for unsigned integer comparisions
llvm-svn: 237800
2015-05-20 15:37:11 +00:00
Tobias Grosser 9a6bef8ba4 Drop redundant condition
This condition was accidentally introduced in r211875.

llvm-svn: 237796
2015-05-20 15:04:27 +00:00
Tobias Grosser 5db5d2da13 Use base-pointer address space when creating new access functions
llvm-svn: 237785
2015-05-20 11:02:12 +00:00
Tobias Grosser 49ad36ca16 Add printing and testing to ScopArrayInfo
Being here, we extend the interface to return the element type and not a pointer
to the element type. We also provide a function to get the size (in bytes) of
the elements stored in this array.

We currently still store the element size as an innermost dimension in
ScopArrayInfo, which is somehow inconsistent and should be addressed in future
patches.

llvm-svn: 237779
2015-05-20 08:05:31 +00:00
Tobias Grosser 1128b36512 Adapt to IRBuilder::CreateCall interface change
The IRBuilder::CreateCall interface was changed in r237624 and now requires an
initializer list.

llvm-svn: 237666
2015-05-19 06:25:02 +00:00
Tobias Grosser 1638f987f1 Update isl to 6be6768e
Besides a couple of interface cleanups, this change also contains a performance
optimization of isl_mat_product that should give us up to almost 6% compiletime
reduction.

llvm-svn: 237616
2015-05-18 21:29:58 +00:00
Tobias Grosser b80def51e1 Drop unused PTX generator file
This code has been part of Polly's GPGPU backend, which has been remove together
with the code generation backend. Development now continues in an out-of-tree
branch.

llvm-svn: 237450
2015-05-15 15:41:14 +00:00
Tobias Grosser 4ac75ba449 Remove need for separate loop index counter
Suggested-by: Johannes Doerfert
llvm-svn: 237441
2015-05-15 12:24:12 +00:00
Tobias Grosser e29d31ce5a Simplify string formatting
Suggested-by: Johannes Doerfert
llvm-svn: 237440
2015-05-15 12:24:09 +00:00
Tobias Grosser 6f48e0fd2b Give each memory access a reference ID
This reference ID is handy for use cases where we need to identify individual
memory accesses (e.g. to modify their access functions).

This is a reworked version of a patch originally developed by Yabin Hu as part
of his summer of code project.

llvm-svn: 237431
2015-05-15 09:58:32 +00:00
Tobias Grosser e0f8d597f4 Update isl to 9f767f1766a0
This fixes a bug in the isl scheduler (http://llvm.org/PR21934)

Otherwise mostly minor changes.

llvm-svn: 237250
2015-05-13 13:10:13 +00:00
Tobias Grosser 09d3069740 Rename IslCodeGeneration to CodeGeneration
Besides class, function and file names, we also change the command line option
from -polly-codegen-isl to just -polly-codegen. The isl postfix is a leftover
from the times when we still had the CLooG based -polly-codegen. Today it is
just redundant and we drop it.

llvm-svn: 237099
2015-05-12 07:45:52 +00:00
Tobias Grosser d4ea2f48c4 Revert "Adjust formatting to latest clang-format change"
This reverts commit 236875. Daniel fixed the clang-format bug that introduced
the changed formatting.

llvm-svn: 236994
2015-05-11 13:43:04 +00:00
Tobias Grosser 3e6070ef03 Update isl to c3892bebc0
Various smaller improvements and bugfixes.

llvm-svn: 236932
2015-05-09 09:37:30 +00:00
Tobias Grosser cd524dc51d Add explicit #includes for used isl features
llvm-svn: 236931
2015-05-09 09:36:38 +00:00
Tobias Grosser ba0d09227c Sort include directives
Upcoming revisions of isl require us to include header files explicitly, which
have previously been already transitively included. Before we add them, we sort
the existing includes.

Thanks to Chandler for sort_includes.py. A simple, but very convenient script.

llvm-svn: 236930
2015-05-09 09:13:42 +00:00
Tobias Grosser f7b5480474 Adjust formatting to latest clang-format change
llvm-svn: 236875
2015-05-08 16:10:53 +00:00
Tobias Grosser e71ed19841 Add iterators for the ArrayInfo objects of the scop
This patch also changes the implementation of the ArrayInfoMap to a MapVector
which will ensure that iterating over the list of ArrayInfo objects gives
predictable results. The single loop that currently enumerates the ArrayInfo
objects only frees the individual objectes, hence a possibly changing
iteration order does not affect the outcome. The added robustness is for
future users of this interface.

llvm-svn: 236583
2015-05-06 10:05:20 +00:00
Johannes Doerfert 8983031b5e [FIX] Invalid recognition of multidimensional access
In the lnt benchmark MultiSource/Benchmarks/MallocBench/gs/gs with
  scalar and PHI modeling we detected the multidimensional accesses
  with sizes variant in the SCoP. This will check the sizes for validity.

llvm-svn: 236395
2015-05-03 16:03:01 +00:00
Tobias Grosser a63b7cee66 Adding debug location information to Polly's JSCOP and dot exports
This change adds location information for the detected regions in Polly when the
required debug information is available.

The JSCOP output format is extended with a "location" field which contains the
information in the format "source.c:start-end"

The dot output is extended to contain the location information for each nested
region in the analyzed function.

As part of this change, the existing getDebugLocation function has been moved
into lib/Support/ScopLocation.cpp to avoid having to include
polly/ScopDetectionDiagnostics.h.

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

Contributed-by: Roal Jordans <r.jordans@tue.nl>
llvm-svn: 236393
2015-05-03 05:21:36 +00:00
Duncan P. N. Exon Smith ddf3a0ef38 Update polly for LLVM rename of debug info metadata with DI* prefix
Ran the same rename-md-di-prefix.sh script attached to PR23080 as in
LLVM r236120 and CFE r236121.

llvm-svn: 236127
2015-04-29 17:02:14 +00:00
Tobias Grosser 0c55cb6071 Extract IslNodeBuilder into its own file
The IslNodeBuilder is a generic class that may be useful in other contexts
as well. Hence, we extract it into its own .h/.cpp file.

llvm-svn: 235873
2015-04-27 12:32:24 +00:00
Tobias Grosser f3ba5b5a40 Drop some unused headers
llvm-svn: 235871
2015-04-27 12:17:22 +00:00
Tobias Grosser 4245372bee Fix PTXGenerator after raw_pwrite_stream has been introduced
Without this patch Polly with GPGPU support enabled did not compile any more.

llvm-svn: 235868
2015-04-27 12:06:32 +00:00