Commit Graph

3932 Commits

Author SHA1 Message Date
Michael Kruse d72637f5cc [ScopBuilder] Fix bug 38358 by preserving correct order of ScopStmts.
ScopBuilder::buildEqivClassBlockStmts creates ScopStmts for instruction
groups in basic block and inserts these ScopStmts into Scop::StmtMap,
however, as described in llvm.org/PR38358, comment #5, StmtScops are
inserted into vector ScopStmt[BB] in wrong order.  As a result,
ScopBuilder::buildSchedule creates wrong order sequence node.

Looking closer to code, it's clear there is no equivalent classes with
interleaving isOrderedInstruction(memory access) instructions after
joinOrderedInstructions.  Afterwards, ScopStmts need to be created and
inserted in the original order of memory access instructions, however,
at the moment ScopStmts are inserted in the order of leader instructions
which are probably not memory access instructions.

The fix is simple with a standalone loop scanning
isOrderedInstruction(memory access) instructions in basic block and
inserting elements into LeaderToInstList one by one.  The patch also
removes double reversing operations which are now unnecessary.

New test preserve-equiv-class-order-in-basic_block.ll is also added.

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

llvm-svn: 375192
2019-10-17 23:55:35 +00:00
Guillaume Chatelet 0e62011df8 [Alignment][NFC] Remove dependency on GlobalObject::setAlignment(unsigned)
Summary:
This is patch is part of a series to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790

Reviewers: courbet

Subscribers: arsenm, mehdi_amini, jvesely, nhaehnle, hiraditya, steven_wu, dexonsmith, dang, llvm-commits

Tags: #llvm

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

llvm-svn: 374880
2019-10-15 11:24:36 +00:00
Volodymyr Sapsai 109bfb7b32 [Polly] Fix formatting violation. NFC.
llvm-svn: 374504
2019-10-11 03:09:24 +00:00
Volodymyr Sapsai 126158f096 [Stats] More polly fixes following llvm::Statistic changes in r374490.
llvm-svn: 374501
2019-10-11 02:42:16 +00:00
Volodymyr Sapsai e90cc03a85 [Stats] Fix polly build due to change in llvm::Statistic constructor in r374490.
llvm-svn: 374497
2019-10-11 01:43:36 +00:00
Guillaume Chatelet d400d45150 [Alignment][NFC] Remove StoreInst::setAlignment(unsigned)
Summary:
This is patch is part of a series to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790

Reviewers: courbet, bollu, jdoerfert

Subscribers: hiraditya, asbirlea, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

llvm-svn: 373595
2019-10-03 13:17:21 +00:00
Guillaume Chatelet ab11b9188d [Alignment][NFC] Remove AllocaInst::setAlignment(unsigned)
Summary:
This is patch is part of a series to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790

Reviewers: courbet

Subscribers: jholewinski, arsenm, jvesely, nhaehnle, eraman, hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

llvm-svn: 373207
2019-09-30 13:34:44 +00:00
Guillaume Chatelet 725efb35c7 [Alignment] Fix polly build
llvm-svn: 373199
2019-09-30 11:14:00 +00:00
Tim Northover 1249126c7c Revert "Update polly test for SCEV change."
The motivating SCEV change was reverted as incorrect.

llvm-svn: 373185
2019-09-30 07:47:08 +00:00
Michael Kruse 241b02e762 [CodeGen] Handle outlining of CopyStmts.
Since the removal of extensions nodes from schedule trees in r362257 it
is possible to emit parallel code for SCoPs containing
matrix-multiplications. However, the code looking for references used in
outlined statement was not prepared to handle CopyStmts introduced by
the matrix-matrix multiplication detection.

In this case, CopyStmts do not introduce references in addition to the
ones captured by MemoryAccesses, i.e. we change the assertion to accept
CopyStmts and add a regression test for this case.

This fixes llvm.org/PR43164

