Commit Graph

200 Commits

Author SHA1 Message Date
Tobias Grosser e2c05bbefe PollyDependence: Simplify Read/Write/MayWrite before feeding them into ISL.
Contributed-by: Star Tan <tanmx_star@yeah.net>
llvm-svn: 187981
2013-08-08 13:55:45 +00:00
Tobias Grosser e42ddb9ad3 ScopInfo: Split start value from SCEVAddRecExpr to enable parameter sharing.
SCoP invariant parameters with the different start value would deter parameter
sharing. For example, when compiling the following C code:

  void foo(float *input) {
    for (long j = 0; j < 8; j++) {
      // SCoP begin
      for (long i = 0; i < 8; i++) {
        float x = input[j * 64 + i + 1];
        input[j * 64 + i] = x * x;
      }
    }
  }

Polly would creat two parameters for these memory accesses:

    p_0: {0,+,256}
    p_2: {4,+,256}
    [j * 64 + i + 1] => MemRef_input[o0] : 4o0 = p_1 + 4i0
    [j * 64 + i]     => MemRef_input[o0] : 4o0 = p_0 + 4i0

These parameters only differ from start value. To enable parameter sharing,
we split the start value from SCEVAddRecExpr, so they would share a single
parameter that always has zero start value:

    p0: {0,+,256}<%for.cond1.preheader>
    [j * 64 + i + 1] => MemRef_input[o0] : 4o0 = 4 + p_1 + 4i0
    [j * 64 + i]     => MemRef_input[o0] : 4o0 = p_0 + 4i0

Such translation can make the polly-dependence much faster.

Contributed-by: Star Tan <tanmx_star@yeah.net>
llvm-svn: 187728
2013-08-05 15:14:15 +00:00
Tobias Grosser abd96a0c0a Dependence: Add DEBUG support.
Contributed-by:  Star Tan <tanmx_star@yeah.net>
llvm-svn: 187498
2013-07-31 14:35:17 +00:00
Tobias Grosser 983e785f17 gitattributes: .png and .txt are no text files
llvm-svn: 187326
2013-07-28 09:05:20 +00:00
Tobias Grosser c7d3fc5547 ScopDetect: Only track detection failures if actually needed.
String operations resulted by raw_string_ostream in the INVALID macro can lead
to significant compile-time overhead when compiling large size source code.
This is because raw_string_ostream relies on TypeFinder class, whose
compile-time cost increases as the size of the module increases. This patch
targets to ensure that it only track detection failures if actually needed.
In this way, we can avoid expensive string operations in normal execution.

With this patch file, the relative compile-time cost of Polly-detect pass does
not increase even when compiling very large size source code.

Contributed-by:   Star Tan <tanmx_star@yeah.net>
llvm-svn: 187102
2013-07-25 03:02:29 +00:00
Tobias Grosser ff9bfdfa80 ScopInfo/IndependentBlocks: clang-format
llvm-svn: 187023
2013-07-24 06:10:30 +00:00
Tobias Grosser 5b1a7f2245 ScopDetect: move "return false" out of INVALID macro.
Contributed-by: Star Tan <tanmx_star@yeah.net>
llvm-svn: 186805
2013-07-22 03:50:33 +00:00
Hongbin Zheng 63cc9467af Ensure a correct order between memory accesses.
Ensure that the scalar write access corresponds to the result of a load
instruction appears after the generic read access corresponds to the load
instruction.

llvm-svn: 186419
2013-07-16 15:20:29 +00:00
Hongbin Zheng c6aa9f5c2a Make sure the each instruction is mapped to one memory access.
llvm-svn: 186417
2013-07-16 15:18:51 +00:00
Tobias Grosser 298a7646f3 ScopDetect: clang-format
llvm-svn: 186289
2013-07-14 18:09:43 +00:00
Tobias Grosser 001bd274f5 Dependences: Use ostream printer to print analysis output
llvm-svn: 186288
2013-07-14 18:09:40 +00:00
Tobias Grosser b58f6a4211 ScopInfo: Add getTupe() method to MemoryAccess
We also move the enum to UPPERCASE.

