Commit Graph

3241 Commits

Author SHA1 Message Date
Tobias Grosser c4bfef50f3 Update isl to isl-0.18-679-g6e75a0d
This is a regular maintenance update

llvm-svn: 304686
2017-06-04 19:13:10 +00:00
Tobias Grosser 22be8a18f3 Add test coverage for regions with non-affine loops
This adds test coverage for regions with non-affine loops, which we
unfortunately missed when committing this features years ago. We will add
more test coverage over time.

llvm-svn: 304672
2017-06-03 23:39:02 +00:00
Siddharth Bhat 726c28f8c4 [CodeGen] Track trip counts per-scop for performance measurement.
- Add a counter that is incremented once on exit from a scop.

- Test cases got split into two: one to test the cycles, and another one
to test trip counts.

- Sample output:
```name=sample-output.txt
scop function, entry block name, exit block name, total time, trip count
warmup, %entry.split, %polly.merge_new_and_old, 5180, 1
f, %entry.split, %polly.merge_new_and_old, 409944, 500
g, %entry.split, %polly.merge_new_and_old, 1226, 1
```

Differential Revision: https://reviews.llvm.org/D33822

llvm-svn: 304543
2017-06-02 11:36:52 +00:00
Siddharth Bhat a4dea6bb05 [CodeGen] Print performance counter information in CSV.
This ensures that tools can parse performance information which Polly
generates easily.

- Sample output:
```name=out.csv
scop function, entry block name, exit block name, total time
warmup, %entry.split, %polly.merge_new_and_old, 1960
f, %entry.split, %polly.merge_new_and_old, 1238
g, %entry.split, %polly.merge_new_and_old, 1218
```

- Example code to parse output:
```lang=python, name=example-parse.py
import asciitable
import sys

table = asciitable.read('out.csv', delimiter=',')
asciitable.write(table, sys.stdout, delimiter=',')
```

llvm-svn: 304533
2017-06-02 09:20:02 +00:00
Siddharth Bhat fee75f4ba5 [NFC] [CodeGen] Bail out of per-scop performance reporting if not supported.
We should bail out if performance monitoring is not supported, since
we would have no information to print per-scop, and `FinalStartBB`,
`ReturnFromFinal` would be `nullptr`.

Assert that these are not `nullptr` if performance monitoring is supported.

llvm-svn: 304529
2017-06-02 08:44:19 +00:00
Siddharth Bhat 07bee290de [CodeGen] Extend Performance Counter to track per-scop information.
Previously, we would generate one performance counter for all scops.
Now, we generate both the old information, as well as a per-scop
performance counter to generate finer grained information.

This patch needed a way to generate a unique name for a `Scop`.
The start region, end region, and function name combined provides a
unique `Scop` name. So, `Scop` has a new public API to provide its start
and end region names.

Differential Revision: https://reviews.llvm.org/D33723

llvm-svn: 304528
2017-06-02 08:01:22 +00:00
Michael Kruse 3bb4829936 [CodeGen] Iterate over explicit instruction list for block statements. NFC
For when statements do not contain all instructions of a BasicBlock
anymore, the block generator needs to go through the explicit list of
instructions it contains.

Contributed-by: Nandini Singhal <cs15mtech01004@iith.ac.in>

Differential Revision: https://reviews.llvm.org/D33653

llvm-svn: 304502
2017-06-02 00:13:49 +00:00
Michael Kruse 678aa336fa [ScopBuilder] Exclude ignored intrinsics from explicit instruction list.
Ignored intrinsics are ignored at code generation, therefore do not
need to be part of the instruction list.

Specifically, llvm.lifetime.* intrinisics are removed before code
generation, referencing them would cause a use-after-free error.

Contributed-by: Nandini Singhal <cs15mtech01004@iith.ac.in>

Differential Revision: https://reviews.llvm.org/D33768

llvm-svn: 304483
2017-06-01 21:46:27 +00:00
Eli Friedman de1b318dad Add opt-bisect support to polly.
This is useful for debugging miscompiles and extracting testcases
for crashes. See http://llvm.org/docs/OptBisect.html .

Differential Revision: https://reviews.llvm.org/D33752

llvm-svn: 304480
2017-06-01 21:29:05 +00:00
Tobias Grosser dff902fca7 [ScopInfo] Do not lookup key twice [NFC]
Suggested-by: Michael Kruse <llvm@meinersbur.de>
llvm-svn: 304410
2017-06-01 12:46:51 +00:00
Tobias Grosser f51decb5fe [BlockGenerator] Take context into account when identifying partial writes
A partial write is a write where the domain of the values written is a subset of
the execution domain of the parent statement containing the write. Originally,
we directly checked this subset relation whereas it is indeed only important
that the subset relation holds for the parameter values that are known to be
valid in the execution context of the scop. We update our check to avoid the
unnecessary introduction of partial writes in situations where the write appears
to be partial without context information, but where context information allows
us to understand that a full write can be generated.

This change fixes (hides) a recent regression introduced in r303517, which broke
our AOSP builds. The part that is correctly fixed in this change is that we do
not any more unnecessarily generate a partial write. This is good performance
wise and, as we currently do not yet explicitly introduce partial writes in the
default configuration, this also hides possible bugs in the partial writes
implementation. The crashes that we have originally seen were caused by such
a bug, where partial writes were incorrectly generated in region statements. An
additional patch in a subsequent commit is needed to address this problem.