llvm-svn: 372188
2019-09-17 22:59:43 +00:00
Rainer Orth 570c50aa92 [Polly] Fix lib/Transform/ScheduleOptimizer.cpp compilation on Solaris
lib/Transform/ScheduleOptimizer.cpp fails to compile on Solaris, both on the 9.x
branch (first noticed when running test-release.sh without -no-polly) and on trunk:

  /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/tools/polly/lib/Transform/ScheduleOptimizer.cpp: In function ‘MicroKernelParamsTy getMicroKernelParams(const llvm::TargetTransformInfo*, polly::MatMulInfoTy)’:
  /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/tools/polly/lib/Transform/ScheduleOptimizer.cpp:914:62: error: call of overloaded ‘sqrt(long unsigned int)’ is ambiguous
    914 |       ceil(sqrt(Nvec * LatencyVectorFma * ThroughputVectorFma) / Nvec) * Nvec;
        |                                                              ^
  In file included from /usr/gcc/9/lib/gcc/x86_64-pc-solaris2.11/9.1.0/include-fixed/math.h:24,
                   from /usr/gcc/9/include/c++/9.1.0/cmath:45,
                   from /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/include/llvm-c/DataTypes.h:28,
                   from /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/include/llvm/Support/DataTypes.h:16,
                   from /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/include/llvm/ADT/Hashing.h:47,
                   from /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/include/llvm/ADT/ArrayRef.h:12,
                   from /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/tools/polly/include/polly/ScheduleOptimizer.h:12,
                   from /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/tools/polly/lib/Transform/ScheduleOptimizer.cpp:48:
  /usr/gcc/9/lib/gcc/x86_64-pc-solaris2.11/9.1.0/include-fixed/iso/math_iso.h:220:21: note: candidate: ‘long double std::sqrt(long double)’
    220 |  inline long double sqrt(long double __X) { return __sqrtl(__X); }
        |                     ^~~~
  /usr/gcc/9/lib/gcc/x86_64-pc-solaris2.11/9.1.0/include-fixed/iso/math_iso.h:186:15:
note: candidate: ‘float std::sqrt(float)’
    186 |  inline float sqrt(float __X) { return __sqrtf(__X); }
        |               ^~~~
  /usr/gcc/9/lib/gcc/x86_64-pc-solaris2.11/9.1.0/include-fixed/iso/math_iso.h:74:15:
note: candidate: ‘double std::sqrt(double)’
     74 | extern double sqrt __P((double));
        |               ^~~~
  /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/tools/polly/lib/Transform/ScheduleOptimizer.cpp:915:67:
error: call of overloaded ‘ceil(long unsigned int)’ is ambiguous
    915 |   int Mr = ceil(Nvec * LatencyVectorFma * ThroughputVectorFma / Nr);
        |                                                                   ^
  In file included from /usr/gcc/9/lib/gcc/x86_64-pc-solaris2.11/9.1.0/include-fixed/math.h:24,
                   from /usr/gcc/9/include/c++/9.1.0/cmath:45,
                   from /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/include/llvm-c/DataTypes.h:28,
                   from /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/include/llvm/Support/DataTypes.h:16,
                   from /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/include/llvm/ADT/Hashing.h:47,
                   from /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/include/llvm/ADT/ArrayRef.h:12,
                   from /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/tools/polly/include/polly/ScheduleOptimizer.h:12,
                   from /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/tools/polly/lib/Transform/ScheduleOptimizer.cpp:48:
  /usr/gcc/9/lib/gcc/x86_64-pc-solaris2.11/9.1.0/include-fixed/iso/math_iso.h:196:21: note: candidate: ‘long double std::ceil(long double)’
    196 |  inline long double ceil(long double __X) { return __ceill(__X); }
        |                     ^~~~
  /usr/gcc/9/lib/gcc/x86_64-pc-solaris2.11/9.1.0/include-fixed/iso/math_iso.h:160:15:
note: candidate: ‘float std::ceil(float)’
    160 |  inline float ceil(float __X) { return __ceilf(__X); }
        |               ^~~~
  /usr/gcc/9/lib/gcc/x86_64-pc-solaris2.11/9.1.0/include-fixed/iso/math_iso.h:76:15:
note: candidate: ‘double std::ceil(double)’
     76 | extern double ceil __P((double));
        |               ^~~~

