Commit Graph

447 Commits

Author SHA1 Message Date
Tobias Grosser e8df5bd92b IndependentBlocks: We can only reconstruct PHI nodes that are within the ScoP
In the classical (non -polly-codegen-scev) mode, we assume that we can always
recreate PHI nodes during code generation. This is not true. We can only
reconstruct them from the polyhedral information, in case the entire loop of the
PHI node is part of the SCoP and consequently the PHI node was translated in
the polyhedral description.

llvm-svn: 179674
2013-04-17 07:20:36 +00:00
Tobias Grosser b5f92892d1 Remove unneeded RegionSimplify pass.
We now support regions with multiple entries and multiple exits natively.
Regions are not needed to be simplified to single entry and single exit.

We need to XFAIL two test cases as this change increases the scop coverage
and uncoveres two failures in the independent blocks pass. The first failure
will be fixed in a subsequent commit, the second one is in the non-default
-polly-codegen-scev mode and still needs to be fixed.

Contributed-by: Star Tan <tanmx_star@yeah.net>
llvm-svn: 179673
2013-04-17 07:20:30 +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 3ed2600cab SCEVValidator: Correctly store 'k * p' as a parameter
We do not only need to understand that 'k * p' is a parameter expression, but
also need to store this expression in the set of parameters. Before this patch
we wrongly stored the two individual parameters %k and %p.

Reported by: Sebastian Pop <spop@codeaurora.org>

llvm-svn: 179485
2013-04-14 13:15:59 +00:00
Tobias Grosser 249c4b1ad5 ScheduleOptimizer: Use isl_map_from_union_map to extract map.
llvm-svn: 179268
2013-04-11 05:55:13 +00:00
Tobias Grosser f242b806ac ScheduleOpt: Do not crash on statements with empty iteration domains
Statements with an empty iteration domain may not have a schedule assigned by
the isl schedule optimizer. As Polly expects each statement to have a schedule,
we keep the old schedule for such statements.

This fixes http://llvm.org/PR15645`

Reported-by: Johannes Doerfert  <johannesdoerfert@gmx.de>
llvm-svn: 179233
2013-04-10 22:48:08 +00:00
Tobias Grosser ecb5092707 ScopDetect: Allow multiplications of the form <param> * <param>
We handle these by treating this result of the multiplication as an additional
parameter.

llvm-svn: 179163
2013-04-10 07:42:28 +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
Tobias Grosser 03fc9acbe5 Codegen: Replace region exit and entries recursively
During code generation we split the original entry and exit basic blocks
of the scop to make room for the newly generated code. To keep the region tree
up to date, we need to update the region tree. This patch ensures that not only
the region of the scop is updated, but also all child regions that share the
same entry or exit block.

We have now test case here, as the bug is only exposed by the subsequent commit.
The test cases of that commit also cover this bug.

Contributed-by: Star Tan <tanmx_star@yeah.net>
llvm-svn: 179158
2013-04-10 06:55:20 +00:00
Sebastian Pop e7a7beec7d fix typos
llvm-svn: 179149
2013-04-10 04:09:12 +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
Sebastian Pop 9ca6612731 IndependentBlocks: translate out of SSA all uses escaping the region
llvm-svn: 179019
2013-04-08 13:05:41 +00:00
Sebastian Pop cefec6d7e4 SCEVCodegen should not run createIndVarSimplifyPass
llvm-svn: 179018
2013-04-08 13:05:37 +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 c2bdf1973b RegisterPasses: Improve comments
llvm-svn: 177831
2013-03-23 21:35:52 +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
Tobias Grosser 45af235e09 RegisterPasses: clang-format
llvm-svn: 177787
2013-03-23 00:32:21 +00:00
Tobias Grosser f008da125c Instvarsimplify: clang-format
Even though we will soon get rid of this pass, we reformat it on the way to
make polly clang-format clean.

llvm-svn: 177786
2013-03-23 00:32:18 +00:00
Tobias Grosser 9abbfc0b69 IndependentBlocks: clang-format and remove includes
llvm-svn: 177785
2013-03-23 00:32:15 +00:00
Tobias Grosser c30d9cc678 DeadCodeElimination: clang-format and comment
llvm-svn: 177782
2013-03-23 00:16:05 +00:00
Tobias Grosser 33bc2e93be CodePreparation: Comment and format the file properly
llvm-svn: 177781
2013-03-23 00:13:39 +00:00
Tobias Grosser 369430ffca codegen: properly instantiate SCEVs to the place where they are used
Given the following code

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