Reported-by: Reported-by: Eli Friedman <efriedma@codeaurora.org>

Differential Revision: https://reviews.llvm.org/D33759

llvm-svn: 304398
2017-06-01 09:34:20 +00:00
Tobias Grosser 6b6ac90098 [BlockGenerator] Translate buildContainsCondition to idiomatic isl C++
llvm-svn: 304354
2017-05-31 21:49:51 +00:00
Tobias Grosser 5ecc5166d9 [isl++] Update bindings
This change removes the requirement for explicit conversions from isl::boolean
to isl::bool, which resolves a compilation error on OSX.

Suggested-by: Siddharth Bhat <siddu.druid@gmail.com>
llvm-svn: 304288
2017-05-31 08:46:29 +00:00
Siddharth Bhat 0610b00295 [NFC] [PerfMonitor] Fix typo.
"InserBefore" -> "InsertBefore"

llvm-svn: 304287
2017-05-31 08:12:04 +00:00
Tobias Grosser 5863087ad3 [test] Add a short explanation to test
llvm-svn: 304279
2017-05-31 05:03:11 +00:00
Michael Kruse ed0c2f7e90 [ScopInfo] Do not add terminator & synthesizable instructions to the output instructions.
Such instructions are generates on-demand by the CodeGenerator and thus
do not need representation in a statement.

Differential Revision: https://reviews.llvm.org/D33642

llvm-svn: 304151
2017-05-29 12:27:38 +00:00
Siddharth Bhat 8bb436eb26 Revert "[NFC] Fix formatting & typecast issue. Build succeeds."
Should not have 'fixed' the formatting issue, I did not have the most
recent version of `clang-format`.
This reverts commit 761b1268359e14e59142f253d77864a29d55c56c.

