Commit Graph

2363 Commits

Author SHA1 Message Date
Michael Kruse f7a4a94d05 Typo: ToComplex -> TooComplex. NFC.
llvm-svn: 268224
2016-05-02 12:25:36 +00:00
Michael Kruse bc150127ae Rename Conjuncts -> Disjunctions. NFC.
The check for complexity compares the number of polyhedra in a set,
which are combined by disjunctions (union, "OR"),
not conjunctions (intersection, "AND").

llvm-svn: 268223
2016-05-02 12:25:18 +00:00
Michael Kruse 315aa3278e [ScheduleOptimizer] Add -polly-opt-outer-coincidence option.
Add a command line switch to set the
isl_options_set_schedule_outer_coincidence option. ISL then tries to
build schedules where the outer member of a band satisfies the
coincidence constraints.

In practice this allows loop skewing for more parallelism in inner
loops.

llvm-svn: 268222
2016-05-02 11:35:27 +00:00
Johannes Doerfert 90f5fed10b [WWW] Mark task as done and me as owner of some task
llvm-svn: 268221
2016-05-02 11:21:30 +00:00
Michael Kruse 2d3ff2a5ba Typo: isToComplex -> isTooComplex. NFC.
llvm-svn: 268220
2016-05-02 10:44:20 +00:00
Tobias Grosser c4a80160b0 doc: A source code with Polly does not use a separate module (by default)
llvm-svn: 268034
2016-04-29 12:35:46 +00:00
Johannes Doerfert 172dd8b923 Allow unsigned divisions
After zero-extend operations and unsigned comparisons we now allow
  unsigned divisions. The handling is basically the same as for signed
  division, except the interpretation of the operands. As the divisor
  has to be constant in both cases we can simply interpret it as an
  unsigned value without additional complexity in the representation.
  For the dividend we could choose from the different representation
  schemes introduced for zero-extend operations but for now we will
  simply use an assumption.

llvm-svn: 268032
2016-04-29 11:53:35 +00:00
Johannes Doerfert ba9725ff41 Refactor SCEVAffinator [NFC]
llvm-svn: 268031
2016-04-29 11:52:30 +00:00
Tobias Grosser 2937b59393 ScopInfo: Add option to control abort on isl errors
For debugging it is often convenient to not abort at the very first memory
management error. This option allows to control this behavior at run-time.

llvm-svn: 268030
2016-04-29 11:43:20 +00:00
Johannes Doerfert 99ec00a2bb [FIX] Typo
llvm-svn: 268027
2016-04-29 10:47:07 +00:00
Johannes Doerfert 64c69f79fb [FIX] Prevent division/modulo by zero in parameters -- test case
This commits a test case for r268023.

llvm-svn: 268026
2016-04-29 10:45:39 +00:00
Johannes Doerfert 3e48ee2ab9 [FIX] Unsigned comparisons change invalid domain
It does not suffice to take a global assumptions for unsigned comparisons but
  we also need to adjust the invalid domain of the statements guarded by such
  an assumption. To this end we allow to specialize the getPwAff call now in
  order to indicate unsigned interpretation.

llvm-svn: 268025
2016-04-29 10:44:41 +00:00
Johannes Doerfert bfaa63a82e [FIX] Prevent division/modulo by zero in parameters
When we materialize parameter SCEVs we did so without considering the
  side effects they might have, e.g., both division and modulo are
  undefined if the right hand side is zero. This is a problem because we
  potentially extended the domain under which we evaluate parameters,
  thus we might have introduced such undefined behaviour. To prevent
  that from happening we will now guard divisions and modulo operations
  in the parameters with a compare and select.

llvm-svn: 268023
2016-04-29 10:36:58 +00:00
Johannes Doerfert 8475d1c163 [FIX] Correct assumption simplification
Assumptions and restrictions can both be simplified with the domain of a
  statement but not the same way. After this patch we will correctly
  distinguish them.

llvm-svn: 267885
2016-04-28 14:32:58 +00:00
Tobias Grosser 947dbe3aae test: Make test case independent of earlier instructions
Instead of matching for %6, we use a regexp to match for the result strings.
This test case caused unrelated noise in http://reviews.llvm.org/D15722.

llvm-svn: 267875
2016-04-28 12:36:39 +00:00
Tobias Grosser 2e27a0f5fd BlockGenerator: Drop leftover debug statement
llvm-svn: 267874
2016-04-28 12:31:05 +00:00
Johannes Doerfert 8ab2803b63 [FIX] Propagate execution domain of invariant loads
If the base pointer of an invariant load is is loaded conditionally, that
  condition needs to hold for the invariant load too. The structure of the
  program will imply this for domain constraints but not for imprecisions in
  the modeling. To this end we will propagate the execution context of base
  pointers during code generation and thus ensure the derived pointer does
  not access an invalid base pointer.

llvm-svn: 267707
2016-04-27 12:49:11 +00:00
Johannes Doerfert 792374b941 Allow unsigned comparisons
With this patch we will optimistically assume that the result of an unsigned
  comparison is the same as the result of the same comparison interpreted as
  signed.