S:  A[i] = 0

When code generating S using scev based code generation, 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' and that we consequently do not know how to code
generate. What we really want is the scev to be instantiated to the value of 'i'
after the loop. This value is {10} and it can be code generated without
troubles.

llvm-svn: 177777
2013-03-22 23:42:53 +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 4e318abece Do not canonicalize indvars with scev based codegen
Scev code generation can now handle scops with non canonical induction
variables. Hence there is no need to introduce canonical ones any more.

llvm-svn: 177644
2013-03-21 16:14:53 +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 5bfa4f8eb8 CodePrepare: Do not require canonical induction variables for scev based mode
llvm-svn: 177593
2013-03-20 22:41:53 +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
Andy Gibbs 36e6ca0143 Remove unnecessary explicit typing in std::make_pair
llvm-svn: 177528
2013-03-20 15:42:59 +00:00
Tobias Grosser b921e6377b Add option -polly-code-generator=none
This allows us to test Polly and the Polly optimizer without actually doing
code generation at the end. By enabling this option, we can also measure the
compile time overhead due to code generation and the cost of LLVM optimizing the
newly generated code.t

llvm-svn: 177516
2013-03-20 13:03:26 +00:00
Tobias Grosser 0fbbbf6aa7 Silence 'variable unused' warning in release mode
llvm-svn: 177515
2013-03-20 13:03:25 +00:00
Tobias Grosser 84b81dee55 ScopDetect: Remove some redundant semicolons
llvm-svn: 177444
2013-03-19 21:44:07 +00:00
Sebastian Pop 97cb813c29 Correct function to decide if a SCEV can be ignored
When doing SCEV based code generation, we ignore instructions calculating values
that are fully defined by a SCEV expression. The values that are calculated by
this instructions are recalculated on demand.

This commit improves the check to verify if certain instructions can be ignored
and recalculated on demand.

llvm-svn: 177313
2013-03-18 20:21:13 +00:00
Tobias Grosser 0d1cf2b875 ScopHelper: Remove some dead code
llvm-svn: 177307
2013-03-18 19:17:07 +00:00
Sebastian Pop e039bb1fdb use the canonical IV only when it exists
llvm-svn: 177306
2013-03-18 19:09:49 +00:00
Tobias Grosser b2863ca2dc Print function names under --polly-report
llvm-svn: 176446
2013-03-04 19:49:51 +00:00
Tobias Grosser de49b8fa3b Support: clang-format
llvm-svn: 175874
2013-02-22 08:21:52 +00:00
Tobias Grosser 7242ad9226 CodeGen: clang-format
llvm-svn: 175872
2013-02-22 08:07:06 +00:00
Sebastian Pop 47d4ee3ed4 capitalize SCEV to match the current naming convention
llvm-svn: 175306
2013-02-15 21:26:53 +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
Sebastian Pop 860e021fe6 add NestLoops to remove some uses of IVS
llvm-svn: 175303
2013-02-15 21:26:44 +00:00
Sebastian Pop 637b23dc63 use apply and ScevParameterRewriter::rewrite instead of SCEVRewriter
llvm-svn: 175296
2013-02-15 20:56:01 +00:00
Sebastian Pop 9d10fffa33 add LoopToScev maps
llvm-svn: 175295
2013-02-15 20:55:59 +00:00
Tobias Grosser d535f55146 Formatting fixes
llvm-svn: 175177
2013-02-14 16:42:45 +00:00
Tobias Grosser c14582f276 CodeGen: clang-format goodness
The changed files are not yet clang-format clean, but we are getting close.

llvm-svn: 174403
2013-02-05 18:01:29 +00:00
Tobias Grosser 1f11b44939 TempScopInfo: clang-format
llvm-svn: 174368
2013-02-05 12:27:23 +00:00
Tobias Grosser 14f4c3e9fa Dependences: clang-format
Everything except INITIALIZE_PASS_* macros

llvm-svn: 174367
2013-02-05 12:27:22 +00:00
Tobias Grosser abfbe637bc ScopInfo: clang-format file
clang-format was able to format the entire file except the final
INITIALIZE_PASS_* macros.

llvm-svn: 174366
2013-02-05 12:09:06 +00:00
Tobias Grosser 0d1eee3298 ScopDetect: clang-format pointer types in templates
llvm-svn: 174365
2013-02-05 11:56:05 +00:00
Tobias Grosser af3c00b87b ScopDetection: clang-format some more code
llvm-svn: 174362
2013-02-05 09:40:22 +00:00