llvm-svn: 186259
2013-07-13 20:41:24 +00:00
Tobias Grosser 229d681675 Dependences: Clarify difference between value and memory based dependences
We make the option a clear choice between the two analysis types and add
descriptions about the difference between the two.

llvm-svn: 186251
2013-07-13 17:37:55 +00:00
Tobias Grosser aef925e81f Small style improvements
llvm-svn: 186248
2013-07-13 16:58:07 +00:00
Sebastian Pop 784c012982 scop detection: remove an iteration over all uses
reenabled reverted patch after checking that it passes without regressions on
the nightly test-suite.  Added testcase from Tobi.

llvm-svn: 185720
2013-07-05 20:24:47 +00:00
Sebastian Pop 8c2d75302f scop detection: early return
to reduce indentation level
No functionality changed.

llvm-svn: 185590
2013-07-03 22:50:36 +00:00
Tobias Grosser 14a3999354 clang-format latest changes
llvm-svn: 185440
2013-07-02 16:13:07 +00:00
Hongbin Zheng 8d3a888ca3 TempScop: (Partial) Implement the printDetail function.
llvm-svn: 185254
2013-06-29 07:00:14 +00:00
Hongbin Zheng f4adf0fc44 Minor change: No need to specify the namespace of raw_ostream.
llvm-svn: 185252
2013-06-29 06:30:55 +00:00
Tobias Grosser 04d6ae65b7 Fix my own formatting mistakes
llvm-svn: 184659
2013-06-23 06:04:54 +00:00
Tobias Grosser 4f96749351 ScopInfo: Clarify may-write and must-write accesses
llvm-svn: 184658
2013-06-23 05:21:18 +00:00
Tobias Grosser 58032cb029 Integrate latest clang-format changes
llvm-svn: 184655
2013-06-23 01:29:29 +00:00
Tobias Grosser edab1359a0 Use isl_val instead of isl_int in the core of Polly
isl recently introduced isl_val as an abstract interface to represent arbitrary
precision numbers. This interface superseeds the old isl_int interface. In
contrast to the old interface which implemented arbitrary precision arithmetic
using macros that forward to the gmp library, the new library hides the math
library implementation in isl. This allows us to switch the math library used by
isl without affecting users such as Polly.

llvm-svn: 184529
2013-06-21 06:41:31 +00:00
Sebastian Pop a189a5763c revert r183799: scop detection: remove an iteration over all uses
llvm-svn: 184128
2013-06-17 21:43:10 +00:00
Sebastian Pop 8ca899c781 scop detection: inline and remove isValidBasicBlock
llvm-svn: 184001
2013-06-14 20:20:43 +00:00
Sebastian Pop e1e4a2d534 scop detection: check flag before expensive call
llvm-svn: 184000
2013-06-14 20:20:39 +00:00
Sebastian Pop 9d63234ad1 ScopDetect: check region entering edges are valid.
When a region header is part of a loop, then all entering edges of this region
should not come from the loop but outside the region. Otherwise, the loop may be
only partially part of the region, which would cause troubles in handling
induction variables.

Currently, we can only model induction variables that are either fully part of
the scop (loop induction variable) or induction variables that are scop-
invariant (parameter). A loop that is only partially part of the
scop causes troubles, as there is no good way to handle the induction
variable in the independent blocks pass.

Contributed-by:    Star Tan <tanmx_star@yeah.net>
llvm-svn: 183800
2013-06-11 22:20:40 +00:00
Sebastian Pop 15117271c7 scop detection: remove an iteration over all uses
llvm-svn: 183799
2013-06-11 22:20:35 +00:00
Sebastian Pop b88ea5e991 scop detection: run isValidLoop as early as possible
to discard regions with invalid loops before going through the contents of the
basic blocks