llvm-svn: 267559
2016-04-26 14:33:12 +00:00
Johannes Doerfert 323ab3975b [FIX] Adjust assumption space for zext instructions
llvm-svn: 267552
2016-04-26 12:44:01 +00:00
Johannes Doerfert b2885799d1 Do not use the number of parameters in the complexity check
llvm-svn: 267532
2016-04-26 09:20:41 +00:00
Johannes Doerfert 625bb1fc10 Do not add but record signed-unsigned assumptions
llvm-svn: 267528
2016-04-26 09:16:36 +00:00
Johannes Doerfert 9cc8340fea Extract some constant factors from "SCEVAddExprs"
Additive expressions can have constant factors too that we can extract
  and thereby simplify the internal representation. For now we do
  compute the gcd of all constant factors but only extract the same
  (possibly negated) factor if there is one.

llvm-svn: 267445
2016-04-25 19:09:10 +00:00
Johannes Doerfert d5c369f460 Do not check all GEPs for assumptions
Before, we checked all GEPs in a statement in order to derive
  out-of-bound assumptions. However, this can not only introduce new
  parameters but it is also not clear what we can learn from GEPs that
  are not immediately used in a memory accesses inside the SCoP. As this
  case is very rare, no actual change in the behaviour is expected.

llvm-svn: 267442
2016-04-25 18:55:15 +00:00
Johannes Doerfert c78ce7dc21 Only add user assumptions on known parameters [NFC]
Before, assumptions derived from llvm.assume could reference new
  parameters that were not known to the SCoP before. These were neither
  beneficial to the representation nor to the user that reads the
  emitted remark. Now we project them out and keep only user assumptions
  on known parameters. Nevertheless, the new parameters are still part
  of the SCoPs parameter space as the SCEVAffinator currently adds them
  on demand.

llvm-svn: 267441
2016-04-25 18:51:27 +00:00
Johannes Doerfert 4e3bb7b98c Refactor Scop parameter handling
The new handling is consistent with the remaining code, e.g., we do
  not create a new parameter id for each lookup call but copy an
  existing one. Additionally, we now use the implicit order defined by
  the Parameters set instead of an explicit one defined in a map.

llvm-svn: 267423
2016-04-25 16:15:13 +00:00
Johannes Doerfert c3596284c3 Model zext-extend instructions
A zero-extended value can be interpreted as a piecewise defined signed
  value. If the value was non-negative it stays the same, otherwise it
  is the sum of the original value and 2^n where n is the bit-width of
  the original (or operand) type. Examples:
    zext i8 127 to i32 -> { [127] }
    zext i8  -1 to i32 -> { [256 + (-1)] } = { [255] }
    zext i8  %v to i32 -> [v] -> { [v] | v >= 0; [256 + v] | v < 0 }

  However, LLVM/Scalar Evolution uses zero-extend (potentially lead by a
  truncate) to represent some forms of modulo computation. The left-hand side
  of the condition in the code below would result in the SCEV
  "zext i1 <false, +, true>for.body" which is just another description
  of the C expression "i & 1 != 0" or, equivalently, "i % 2 != 0".

    for (i = 0; i < N; i++)
      if (i & 1 != 0 /* == i % 2 */)
        /* do something */

  If we do not make the modulo explicit but only use the mechanism described
  above we will get the very restrictive assumption "N < 3", because for all
  values of N >= 3 the SCEVAddRecExpr operand of the zero-extend would wrap.
  Alternatively, we can make the modulo in the operand explicit in the
  resulting piecewise function and thereby avoid the assumption on N. For the
  example this would result in the following piecewise affine function:
  { [i0] -> [(1)] : 2*floor((-1 + i0)/2) = -1 + i0;
    [i0] -> [(0)] : 2*floor((i0)/2) = i0 }
  To this end we can first determine if the (immediate) operand of the
  zero-extend can wrap and, in case it might, we will use explicit modulo
  semantic to compute the result instead of emitting non-wrapping assumptions.

  Note that operands with large bit-widths are less likely to be negative
  because it would result in a very large access offset or loop bound after the
  zero-extend. To this end one can optimistically assume the operand to be
  positive and avoid the piecewise definition if the bit-width is bigger than
  some threshold (here MaxZextSmallBitWidth).

  We choose to go with a hybrid solution of all modeling techniques described
  above. For small bit-widths (up to MaxZextSmallBitWidth) we will model the
  wrapping explicitly and use a piecewise defined function. However, if the
  bit-width is bigger than MaxZextSmallBitWidth we will employ overflow
  assumptions and assume the "former negative" piece will not exist.

llvm-svn: 267408
2016-04-25 14:01:36 +00:00
Johannes Doerfert 517d8d2f94 Check only loop control of loops that are part of the region
This also removes a duplicated line of code in the region generator
  that caused a SPEC benchmark to fail with the new SCoPs.