Fixed by adding casts to disambiguate, checked that it now compiles on both 
amd64-pc-solaris2.11 and sparcv9-sun-solaris2.11 and on x86_64-pc-linux-gnu.

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

llvm-svn: 371825
2019-09-13 08:45:06 +00:00
Michael Kruse 87baae85cd [ScopBuilder] Skip getting leader when merging statements to close holes.
Function joinOrderedInstructions merges instructions when a leader is encountered twice.
It also notices that leaders in SeenLeaders may lose their leadership in previous merging,
and tries to handle the case using following code:

    Instruction *PrevLeader = UnionFind.getLeaderValue(SeenLeaders.back());

However, this is wrong because it always gets leader for the last element of SeenLeaders,
and I believe it's wrong even we get leader for Prev here.  As a result, Statements in cases
like the one in patch aren't merged as expected.  After investigation, I believe it's
unnecessary to get leader instruction at all.  This is based on fact: Although leaders in
SeenLeaders could lose leadership, they only lose to others in SeenLeaders, in other words,
one existing leader will be chosen as new leader of merged equivalent statements.  We can
take advantage of this and simply check if current leader equals to Prev and break merging
if it does.

The patch also adds a new test.

Patch by bin.narwal <bin.narwal@gmail.com>

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

llvm-svn: 371801
2019-09-13 01:04:38 +00:00
Michael Kruse acbdd07de6 [DependenceInfo] Compute WAR dependence info using ISL kills. NFC.
When reading code of Dependences::calculateDependences, I noticed that
WAR is computed specifically by buildWAR.  Given ISL now
supports "kills" in approximate dataflow analysis, this patch takes
advantage of it.

This patch also cleans up a couple lines redundant codes.

Patch by bin.narwal <bin.narwal@gmail.com>

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

llvm-svn: 370396
2019-08-29 18:55:55 +00:00
Michael Kruse 6220ce60de [ScopBuilder] Remove superfluous while loop in buildDomains. NFC.
The while loop iterating parent loop in ScopBuilder::buildDomains is
unnecessary because either L or LD are later unused, this is a simple
patch removing it.

Patch by bin.narwal <bin.narwal@gmail.com>

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

llvm-svn: 370368
2019-08-29 14:42:41 +00:00
Michael Kruse 88fd2d0123 [ScopBuilder] Simplify main statement flag in buildEqivClassBlockStmts. NFC.
When reading code in ScopBuilder::buildEqivClassBlockStmts, I think the
main statement flag computation can be simplified, here is the patch.
It's based on two simple facts that:

  1. Instruction won't be removed once it's inserted into UnionFind.
  2. Main statement must be set if there is non-trivial statement besides the last one.

The patch also saves std::find call.

Patch by bin.narwal <bin.narwal@gmail.com>

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

llvm-svn: 369972
2019-08-26 21:31:47 +00:00
Jonas Devlieghere 736259e342 [Polly] Migrate llvm::make_unique to std::make_unique
Now that we've moved to C++14, we no longer need the llvm::make_unique
implementation from STLExtras.h. This patch is a mechanical replacement
of (hopefully) all the llvm::make_unique instances across the monorepo.

Differential revision: https://reviews.llvm.org/D66259

llvm-svn: 368935
2019-08-14 22:28:12 +00:00
Michael Kruse cc0f0582c8 [Polly-ACC] Fix test after IR-printer change.
After r367755, even unnamed parameters are printed in IR dumps. Change
the test to expect te additional %0 in the line.

llvm-svn: 368763
2019-08-13 22:42:08 +00:00
Dominik Adamski a0438305d0 [NFC][ScopBuilder] Move buildDomains and its callees to ScopBuilder.
Scope of changes:

1) Moved buildDomains function to ScopBuilder class.
2) Moved buildDomainsWithBranchConstraints function to ScopBuilder class.
3) Moved propagateDomainConstraints to ScopBuilder class.
4) Moved propagateDomainConstraintsToRegionExit to ScopBuilder class.
5) Moved propagateInvalidStmtDomains to ScopBuilder class.
6) Moved getPredecessorDomainConstraints function to ScopBuilder class.
7) Moved addLoopBoundsToHeaderDomain function to ScopBuilder class.
8) Moved getPwAff function to ScopBuilder class.
9) Moved buildConditionSets functions to ScopBuilder class.
10) Added updateMaxLoopDepth, notifyErrorBlock, getOrInitEmptyDomain, isDomainDefined, setDomain functions to Scop class. They are used by ScopBuilder.
11) Moved helper functions: getRegionNodeBasicBlock, getRegionNodeSuccessor, containsErrorBlock, createNextIterationMap, collectBoundedParts, partitionSetParts, buildConditionSet to ScopBuilder.cpp file.

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

llvm-svn: 368100
2019-08-06 21:51:18 +00:00
Dominik Adamski b169e58b31 [NFC][ScopBuilder] Move addUserAssumptions to ScopBuilder
Scope of changes:
1) Moved addUserAssumptions function to ScopBuilder class.
2) Moved buildConditionSets functions to polly namespace.
3) Moved getRepresentingInvariantLoadSCEV to public section of the Scop class

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

llvm-svn: 368089
2019-08-06 21:25:35 +00:00
Fangrui Song d9b948b6eb Rename F_{None,Text,Append} to OF_{None,Text,Append}. NFC
F_{None,Text,Append} are kept for compatibility since r334221.

llvm-svn: 367800
2019-08-05 05:43:48 +00:00
Guillaume Chatelet d2b45f299e [Polly] Clang complains about missing virtual destructor
Summary: Feel free to reassign if needed.

Reviewers: mhalk, bollu, jdoerfert

Reviewed By: jdoerfert

Subscribers: jdoerfert, llvm-commits

Tags: #llvm

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

llvm-svn: 366697
2019-07-22 15:34:27 +00:00
Eli Friedman c68dd359ae Update polly test for SCEV change.
r366419 adds nsw to more SCEV expressions, which allows polly to
make more aggressive assumptions about the input expressions.

llvm-svn: 366510
2019-07-18 22:35:45 +00:00
Hans Wennborg 8f5b44aead Bump the trunk version to 10.0.0svn
and clear the release notes.

llvm-svn: 366427
2019-07-18 11:51:05 +00:00
Dominik Adamski d0ac007f9a [NFC][ScopBuilder] Move buildSchedule and its callees to ScopBuilder or ScopHelper
Scope of changes:
1. Moved buildSchedule functions to ScopBuilder.
2. Moved combineInSequence function to ScopBuilder.
3. Moved mapToDimension function to ScopBuilder.
4. Moved LoopStackTy to ScopBuilder.
5. Moved getLoopSurroundingScop to ScopHelper.
6. Moved getNumBlocksInLoop to ScopHelper.
7. Moved getNumBlocksInRegionNode to ScopHelper.
8. Moved getRegionNodeLoop to ScopHelper.

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

llvm-svn: 366377
2019-07-17 21:42:39 +00:00
Dominik Adamski eece5a9d31 [NFC][ScopBuilder]Move finalizeAccesses and its callees to ScopBuilder
Scope of changes:
1) Moved finalizeAccesses to ScopBuilder
2) Moved updateAccessDimensionality to ScopBuilder
3) Moved foldSizeConstantsToRight to ScopBuilder
4) Moved foldSizeConstantsToRight to ScopBuilder
5) Moved assumeNoOutOfBounds to ScopBuilder
6) Moved markFortranArrays to ScopBuilder
7) Added iterator range for AccessFunctions vector.

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

llvm-svn: 366374
2019-07-17 21:25:18 +00:00
Dominik Adamski fdc61bce94 [NFC][ScopBuilder] Move addUserContext to ScopBuilder
Scope of changes:
1) Moved addUserContext to ScopBuilder.
2) Moved command line option UserContextStr to ScopBuilder.

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