llvm-svn: 183798
2013-06-11 22:20:32 +00:00
Sebastian Pop 9e3d2dd6ea scop detection: run isValidCFG as early as possible
to discard regions with invalid CFG before going through the contents of the
basic blocks

llvm-svn: 183797
2013-06-11 22:20:27 +00:00
Hongbin Zheng 599782bb6c TempScopInfo: Add code to build the scalar dependences.
llvm-svn: 183653
2013-06-10 13:55:34 +00:00
Hongbin Zheng d1fdf0b180 Refactor: Move the IRAccess building code to a new function.
llvm-svn: 183635
2013-06-10 02:52:30 +00:00
Sebastian Pop b35892bd59 scop detection: do not call getAliasSetForPointer when IgnoreAliasing
Contributed-by: Dmitry N. Mikushin <maemarcus@gmail.com>
llvm-svn: 183114
2013-06-03 16:35:41 +00:00
Sebastian Pop 2c9ec2e651 scop detection: do not run scop detection on regions without loops
otherwise, use -polly-detect-scops-in-regions-without-loops to also detect scops
in regions without loops

llvm-svn: 183113
2013-06-03 16:35:37 +00:00
Sebastian Pop 8fe6d11b84 scop detection: only handle functions with loops
to detect scops in functions with no loops, use -polly-detect-scops-in-functions-without-loops

llvm-svn: 182941
2013-05-30 17:47:32 +00:00
Tobias Grosser 83628182f7 Sort includes
llvm-svn: 181297
2013-05-07 08:11:54 +00:00
Tobias Grosser 637bd63123 Move polly options into separate option category
Use the new cl::OptionCategory support to move the Polly options into a separate
option category. The aim is to hide most options and show by default only the
options a user needs to influence '-O3 -polly'. The available options probably
need some care, but here is the current status:

Polly Options:
Configure the polly loop optimizer

  -enable-polly-openmp              - Generate OpenMP parallel code
  -polly                            - Enable the polly optimizer (only at -O3)
  -polly-no-tiling                  - Disable tiling in the scheduler
  -polly-only-func=<function-name>  - Only run on a single function
  -polly-report                     - Print information about the activities
                                      of Polly
  -polly-vectorizer                 - Select the vectorization strategy
    =none                           -   No Vectorization
    =polly                          -   Polly internal vectorizer
    =unroll-only                    -   Only grouped unroll the vectorize
                                        candidate loops
    =bb                             -   The Basic Block vectorizer driven by
                                        Polly

llvm-svn: 181295
2013-05-07 07:31:10 +00:00
Tobias Grosser e602a07662 Reformat with clang-format
clang-format become way more stable. This time we mainly reformat function
signatures.

llvm-svn: 181294
2013-05-07 07:30:56 +00:00
Tobias Grosser 8edce4ee62 Support SCoPs with multiple entry edges.
Regions that have multiple entry edges are very common. A simple if condition
yields e.g. such a region:

  if
 /   \
then  else
 \   /
for_region

This for_region contains two entry edges 'then' -> 'for_region' and 'else' -> 'for_region'.

Previously we scheduled the RegionSimplify pass to translate such regions into
simple regions. With this patch, we now support them natively when the region is
in -loop-simplify form, which means the entry block should not be a loop header.

Contributed by:  Star Tan <tanmx_star@yeah.net>

llvm-svn: 179586
2013-04-16 08:04:42 +00:00
Tobias Grosser d7e58640a5 Update formatting to latest version of clang-format
llvm-svn: 179160
2013-04-10 06:55:45 +00:00
Tobias Grosser 0ee50f6ee4 Support SCoPs with multiple exit edges
Regions that have multiple exit edges are very common. A simple if condition
yields e.g. such a region:

        if
      /   \
  then     else
      \   /
      after

Region: if -> after

This regions contains the bbs 'if', 'then', 'else', but not 'after'. It has
two exit edges 'then' -> 'after' and 'else' -> 'after'.

Previously we scheduled the RegionSimplify pass to translate such regions into
simple regions. With this patch, we now support them natively.