llvm-svn: 304148
2017-05-29 11:34:29 +00:00
Siddharth Bhat ede801ca2b [NFC] Fix formatting & typecast issue. Build succeeds.
- Fix formatting in `RegisterPasses.cpp`.
- `assert` tried to compare `isl::boolean` against `long`. Explicitly
construct `bool` from `isl::boolean`. This allows the implicit cast of
`bool` to `long.

llvm-svn: 304146
2017-05-29 11:00:31 +00:00
Tobias Grosser d9fb2842e7 Adapt to recent clang-format changes
llvm-svn: 304136
2017-05-29 08:06:29 +00:00
Tobias Grosser 1e55db30d5 Delinearize memory accesses that reference parameters coming from function calls
Certain affine memory accesses which we model today might contain products of
parameters which we might combined into a new parameter to be able to create an
affine expression that represents these memory accesses. Especially in the
context of OpenCL, this approach looses information as memory accesses such as
A[get_global_id(0) * N + get_global_id(1)] are assumed to be linear. We
correctly recover their multi-dimensional structure by assuming that parameters
that are the result of a function call at IR level likely are not parameters,
but indeed induction variables. The resulting access is now
A[get_global_id(0)][get_global_id(1)] for an array A[][N].

llvm-svn: 304075
2017-05-27 15:18:53 +00:00
Tobias Grosser f5e7e60bc8 Allow side-effect free function calls in valid affine SCEVs
Side-effect free function calls with only constant parameters can be easily
re-generated and consequently do not prevent us from modeling a SCEV. This
change allows array subscripts to reference function calls such as
'get_global_id()' as used in OpenCL.

We use the function name plus the constant operands to name the parameter. This
is possible as the function name is required and is not dropped in release
builds the same way names of llvm::Values are dropped. We also provide more
readable names for common OpenCL functions, to make it easy to understand the
polyhedral model we generate.

llvm-svn: 304074
2017-05-27 15:18:46 +00:00
Tobias Grosser 7aa22859b6 Update some tests to changes in isl's internal representation
This was forgotten as part of r304069.

llvm-svn: 304070
2017-05-27 11:33:05 +00:00
Tobias Grosser 6ea64d8bd3 Update isl to isl-0.18-662-g17e172e
This is a general maintenance update

llvm-svn: 304069
2017-05-27 11:09:39 +00:00
Tobias Grosser 58822e8441 Update information on isl C++ bindings in Polly release notes
llvm-svn: 304068
2017-05-27 11:01:01 +00:00
Tobias Grosser d5fcbef8ee [Polly] Added the list of Instructions to output in ScopInfo pass
Summary: This patch outputs all the list of instructions in BlockStmts.

Reviewers: Meinersbur, grosser, bollu

Subscribers: bollu, llvm-commits, pollydev

Differential Revision: https://reviews.llvm.org/D33163

llvm-svn: 304062
2017-05-27 04:40:18 +00:00
Tobias Grosser 9932086895 [ScopInfo] Translate mapToDimension to isl C++ [NFC]
llvm-svn: 304007
2017-05-26 17:22:03 +00:00
Siddharth Bhat c56a355a35 [Docs] Fix exception name being caught in case ReadTheDocs does not exist.
The exception is `ImportError`, not `ModuleNotFoundError`.

llvm-svn: 303982
2017-05-26 12:56:35 +00:00
Tobias Grosser 6e770813c9 Drop newline in docs builder to see if Polly docs are updated
llvm-svn: 303839
2017-05-25 05:38:05 +00:00
Tobias Grosser c8d13f50cc [ScopInfo] Tighten compute out introduced in r303404
It seems we are still spending too much time on rare inputs, which continue to
timeout the AOSP buildbot. Let's see if a further reduction is sufficient.

llvm-svn: 303807
2017-05-24 21:24:04 +00:00
Philip Pfaffe 1a0128faaa [Polly] Add handling of Top Level Regions
Summary:
My goal is to make the newly added `AllowWholeFunctions` options more usable/powerful.

The changes to ScopBuilder.cpp are exclusively checks to prevent `Region.getExit()` from being dereferenced, since Top Level Regions (TLRs) don't have an exit block.

In ScopDetection's `isValidCFG`, I removed a check that disallowed ReturnInstructions to have return values. This might of course have been intentional, so I would welcome your feedback on this and maybe a small explanation why return values are forbidden. Maybe it can be done but needs more changes elsewhere?

The remaining changes in ScopDetection are simply to consider the AllowWholeFunctions option in more places, i.e. allow TLRs when it is set and once again avoid derefererncing `getExit()` if it doesn't exist.

Finally, in ScopHelper.cpp I extended `polly::isErrorBlock` to handle regions without exit blocks as well: The original check was if a given BasicBlock dominates all predecessors of the exit block. Therefore I do the same for TLRs by regarding all BasicBlocks terminating with a ReturnInst as predecessors of a "virtual" function exit block.

Patch by: Lukas Boehm

Reviewers: philip.pfaffe, grosser, Meinersbur

Reviewed By: grosser

Subscribers: pollydev, llvm-commits, bollu

Tags: #polly

Differential Revision: https://reviews.llvm.org/D33411

llvm-svn: 303790
2017-05-24 18:39:39 +00:00
Michael Kruse 5f16986271 [DeLICM] Partial writes for PHIs.
Enable the use for partial writes for PHI write accesses with a switch.
This simply skips the test for whether a PHI write would be partial.

The analog test for partial value writes also protects for partial reads
which we do not support (yet). It is possible to test for partial reads
separately such that we could skip the partial write check as well. In
case this shows up to be useful, I can implement it as well.

Differential Revision: https://reviews.llvm.org/D33487

llvm-svn: 303762
2017-05-24 15:23:06 +00:00
Michael Kruse cb58bd6ccd [JSONImporter] misses checks whether the data it imports makes sense.
Without this patch, the JSONImporter did not verify if the data it loads
were correct or not  (Bug llvm.org/PR32543). I add some checks in the
JSONImporter class and some test cases.

Here are the checks (and test cases) I added :

JSONImporter::importContext
- The "context" key does not exist.
- The context was not parsed successfully by ISL.
- The isl_set has the wrong number of parameters.
- The isl_set is not a parameter set.

JSONImporter::importSchedule
- The "statements" key does not exist.
- There is not the right number of statement in the file.
- The "schedule" key does not exist.
- The schedule was not parsed successfully by ISL.

JSONImporter::importAccesses
- The "statements" key does not exist.
- There is not the right number of statement in the file.
- The "accesses" key does not exist.
- There is not the right number of memory accesses in the file.
- The "relation" key does not exist.
- The memory access was not parsed successfully by ISL.

JSONImporter::areArraysEqual
- The "type" key does not exist.
- The "sizes" key does not exist.
- The "name" key does not exist.

JSONImporter::importArrays
/!\ Do not check if there is an key name "arrays" because it is not
considered as an error.
All checks are already in place or implemented in
JSONImporter::areArraysEqual.

Contributed-by: Nicolas Bonfante <nicolas.bonfante@insa-lyon.fr>

Differential Revision: https://reviews.llvm.org/D32739

llvm-svn: 303759
2017-05-24 15:09:35 +00:00
Tobias Grosser 8913015a79 Add a permanent Polly Hangouts URL
llvm-svn: 303725
2017-05-24 06:46:11 +00:00
Tobias Grosser 0bb785fc62 Add new C++ bindings to release notes
llvm-svn: 303724
2017-05-24 06:46:09 +00:00
Tobias Grosser 7eacc04836 Update version number in Polly release notes
llvm-svn: 303723
2017-05-24 06:46:06 +00:00
Tobias Grosser ecc0141349 Header file to help forcibly link GPURuntime
Summary: LinkGPURuntime.h defines and creates a structure ForceGPURuntimeLinking which creates an artificial dependency to functions defined in GPUJIT.c. The presence of this structure ensures that these functions are a part of the compiled object/library files including it.

Reviewers: grosser, Meinersbur

Reviewed By: grosser

Subscribers: #polly, pollydev

Tags: #polly

Differential Revision: https://reviews.llvm.org/D33198

llvm-svn: 303722
2017-05-24 06:46:03 +00:00
Siddharth Bhat 7bccbe780e [NFC] [PolyhedralInfo] fix typo
"an" -> "and"

llvm-svn: 303631
2017-05-23 11:41:52 +00:00
Philip Pfaffe 483340bb83 [Polly][NewPM] Reenable ScopPassManager unittest
llvm-svn: 303629
2017-05-23 11:28:50 +00:00
Philip Pfaffe 24a1bb2cf9 Post-commit fix of a comment
llvm-svn: 303628
2017-05-23 11:25:05 +00:00
Philip Pfaffe 78ae52f0d6 [Polly][NewPM] Port CodeGen to the new PM
Summary: To move CG to the new PM I outlined the various helper that were previously members of the CG class into free static functions. The CG class itself I moved into a header, which is required because we need to include it in `RegisterPasses` eventually.

Reviewers: grosser, Meinersbur

Reviewed By: grosser

Subscribers: pollydev, llvm-commits, sanjoy

Tags: #polly

Differential Revision: https://reviews.llvm.org/D33423

llvm-svn: 303624
2017-05-23 10:18:12 +00:00
Philip Pfaffe 2b852e2e42 [Polly][NewPM] Port IslAst to the new ScopPassManager
Summary: This patch ports IslAst to the new PM. The change is mostly straightforward. The only major modification required is making IslAst move-only, to correctly manage the isl resources it owns.

Reviewers: grosser, Meinersbur

Reviewed By: grosser

Subscribers: nemanjai, pollydev, llvm-commits

Tags: #polly

Differential Revision: https://reviews.llvm.org/D33422

llvm-svn: 303622
2017-05-23 10:12:56 +00:00
Philip Pfaffe 3ef36fa222 [Polly][NewPM] Port DependenceInfo to the new ScopPassManager.
Summary: This patch ports DependenceInfo to the new ScopPassManager. Printing is implemented as a seperate printer pass.

Reviewers: grosser, Meinersbur

Reviewed By: grosser

Subscribers: llvm-commits, pollydev

Tags: #polly

Differential Revision: https://reviews.llvm.org/D33421

llvm-svn: 303621
2017-05-23 10:09:06 +00:00
Tobias Grosser a32de1341e [ScopInfo] Translate foldAccessRelation to isl C++ [NFC]
llvm-svn: 303615
2017-05-23 07:22:56 +00:00
Tobias Grosser 53fc355e7d [ScopInfo] Translate buildMemIntrinsicAccessRelation to isl C++ [NFC]
llvm-svn: 303612
2017-05-23 07:07:09 +00:00
Tobias Grosser 1e2edaf3ea [ScopInfo] Translate assumeNoOutOfBound to isl C++ [NFC]
llvm-svn: 303611
2017-05-23 07:07:07 +00:00
Tobias Grosser b1ed3d9749 [ScopInfo] Translate applyAndSetFAD to isl C++
llvm-svn: 303610
2017-05-23 07:07:05 +00:00
Tobias Grosser 2ade986c9e [ScopInfo] Translate isReadOnly to isl C++
llvm-svn: 303608
2017-05-23 06:41:04 +00:00
Tobias Grosser 6d459c5d3d [ScopInfo] Simplify domains early
This speeds up scop modeling for scops with many redundent existentially
quantified constraints. For the attached test case, this change reduces
scop modeling time from minutes (hours?) to 0.15 seconds.

This change resolves a compilation timeout on the AOSP build.

Thanks Eli for reporting _and_ reducing the test case!

Reported-by: Eli Friedman <efriedma@codeaurora.org>
llvm-svn: 303600
2017-05-23 04:26:28 +00:00
Michael Kruse 1aad76c18f [CodeGen] Add invalidation of the loop SCEVs after merge block generation.
The SCEVs of loops surrounding the escape users of a merge blocks are
forgotten, so that loop trip counts based on old values can be revoked.

This fixes llvm.org//PR32536

Contributed-by: Baranidharan Mohan <mbdharan@gmail.com>

Differential Revision: https://reviews.llvm.org/D33195

llvm-svn: 303561
2017-05-22 15:36:53 +00:00
Siddharth Bhat 68ae83e68c [Docs] Use ReadTheDocs theme if available.
Use ReadTheDocs theme for Sphinx if available since it is well
maintained and used by readthedocs.org.

Differential Revision: https://reviews.llvm.org/D33387

llvm-svn: 303550
2017-05-22 13:36:15 +00:00
Siddharth Bhat b2f754e39f [Docs] Fix Sphinx documentation in CMake check.
Summary:
- `include(AddSphinxTarget)` needs to occur before checking `SPHINX_FOUND`.
- `docs-polly-html` and `docs-polly-man` are now usable again.
- Perhaps we should build docs in the CI as well?

Differential Revision: https://reviews.llvm.org/D33386

llvm-svn: 303549
2017-05-22 13:16:02 +00:00
Michael Kruse 706f79ab14 [CodeGen] Support partial write accesses.
Allow the BlockGenerator to generate memory writes that are not defined
over the complete statement domain, but only over a subset of it. It
generates a condition that evaluates to 1 if executing the subdomain,
and only then execute the access.

Only write accesses are supported. Read accesses would require a PHINode
which has a value if the access is not executed.

Partial write makes DeLICM able to apply mappings that are not defined
over the entire domain (for instance, a branch that leaves a loop with
a PHINode in its header; a MemoryKind::PHI write when leaving is never
read by its PHI read).

Differential Revision: https://reviews.llvm.org/D33255

llvm-svn: 303517
2017-05-21 22:46:57 +00:00
Tobias Grosser 7be8245a40 [ScopInfo] Translate updateDimensionality to isl C++ [NFC]
llvm-svn: 303514
2017-05-21 20:38:33 +00:00
Tobias Grosser a3f7546931 [isl++] add isl_constraint to C++ bindings [NFC]
llvm-svn: 303512
2017-05-21 20:23:26 +00:00
Tobias Grosser 3137f2cb65 [ScopInfo] Translate wrapConstantDimensions to isl C++ [NFC]
llvm-svn: 303511
2017-05-21 20:23:23 +00:00
Tobias Grosser 99ea1d0808 [ScopInfo] Translate addRangeBoundsToSet to isl C++ [NFC]
llvm-svn: 303510
2017-05-21 20:23:20 +00:00
Tobias Grosser 1f94dcee0b Fix include order to stop clang-format complains
llvm-svn: 303509
2017-05-21 16:34:09 +00:00
Tobias Grosser 7205f93a98 [ScheduleOptimizer] Move schedule construction to isl C++ [NFC]
llvm-svn: 303508
2017-05-21 16:21:33 +00:00
Tobias Grosser b5f61bdeeb [Simplify] Move to isl C++
llvm-svn: 303507
2017-05-21 16:12:21 +00:00
Tobias Grosser 6151654c00 [isl++] Export (almost) all functions from isl
This commit exports the majority of the isl functions to the isl C++ interface.

The official isl C++ bindings still require discussions to define the set of
functions that are officially supported. As a result, the officially exported
functionality will be rather limited until these discussions conclude and a
non-trivial set of isl functions is officially supported through the isl C++
bindings. Starting from this commit we ship with Polly an extended version of
the official isl C++ bindings to ensure sufficient functionality is available
such that LLVM developers can make efficient use of isl through C++. The
practical experience Polly gathers with its bindings will then be used to
gradually upstream patches to isl to extend the official bindings.

llvm-svn: 303506
2017-05-21 16:00:32 +00:00
Tobias Grosser 443f6814a1 [isl++] Rebase isl C++ bindings on top of 29aee98ce
This reduces the diff to the official isl C++ bindings and solves a correctness
issue with isl::booleans, where isl_bool_error results were accidentally
converted to isl::boolean::true.

llvm-svn: 303505
2017-05-21 15:59:15 +00:00
Tobias Grosser 3320485961 [isl++] Move isl raw_ostream printers into separate header
Instead of relying on these functions to be part of the isl C++ bindings, we
just define this functionality independently. This allows us to use isl C++
bindings that do not contain LLVM specific functionality.

llvm-svn: 303503
2017-05-21 13:16:05 +00:00
Tobias Grosser ee61ebb134 Fix buildbots after r303429
A test case with a GPU runline was added without setting 'REQUIRES=pollyacc'. We
drop the GPU run line, as the basic functionality can already be tested with
the normal code generation.

llvm-svn: 303485
2017-05-20 04:22:26 +00:00
Siddharth Bhat b7f68b8c9e [Fortran Support] Materialize outermost dimension for Fortran array.
- We use the outermost dimension of arrays since we need this
information to generate GPU transfers.

- In general, if we do not know the outermost dimension of the array
(because the indexing expression is non-affine, for example) then we
simply cannot generate transfer code.

- However, for Fortran arrays, we can use the Fortran array
representation which stores the dimensions of all arrays.

- This patch uses the Fortran array representation to generate code that
computes the outermost dimension size.

Differential Revision: https://reviews.llvm.org/D32967

llvm-svn: 303429
2017-05-19 15:07:45 +00:00
Tobias Grosser d8945baa0a [ScopDetection] Allow detection of full functions
This is useful when only analyzing functions.

llvm-svn: 303420
2017-05-19 12:13:02 +00:00
Tobias Grosser 977158488e [ScopInfo] Fix typo in documentation
llvm-svn: 303405
2017-05-19 04:01:52 +00:00
Tobias Grosser 45e9fd1810 [ScopInfo] Gracefully handle long compile times
The following test case tried to compute the lexicographic minimum of the
following set during alias analysis, which caused very long compile time:

[p_0, p_1, p_2, p_3, p_4, p_5] -> { MemRef0[i0] : (517p_3 >= 70944 - 298p_2 and
256i0 >= -71199 + 298p_2 + 517p_3 and 256i0 <= -70944 + 298p_2 + 517p_3) or
(409p_4 >= 57120 - 298p_2 and 256i0 >= -57375 + 298p_2 + 409p_4 and 256i0 <=
-57120 + 298p_2 + 409p_4) or (104p_4 >= 17329 + 149p_2 - 50p_3 and 128i0 >=
17328 + 149p_2 - 50p_3 - 104p_4 and 128i0 <= 17455 + 149p_2 - 50p_3 - 104p_4) or
(104p_4 <= 17328 + 149p_2 - 50p_3 and 128i0 >= 17201 + 149p_2 - 50p_3 - 104p_4
and 128i0 <= 17328 + 149p_2 - 50p_3 - 104p_4) or (409p_4 <= 57119 - 298p_2 and
256i0 >= -57120 + 298p_2 + 409p_4 and 256i0 <= -56865 + 298p_2 + 409p_4) or
(517p_3 <= 70943 - 298p_2 and 256i0 >= -70944 + 298p_2 + 517p_3 and 256i0 <=
-70689 + 298p_2 + 517p_3) or (p_1 >= 2 + 2p_0 and 298p_5 >= 70944 - 517p_3 and
256i0 >= -71199 + 517p_3 + 298p_5 and 256i0 <= -70944 + 517p_3 + 298p_5) or (p_1
>= 2 + 2p_0 and 298p_5 >= 57120 - 409p_4 and 256i0 >= -57375 + 409p_4 + 298p_5
>and 256i0 <= -57120 + 409p_4 + 298p_5) or (p_1 >= 2 + 2p_0 and 149p_5 <= -17329
>+ 50p_3 + 104p_4 and 128i0 >= 17328 - 50p_3 - 104p_4 + 149p_5 and 128i0 <=
>17455 - 50p_3 - 104p_4 + 149p_5) or (p_1 >= 2 + 2p_0 and 149p_5 >= -17328 +
>50p_3 + 104p_4 and 128i0 >= 17201 - 50p_3 - 104p_4 + 149p_5 and 128i0 <= 17328
>- 50p_3 - 104p_4 + 149p_5) or (p_1 >= 2 + 2p_0 and 298p_5 <= 57119 - 409p_4 and
>256i0 >= -57120 + 409p_4 + 298p_5 and 256i0 <= -56865 + 409p_4 + 298p_5) or
>(p_1 >= 2 + 2p_0 and 298p_5 <= 70943 - 517p_3 and 256i0 >= -70944 + 517p_3 +
>298p_5 and 256i0 <= -70689 + 517p_3 + 298p_5) }

We now guard the potentially expensive functions in Polly's scop analysis to
gracefully bail out in case of overly long compilation times.

llvm-svn: 303404
2017-05-19 03:45:00 +00:00
Michael Kruse 960c0d0b04 [ScopInfo] Fix r302231 to use logical or (||). NFC.
In r302231 we mistakenly use bitwise or (|) instead of logical
or (||). This patch fixes that.

Contributed-by: Sameer AbuAsal <sabuasal@codeaurora.org>

Differential Revision: https://reviews.llvm.org/D33337

llvm-svn: 303386
2017-05-18 21:55:36 +00:00
Reid Kleckner 96ab8726a3 [IR] De-virtualize ~Value to save a vptr
Summary:
Implements PR889

Removing the virtual table pointer from Value saves 1% of RSS when doing
LTO of llc on Linux. The impact on time was positive, but too noisy to
conclusively say that performance improved. Here is a link to the
spreadsheet with the original data:

https://docs.google.com/spreadsheets/d/1F4FHir0qYnV0MEp2sYYp_BuvnJgWlWPhWOwZ6LbW7W4/edit?usp=sharing

This change makes it invalid to directly delete a Value, User, or
Instruction pointer. Instead, such code can be rewritten to a null check
and a call Value::deleteValue(). Value objects tend to have their
lifetimes managed through iplist, so for the most part, this isn't a big
deal.  However, there are some places where LLVM deletes values, and
those places had to be migrated to deleteValue.  I have also created
llvm::unique_value, which has a custom deleter, so it can be used in
place of std::unique_ptr<Value>.

I had to add the "DerivedUser" Deleter escape hatch for MemorySSA, which
derives from User outside of lib/IR. Code in IR cannot include MemorySSA
headers or call the MemoryAccess object destructors without introducing
a circular dependency, so we need some level of indirection.
Unfortunately, no class derived from User may have any virtual methods,
because adding a virtual method would break User::getHungOffOperands(),
which assumes that it can find the use list immediately prior to the
User object. I've added a static_assert to the appropriate OperandTraits
templates to help people avoid this trap.

Reviewers: chandlerc, mehdi_amini, pete, dberlin, george.burgess.iv

Reviewed By: chandlerc

Subscribers: krytarowski, eraman, george.burgess.iv, mzolotukhin, Prazek, nlewycky, hans, inglorion, pcc, tejohnson, dberlin, llvm-commits

Differential Revision: https://reviews.llvm.org/D31261

llvm-svn: 303362
2017-05-18 17:24:10 +00:00
Siddharth Bhat 06e3c74d83 [Fortran Support] Change "global" pattern match to work for params
Summary:
- Rename global / local naming convention that did not make much sense
to Visible / Invisible, where the visible refers to whether the ALLOCATE
call to the Fortran array is present in the current module or not.

- This match now works on both cross fortran module globals and on
parameters to functions since neither of them are necessarily allocated
at the point of their usage.

- Add testcase that matches against both a load and a store against
function parameters.

Differential Revision: https://reviews.llvm.org/D33190

llvm-svn: 303356
2017-05-18 16:47:13 +00:00
Michael Kruse 1198b1f8d6 [ScopInfo] Remove unused MemoryAccess::BaseName. NFC.
llvm-svn: 303189
2017-05-16 16:52:24 +00:00
Tobias Grosser e890d5ba1b Drop nonexisting ScopPassManager directory
llvm-svn: 303066
2017-05-15 14:12:30 +00:00
Tobias Grosser ff3f38b2c5 Adjust formatting
llvm-svn: 303065
2017-05-15 14:12:27 +00:00
Philip Pfaffe 762ec5a3eb [Polly][NewPM] Add missing Unittests
llvm-svn: 303064
2017-05-15 13:52:10 +00:00
Philip Pfaffe 35bdcaf9e9 [Polly][NewPM][WIP] Add a ScopPassManager
This patch adds both a ScopAnalysisManager and a ScopPassManager.

The ScopAnalysisManager is itself a Function-Analysis, and manages
analyses on Scops. The ScopPassManager takes care of building Scop pass
pipelines.

This patch is marked WIP because I've left two FIXMEs which I need to
think about some more. Both of these deal with invalidation:

Deferred invalidation is currently not implemented. Deferred
invalidation deals with analyses which cache references to other
analysis results. If these results are invalidated, invalidation needs
to be propagated into the caching analyses.
The ScopPassManager as implemented assumes that ScopPasses do not affect
other Scops in any way. There has been some discussion about this on
other patch threads, however it makes sense to reiterate this for this
specific patch.
I'm uploading this patch even though it's incomplete to encourage
discussion and give you an impression of how this is going to work.

Differential Revision: https://reviews.llvm.org/D33192

llvm-svn: 303062
2017-05-15 13:43:01 +00:00
Philip Pfaffe bbb86719c1 [Polly][CMake] Exclude isl_config from the polly-check-format target.
Summary:
The custom `polly-check-format` target runs clang-format over all source files in the directory tree excluding lib/External. `isl_config.h` is a header file that is generated by CMake in the build directory, and it's not correctly formatted (which I also wouldn't consider necessary, as it is a generated file).

If the build directory is actually inside the Polly source directory (which it might be if you're building Polly out-of-tree), that check always fails. Hence this patch excludes this file from the check-format target.

Reviewers: Meinersbur, grosser

Reviewed By: grosser

Subscribers: mgorny, llvm-commits, pollydev

Tags: #polly

Differential Revision: https://reviews.llvm.org/D33192

llvm-svn: 303060
2017-05-15 13:20:26 +00:00
Philip Pfaffe 3030bf0c81 [Polly][Fortran Support] Fix two testcases for the loadable-library use-case
llvm-svn: 303057
2017-05-15 12:58:31 +00:00
Philip Pfaffe 838e0884ef [Polly][NewPM] Port ScopInfo to the new PassManager
llvm-svn: 303056
2017-05-15 12:55:14 +00:00
Siddharth Bhat aed4b5682d [NFC] [Fortran Support] Fix findFADGlobalNonAlloc pattern match comment
llvm-svn: 303052
2017-05-15 11:49:19 +00:00
Siddharth Bhat 0fe7231a2f [Fortran Support] Add pattern match for Fortran Arrays that are parameters.
- This breaks the previous assumption that Fortran Arrays are `GlobalValue`.

- The names of functions were getting unwieldy. So, I renamed the
Fortran related functions.

Differential Revision: https://reviews.llvm.org/D33075

llvm-svn: 303040
2017-05-15 08:41:30 +00:00
Siddharth Bhat 9746f817ea [Simplify] Fix r302986 that introduced non-inferrable templates.
- auto + decltype + template use was not inferrable in
  `Transform/Simplify.cpp accessesInOrder`.

- changed code to explicitly construct required vector instead of using
  higher order iterator helpers.

- Failing compiler spec:
    Apple LLVM version 7.3.0 (clang-703.0.31)
    Target: x86_64-apple-darwin15.6.0

llvm-svn: 303039
2017-05-15 08:18:51 +00:00
Tobias Grosser 497fdd7dff [Simplify] Remove some leftover dead code
llvm-svn: 303007
2017-05-14 09:20:56 +00:00
Tobias Grosser b693f42b71 [Polly] Fix code generation of llvm.expect intrinsic
At the time of code generation, an instruction with an llvm intrinsic is ignored
in copyBB. However, if the value of the instruction is used later in the
program, the value needs to be synthesized. However, this is causing some issues
with the instructions being generated in a hoisted basic block.

Removing llvm.expect from the list of ignored intrinsics fixes this bug.

This resolves http://llvm.org/PR32324.

Contributed-by: Annanay Agarwal <cs14btech11001@iith.ac.in>

Tags: #polly

Differential Revision: https://reviews.llvm.org/D32992

llvm-svn: 303006
2017-05-14 09:09:54 +00:00
Michael Kruse fa7be88378 [Simplify] Remove identical write removal. NFC.
Removal of overwritten writes currently encompasses all the cases
of the identical write removal.

There is an observable behavioral change in that the last, instead
of the first, MemoryAccess is kept. This should not affect the
generated code, however.

Differential Revision: https://reviews.llvm.org/D33143

llvm-svn: 302987
2017-05-13 12:20:57 +00:00
Michael Kruse f263610b82 [Simplify] Remove writes that are overwritten.
Remove memory writes that are overwritten by later writes. This works
for StoreInsts:

      store double 21.0, double* %A
      store double 42.0, double* %A

scalar writes at the end of a statement and mixes of these.

Multiple writes can be the result of DeLICM, which might map multiple
writes to the same location when it knows that these do no conflict
(for instance because they write the same value). Such writes
interfere with pattern-matched optimization such as gemm and may not
get removed by other LLVM passes after code generation.

Differential Revision: https://reviews.llvm.org/D33142

llvm-svn: 302986
2017-05-13 11:49:34 +00:00
Michael Kruse aeb4864090 [Simplify] Reset all stats between runs.
llvm-svn: 302926
2017-05-12 17:23:07 +00:00
Philip Pfaffe 5cc87e3ab3 [Polly][NewPM] Port ScopDetection to the new PassManager
Summary: This is a proof of concept of how to port polly-passes to the new PassManager architecture.  This approach works ootb for Function-Passes, but might not be directly applicable to Scop/Region-Passes. While we could just run the Analyses/Transforms over functions instead, we'd surrender the nice pipelining behaviour we have now.

Reviewers: Meinersbur, grosser

Reviewed By: grosser

Subscribers: pollydev, sanjoy, nemanjai, llvm-commits

Tags: #polly

Differential Revision: https://reviews.llvm.org/D31459

llvm-svn: 302902
2017-05-12 14:37:29 +00:00
Siddharth Bhat d0d29addf9 [NFC] [Fortran Support] Run -instnamer on testcases
llvm-svn: 302892
2017-05-12 12:36:04 +00:00
Siddharth Bhat f16db04cd5 [FIX] Fix regression caused by c29f4ed, testcase matches output
- Commit changed codegen for induction variables
- Updated testcase

llvm-svn: 302891
2017-05-12 11:34:51 +00:00
Philip Pfaffe cda7152fcb [Polly][CMake] Fix variable name in target exports
llvm-svn: 302888
2017-05-12 10:39:38 +00:00
Siddharth Bhat c05fcc0d9e [NFC] [Fortran Support] Cleanup Fortran Array pattern mactch testcases
- Move the testcases to ScopInfo/ since the processing takes place in
  ScopBuilder.

- Cleanup testcases, run -polly-canonicalize on them, find minimal set
  of opt parameters.

llvm-svn: 302886
2017-05-12 09:37:39 +00:00
Hongbin Zheng 5b263d4ce1 [Polly] Remove unused header
llvm-svn: 302868
2017-05-12 02:21:50 +00:00
Hongbin Zheng 4fe342cb75 [Polly] Generate more 'canonical' induction variable
Today Polly generates induction variable in this way:

polly.indvar = phi 0, polly.indvar.next
...
polly.indvar.next = polly.indvar + stide
polly.loop_cond = predicate polly.indvar, (UB - stride)

Instead of:

polly.indvar = phi 0, polly.indvar.next
...
polly.indvar.next = polly.indvar + stide
polly.loop_cond = predicate polly.indvar.next, UB

The way Polly generate induction variable cause some problem in the indvar simplify pass.
This patch make polly generate the later form, by assuming the induction variable never overflow

Differential Revision: https://reviews.llvm.org/D33089

llvm-svn: 302866
2017-05-12 02:17:15 +00:00
Michael Kruse d644ec7647 [DeLICM] Use input access heuristic for mapped PHI WRITEs.
As with the scalar operand of the initial StoreInst, also use input
accesses when searching for new opportunities after mapping a
PHI write.

The same rational applies here: After LICM has been applied, the
promoted value will either be an instruction in the same statement
(in which case we fall back to try every scalar access of the
statement), or in another statement such that there will be such
an input access. In the latter case other scalars cannot have
originated from the same register promotion, at least not by LICM.

This mostly helps to decrease compilation time and makes debugging
easier by not pursuing unpromising routes. In some circumstances,
it may change the compiler's output.

llvm-svn: 302839
2017-05-11 22:56:59 +00:00
Michael Kruse 4c27643398 [DeLICM] Lookup input accesses.
Previous to this patch, we used VirtualUse to determine the input
access of an llvm::Value in a statement. The input access is the
READ MemoryAccess that makes a value available in that statement,
which can either be a READ of a MemoryKind::Value or the
MemoryKind::PHI for a PHINode in the statement. DeLICM uses the input
access to heuristically find a candidate to map without searching all
possible values.

This might modify the behaviour in that previously PHI accesses were
not considered input accesses before. This was unintentially lost when
"VirtualUse" was extracted from the "Known Knowledge" patch.

llvm-svn: 302838
2017-05-11 22:56:46 +00:00
Michael Kruse bfaa1857b3 [VirtualInstruction] Do a lookup instead of a linear search. NFC.
llvm-svn: 302837
2017-05-11 22:56:27 +00:00
Michael Kruse e60eca7316 [ScopInfo] Keep scalar acceess dictionaries up-to-data. NFC.
When removing a MemoryAccess, also remove it from maps pointing to it.
This was already done for InstructionToAccess, but not yet for
ValueReads, ValueWrites and PHIWrites as those were only used during
the ScopBuilder phase. Keeping them updated allows us to use them
later as well.

llvm-svn: 302836
2017-05-11 22:56:12 +00:00
Michael Kruse 07e315e780 [Simplify] Remove identical scalar writes.
After DeLICM, it is possible to have two writes of the same value to
the same location in the same statement when it determined that those
writes do not conflict (write the same value).

Teach -polly-simplify to remove one of the writes. It interferes with
the pattern matching of matrix-multiplication kernels and also seem
to not be optimized away by LLVM.

The algorthm is simple, has O(n^2) behaviour (n = max number of
MemoryAccesses in a statement) and only matches the most obvious cases,
but seem to be enough to pattern-match Boost ublas gemm.

Not handled cases include:
- StoreInst instructions (a.k.a. explicit writes), since the value might
  be loaded or overwritten between the two stores.
- PHINode, especially LCSSA, when the PHI value matches with on other's.
- Partial writes (in preparation)

llvm-svn: 302805
2017-05-11 15:07:38 +00:00
Siddharth Bhat abea18feba [NFC] [Fortran Support] move Fortran array detection testcases
move these testcases to where they belong: ScopDetect

llvm-svn: 302735
2017-05-10 21:35:14 +00:00
Michael Kruse a0987b83d5 [Simplify] Mark variables as used. NFC.
Mark one more variable as used that is needed in assertions.

llvm-svn: 302726
2017-05-10 20:45:10 +00:00