llvm-svn: 366266
2019-07-16 21:29:06 +00:00
Dominik Adamski 588fc9e756 [NFC][ScopBuilder] Move buildAliasChecks and its implementing methods to ScopBuilder
Scope of changes:
1) Moved buildAliasChecks to ScopBuilder.
2) Moved buildAliasGroup to ScopBuilder.
3) Moved buildAliasGroups to ScopBuilder.
4) Moved buildAliasGroupsForAccesses to ScopBuilder.
5) Moved splitAliasGroupsByDomain to ScopBuilder.
6) Moved addNonEmptyDomainConstraints to ScopBuilder.
7) Moved buildMinMaxAccess to ScopBuilder.
8) Moved calculateMinMaxAccess to ScopBuilder.
9) Moved getAccessDomain to ScopBuilder.
10) Moved command line options used only by buildAliasChecks functions to ScopBuilder.
11) Refactored buildAliasGroup function. Added addAliasGroup function to Scop class for pushing back calculated min/max accesses.
12) Added function incrementNumberOfAliasingAssumptions which increments number of statistic variable AssumptionsAliasing. AssumptionsAliasing variable is defined by STATISTIC macro inside ScopInfo.cpp and it is also used by function trackAssumption from Scop class.
13) Added reference to OptimizationRemarkEmitter to ScopBuilder class.
14) Moved calculateMinMaxAccess function to ScopBuilder class.

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

llvm-svn: 366262
2019-07-16 21:10:45 +00:00
Dominik Adamski ddbb83732a [NFC][ScopBuilder] Move addRecordedAssumption to ScopBuilder
Scope of changes:
1) Moved addRecordedAssumptions to ScopBuilder.
2) Moved Assumption struct outside Scop class.
3) Refactored addRecordedAssumptions function. Replaced while loop by
for range loop.
4) Added function to clear processed Assumptions.

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

llvm-svn: 366260
2019-07-16 20:51:04 +00:00
Dominik Adamski 46b84fa231 [ScopInfo][NFC] Add dot at the end of comment statement.
llvm-svn: 366134
2019-07-15 22:01:55 +00:00
Tim Northover 4bc20fa149 OpaquePtr: Update polly's calls to Loads.h API
The Loads.h API changed so that a Type parameter is now mandatory in
preparation for pointer types being opaque. Unfortunately I don't build
polly routinely and it still had some uses. This just provides the
(obvious) load type in each case.

llvm-svn: 365470
2019-07-09 12:13:31 +00:00
Michael Kruse 88afd75300 [test] Add wrap flags after D61934.
https://reviews.llvm.org/D61934, committed as r362687, r363540, r363364
and r363147, made some emitted instruction nus/nsw. Add these falgs to
Polly's regression tests.

This should fix
    Polly :: Isl/CodeGen/partial_write_in_region_with_loop.ll
    Polly :: Isl/CodeGen/scev_expansion_in_nonaffine.ll

llvm-svn: 363599
2019-06-17 19:17:07 +00:00
Michael Kruse 77bc3b6542 [ScopInliner] Register FunctionAnalysisManagerModuleProxy.
FunctionAnalysisManagerModuleProxy started to be used by the
AlwaysInlinerPass in r363287 and therefore had to be registered in the
New PassManager.

Should fix the regression tests
    Polly :: ScopInliner/invariant-load-func.ll
    Polly :: ScopInliner/simple-inline-loop.ll

llvm-svn: 363572
2019-06-17 16:01:40 +00:00
Michael Kruse 189abad128 [ScopBuilder] Move addInvariantLoads to ScopBuilder. NFC.
Moved addInvariantLoads and functions listed below to ScopBuilder:
isAParameter
canAlwaysBeHoisted

These functions were referenced only by getNonHoistableCtx.

Moved CLI parameter PollyAllowDereferenceOfAllFunctionParams to
ScopBuilder.

Added iterator range through InvariantEquivClasses.

Patch by Dominik Adamski <adamski.dominik@gmail.com>

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

llvm-svn: 363216
2019-06-12 22:51:56 +00:00
Michael Kruse bb824c61a9 [ScopBuilder] Move getNonHoistableCtx to ScopBuilder. NFC.
This review is based on review: https://reviews.llvm.org/D62925 . It is
part of moving hoistInvariantLoads function and all functions referenced
only by hoistInvariantLoads to ScopBuilder.

Moved getNonHoistableCtx and functions listed below to ScopBuilder:
isRequiredInvariantLoad
hasNonHoistableBasePtrInScop
isAccessRangeTooComplex