Contributed-by: Star Tan <tanmx_star@yeah.net>
llvm-svn: 179159
2013-04-10 06:55:31 +00:00
Sebastian Pop 9f57c5b695 scop detection: properly instantiate SCEVs to the place where they are used
Fix inspired from c2d4a0627e95c34a819b9d4ffb4db62daa78dade.

    Given the following code

        for (i = 0; i < 10; i++) {
          ;
        }

    S:  A[i] = 0

    When translate the data reference A[i] in statement S using scev, we need to
    retrieve the scev of 'i' at the location of 'S'. If we do not do this the
    scev that we obtain will be expressed as {0,+,1}_for and will reference loop
    iterators that do not surround 'S'. What we really want is the scev to be
    instantiated to the value of 'i' after the loop. This value is {10}.

This used to crash in:

    int loopDimension = getLoopDepth(Expr->getLoop());

    isl_aff *LAff = isl_aff_set_coefficient_si(
        isl_aff_zero_on_domain(LocalSpace), isl_dim_in, loopDimension, 1);

(gdb) p Expr->dump()
{8,+,8}<nw><%do.body>

(gdb) p getLoopDepth(Expr->getLoop())
$5 = 0

    isl_space *Space = isl_space_set_alloc(Ctx, 0, NbLoopSpaces);
    isl_local_space *LocalSpace = isl_local_space_from_space(Space);

As we are trying to create a memory access in a stmt that is outside all loops,
LocalSpace has 0 dimensions:

(gdb) p NbLoopSpaces
$12 = 0

(gdb) p Statement.BB->dump()

if.then:                                          ; preds = %do.end
  %0 = load float* %add.ptr, align 4
  store float %0, float* %q.1.reg2mem, align 4
  br label %if.end.single_exit

and so the scev for %add.ptr should be taken at the place where it is used,
i.e., it should be the value on the last iteration of the do.body loop, and not
"{8,+,8}<nw><%do.body>".

llvm-svn: 179148
2013-04-10 04:05:18 +00:00
Tobias Grosser aeabcf24df ScopDetection: Use isTopLevelRegion
Contributed-by: Star Tan <tanmx_star@yeah.net>
llvm-svn: 178530
2013-04-02 06:41:48 +00:00
Tobias Grosser 4d96c8d714 clang-format: Many more files
After this commit, polly is clang-format clean. This can be tested with
'ninja polly-check-format'. Updates to clang-format may change this, but the
differences will hopefully be both small and general improvements to the
formatting.

We currently have some not very nice formatting for a couple of items, DEBUG()
stmts for example. I believe the benefit of being clang-format clean outweights
the not perfect layout of this code.

llvm-svn: 177796
2013-03-23 01:05:07 +00:00
Sebastian Pop 27c10c6b1f ScopInfo: do not call getCanonicalInductionVariable for SCEVCodegen
llvm-svn: 177771
2013-03-22 22:07:43 +00:00
Tobias Grosser 826b2af112 Remove last uses of canoncial induction variable when scev code generating
We now detect scops without a canonical induction variable and can generate a
polyhedral representation for them. There was no modification necessary to
code generate these scops.

llvm-svn: 177643
2013-03-21 16:14:50 +00:00
Tobias Grosser ecfe21b792 Remove dependence on canonical induction variable
When using the scev based code generation, we now do not rely on the presence
of a canonical induction variable any more. This commit prepares the path to
(conditionally) disable the induction variable canonicalization pass.

llvm-svn: 177548
2013-03-20 18:03:18 +00:00
Tobias Grosser 84b81dee55 ScopDetect: Remove some redundant semicolons
llvm-svn: 177444
2013-03-19 21:44:07 +00:00
Tobias Grosser b2863ca2dc Print function names under --polly-report
llvm-svn: 176446
2013-03-04 19:49:51 +00:00
Sebastian Pop f30d3b2d89 don't store a pointer to the loop in IVS
llvm-svn: 175304
2013-02-15 21:26:48 +00:00