llvm-svn: 267404
2016-04-25 13:37:24 +00:00
Johannes Doerfert a4dd8ef40f Initialize the invalid domain of an access with an empty set
llvm-svn: 267403
2016-04-25 13:36:23 +00:00
Johannes Doerfert e4459a24cc Do not propagate invalid domains over back edges
llvm-svn: 267402
2016-04-25 13:34:50 +00:00
Johannes Doerfert f560b3d2db Introduce a parameter set type [NFC]
llvm-svn: 267401
2016-04-25 13:33:07 +00:00
Johannes Doerfert ec8a217729 Remove unnecessary argument of the SCEVValidator [NFC]
llvm-svn: 267400
2016-04-25 13:32:36 +00:00
Johannes Doerfert 6862f0cb5c Remove unused iterators [NFC]
llvm-svn: 267336
2016-04-24 12:31:02 +00:00
Johannes Doerfert 85676e3674 Add an invalid domain to memory accesses
Memory accesses can have non-precisely modeled access functions that
  would cause us to build incorrect execution context for hoisted loads.
  This is the same issue that occurred during the domain construction for
  statements and it is dealt with the same way.

llvm-svn: 267289
2016-04-23 14:32:34 +00:00
Johannes Doerfert ac9c32e216 Translate SCEVs to isl_pw_aff and their invalid domain
The SCEVAffinator will now produce not only the isl representaiton of
  a SCEV but also the domain under which it is invalid. This is used to
  record possible overflows that can happen in the statement domains in
  the statements invalid domain. The result is that invalid loads have
  an accurate execution contexts with regards to the validity of their
  statements domain. While the SCEVAffinator currently is only taking
  "no-wrapping" assumptions, we can add more withouth worrying about the
  execution context of loads that are optimistically hoisted.

llvm-svn: 267288
2016-04-23 14:31:17 +00:00
Johannes Doerfert a3519515b5 Track invalid domains not invalid contexts for statements
The invalid context is not enough to describe the parameter constraints under
  which a statement is not modeled precisely. The reason is that during the
  domain construction the bounds on the induction variables are not known but
  needed to check if e.g., an overflow can actually happen. To this end we
  replace the invalid context of a statement with an invalid domain. It is
  initialized during domain construction and intersected with the domain once
  it was completely build. Later this invalid domain allows to eliminate
  falsely assumed wrapping cases and other falsely assumed mismatches in the
  modeling.

llvm-svn: 267286
2016-04-23 13:02:23 +00:00
Johannes Doerfert 94341c996d Improve accuracy of Scop::hasFeasibleRuntimeContext
If the AssumptionContext is a subset of the InvalidContext the runtime
  context is not feasible.

llvm-svn: 267285
2016-04-23 13:00:27 +00:00
Johannes Doerfert 1dc12aff8a Simplify the execution context for dereferencable loads
If we know it is safe to execute a load we do not need an execution
  context, however only if we are sure it was modeled correctly.

llvm-svn: 267284
2016-04-23 12:59:18 +00:00
Johannes Doerfert f4f1d9a5cf Remove simplification calls for the execution domain [NFC]
These calls were sometimes costly and do not show any improvements on our
  small test cases.

llvm-svn: 267283
2016-04-23 12:56:58 +00:00
Johannes Doerfert d77089e62d Bail for complex execution contexts of invariant loads
llvm-svn: 267146
2016-04-22 11:41:14 +00:00
Johannes Doerfert 5d03f84cf5 Early exit for addInvariantLoads
llvm-svn: 267143
2016-04-22 11:38:44 +00:00
Johannes Doerfert 6296d95420 Bail for complex alias checks
llvm-svn: 267142
2016-04-22 11:38:19 +00:00
Johannes Doerfert 06ae425e28 Repair doxygen comment [NFC]
llvm-svn: 267141
2016-04-22 11:36:13 +00:00
Johannes Doerfert 171b92f1e1 Relate domains to statements during construction [NFC]
Instead of the Scop::getPwAff() function we now use the ScopStmt::getPwAff()
  function during the statements domain construction.

llvm-svn: 266741
2016-04-19 14:53:13 +00:00
Johannes Doerfert ff68f46458 Add user assumptions after domain generation [NFC]
llvm-svn: 266740
2016-04-19 14:49:42 +00:00
Johannes Doerfert 535de03571 Do not build domains for out of SCoP blocks [NFC]
llvm-svn: 266739
2016-04-19 14:49:05 +00:00
Johannes Doerfert fff283df7a Mark Scop::getDomainConditions as const [NFC]
llvm-svn: 266738
2016-04-19 14:48:22 +00:00
Tobias Grosser 90303f872d SCoPValidator: Use SCEVTraversal to simplify SCEVInRegionDependences
llvm-svn: 266622
2016-04-18 15:46:27 +00:00
Tobias Grosser b99b97420f Update two more test cases for r266445+r266446 II
llvm-svn: 266475
2016-04-15 21:02:35 +00:00
Tobias Grosser 8af5e2f7bb Update two more test cases for r266445+r266446
llvm-svn: 266474
2016-04-15 20:56:17 +00:00
Tobias Grosser ad25f0fee6 Update debug metadata after LLVM commits r266445+r266446
llvm-svn: 266473
2016-04-15 20:51:27 +00:00