These functions were referenced only by getNonHoistableCtx.

MaxDimensionsInAccessRange and MaxDisjunctsInDomain constant is marked
as extern and it is added to polly namespace. It is used by Scop and
ScopBuilder classes.

MaxDimensionsInAccessRange constant moved to ScopBuilder. It is not used
outside ScopBuilder.

Patch by Dominik Adamski <adamski.dominik@gmail.com>

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

llvm-svn: 363214
2019-06-12 22:40:08 +00:00
Michael Kruse 549991e48c [ScopBuilder] Move hoistInvariantLoads to ScopBuilder. NFC.
Refactor Scop and ScopBuilder class:

1. Move hoistInvariantLoads function from Scop to ScopBuilder class.

2. Private functions (addInvariantLoads, getNonHoistableCtx) are moved
   to public section of Scop class. hoistInvariantLoads function
   references these functions. These functions will be moved to
   ScopBuilder as well in the next steps.

Patch by Dominik Adamski <adamski.dominik@gmail.com>

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

llvm-svn: 363121
2019-06-12 04:23:05 +00:00
Michael Kruse bd9e810b23 [ScheduleTreeTransform] Silence compiler warning. NFC.
Use size_t for position which is the return type type ArrayRef::size()
it is compared to.

llvm-svn: 362724
2019-06-06 17:15:36 +00:00
Michael Kruse 06c801e153 [ScopBuilder] Move canonicalizeDynamicsBasePtrs from ScopInfo. NFC.
Refactor Scop and ScopBuilder class. Move canonicalizeDynamicsBasePtrs
and corresponding static functions from ScopInfo.cpp to ScopBuilder.cpp

Patch by Dominik Adamski <adamski.dominik@gmail.com>

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

llvm-svn: 362554
2019-06-04 21:58:54 +00:00
Michael Kruse c16ab9dd88 [ScopBuilder] Move verifyInvariantLoads function from ScopInfo. NFC.
Refactor Scop and ScopBuilder class. Move verifyInvariantLoads from Scop
class to ScopBuilder class.

Patch by: Dominik Adamski <adamski.dominik@gmail.com>

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

llvm-svn: 362258
2019-05-31 19:40:20 +00:00
Michael Kruse aa8a976174 [ScheduleOptimizer] Hoist extension nodes after schedule optimization.
Extension nodes make schedule trees are less flexible: Many operations,
such as rescheduling, do not work on such schedule trees with extension.
As such, some functionality such as determining parallel loops in isl's
AST are disabled.

Currently, only the pattern-matching generalized matrix-matrix
multiplication optimization adds extension nodes (to add copy-in
statements).

This patch removes all extension nodes as the last step of the schedule
optimization by hoisting the extension node's added domain up to the
root domain node. All following passes can assume that schedule trees
work without restrictions, including the parallelism test. Mark the
outermost loop of the optimized matrix-matrix multiplication as parallel
such that -polly-parallel is able to parallelize that loop.

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

llvm-svn: 362257
2019-05-31 19:26:57 +00:00
Michael Kruse 26212da555 [ScopBuilder] Move buildInvariantEquivalenceClasses function from ScopInfo. NFC.
Refactor Scop and ScopBuilder class. Move
buildInvariantEquivalenceClasses function from Scop class to ScopBuilder
class.

Patch by: Dominik Adamski <adamski.dominik@gmail.com>

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

llvm-svn: 361902
2019-05-28 23:47:55 +00:00
Michael Kruse 467069688d [DeLICM] Use polly::singleton to allow empty result.
isl_map_from_union_map cannot determine the map's space if the union_map
is empty. polly::singleton was designed for this case. We pass the
expected map space to avoid crashing in isl_map_from_union_map.

This fixes an issue found by the aosp buildbot. Thanks to Eli Friedman
for the reproducer.

llvm-svn: 361290
2019-05-21 19:18:26 +00:00
Michael Kruse c4c679c232 [CodeGen] Fix order of PHINode and MA Write generation.
At the end of a region statement, the PHINode must be generated
while the current IRBuilder's block is the region's exit node. For
obvious reasons: The PHINode references the region's exiting block.
A partial write would insert new control flow, i.e. insert new basic
blocks between the exiting blocks and the current block.

We fix this by generating the PHI nodes (region exit values) before
generating any MemoryAccess's stores.

This should fix the AOSP buildbot.

Reported-by: Eli Friedman <efriedma@quicinc.com>
llvm-svn: 361204
2019-05-20 22:31:09 +00:00
Michael Kruse ac5c8318d7 [DependenceInfo] Remove dead initialization. NFC.
Fix scan-analyzer issue:
Value stored to 'WARMemAccesses' during its initialization is never read

Patch by Dominik Adamski <adamski.dominik@gmail.com>

Signed-off-by: Dominik Adamski <adamski.dominik@gmail.com>
llvm-svn: 361196
2019-05-20 20:54:17 +00:00
Eli Friedman a0de66dd17 [polly] Fix non-determinism in IslNodeBuilder.
The iteration order of OutsideLoopIterations matters for
IslNodeBuilder::getReferencesInSubtree, which inserts the values from
the map into a SetVector, which is eventually used to construct the
type of the context for parallel loops.

llvm-svn: 360723
2019-05-14 23:01:19 +00:00
Eli Friedman 9b234b388d [Polly] Don't crash on invalid delinearization result.
In certain cases, it's possible for delinearization to decide one of the
array dimensions should be some function of an induction variable inside
the scop.  Make sure if this happens, we refuse to use those dimensions
for delinearization.

Usually, we end up rejecting the scop before it actually crashes, but it
looks like it's possible to slip past other checks in certain cases
involving smax expressions.

Fixes a crash that started showing up this week on the polly AOSP
builder.  As far as I can tell, this is a longstanding issue, though;
it was just exposed by better SCEV analysis of smin expressions.

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

llvm-svn: 360708
2019-05-14 21:32:54 +00:00
Michael Kruse 2698390c68 [ZoneAlgo] Fix PHI inconsistency in invalid contexts.
PHI nodes (reads) could point to multiple instances of predecessor
blocks (PHI writes) when in an invalid context. Fix by removing PHI
instances that are in an invalid or ouside assumed context.

This fixes llvm.org/PR41656.

llvm-svn: 360454
2019-05-10 18:38:13 +00:00
Keno Fischer aa1b6f1cfb [polly][SCEV] Expand SCEV matcher cases for new smin/umin ops
These were added in rL360159, but I neglected to update polly at the
same time.

llvm-svn: 360238
2019-05-08 10:36:04 +00:00
Michael Kruse 031bb16556 Apply include-what-you-use #include removal suggestions. NFC.
This removes unused includes (and forward declarations) as
suggested by include-what-you-use. If a transitive include of a removed
include is required to compile a file, I added the required header (or
forward declaration if suggested by include-what-you-use).

This should reduce compilation time and reduce the number of iterative
recompilations when a header was changed.

llvm-svn: 357209
2019-03-28 20:19:49 +00:00
Nikita Popov 6d855ea024 [ConstantRange] Rename isWrappedSet() to isUpperWrapped()
Split out from D59749. The current implementation of isWrappedSet()
doesn't do what it says on the tin, and treats ranges like
[X, Max] as wrapping, because they are represented as [X, 0) when
using half-inclusive ranges. This also makes it inconsistent with
the semantics of isSignWrappedSet().

This patch renames isWrappedSet() to isUpperWrapped(), in preparation
for the introduction of a new isWrappedSet() method with corrected
behavior.

llvm-svn: 357107
2019-03-27 18:19:33 +00:00
Michael Kruse ea40d5b05b Moving ManagedMemoryRewritePass when hybrid option is selected
Compiling with -polly-target=hybrid was causing Polly to occur two times
in the pipeline. The reason was how the ManagedMemoryRewritePass was
registered in the pass manager. ManagedMemoryRewritePass being a
ModulePass was forcing all previous passes to get recomputed. This
commit avoids Polly to appear two times in the pipeline registering the
ManagedMemoryRewritePass later in the pass manager.

Patch by Lorenzo Chelini <l.chelini@icloud.com>

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

llvm-svn: 356965
2019-03-25 23:26:59 +00:00