Commit Graph

37 Commits

Author SHA1 Message Date
Tobias Grosser 262538435f ScopInfo: Make getDimensionSize better reflect which dimensions carry sizes
In polly the first dimensions of an array as well as all scalars do not carry
any size information. This commit makes this explicit in the interface of
getDimensionSize. Before this commit getDimensionSize(0) returned the size of
the first dimension that carried a size. After this commit getDimensionSize(i)
will either return the size of dimension 'i' or assert in case 'i' does not
carry a size or does not exist at all.

This very same behaviour was already present in getDimensionSizePw(). This
commit also adds assertions that ensure getDimensionSizePw() is called
appropriately.

llvm-svn: 252607
2015-11-10 14:24:21 +00:00
Johannes Doerfert c4898504ea [FIX] Bail out if there is a dependence cycle between invariant loads
While the program cannot cause a dependence cycle between invariant
  loads, additional constraints (e.g., to ensure finite loops) can
  introduce them. It is hard to detect them in the SCoP description,
  thus we will only check for them at code generation time. If such a
  recursion is detected we will bail out the code generation and place a
  "false" runtime check to guarantee the original code is used.

  This fixes bug 25443.

llvm-svn: 252412
2015-11-07 19:46:04 +00:00
Duncan P. N. Exon Smith b8f58b53dd polly/ADT: Remove implicit ilist iterator conversions, NFC
Remove all the implicit ilist iterator conversions from polly, in
preparation for making them illegal in ADT.  There was one oddity I came
across: at line 95 of lib/CodeGen/LoopGenerators.cpp, there was a
post-increment `Builder.GetInsertPoint()++`.

Since it was a no-op, I removed it, but I admit I wonder if it might be
a bug (both before and after this change)?  Perhaps it should be a
pre-increment?

llvm-svn: 252357
2015-11-06 22:56:54 +00:00
Johannes Doerfert 907456fe04 [FIX] Use appropriately sized types for big constants
llvm-svn: 251869
2015-11-03 00:26:22 +00:00
Tobias Grosser f4bb7a6a4d Consolidate the different ValueMapTypes we are using
There have been various places where llvm::DenseMap<const llvm::Value *,
llvm::Value *> types have been defined, but all types have been expected to be
identical. We make this more clear by consolidating the different types and use
BlockGenerator::ValueMapT wherever there is a need for types to match
BlockGenerator::ValueMapT.

llvm-svn: 249264
2015-10-04 10:18:32 +00:00
Tobias Grosser 0d8874c0f6 OpenMP codegen: support generation of multi-dimensional access functions
When computing the index expressions for new, multi-dimensional memory accesses
these new index expressions may reference original llvm::Values that are not
transfered into the OpenMP subfunction. Using GlobalMap we now replace
references to such values with the rewritten values that have e.g. been passed
to the OpenMP subfunction.

llvm-svn: 246923
2015-09-05 10:32:56 +00:00
Johannes Doerfert e69e1141d9 Introduce the ScopExpander as a SCEVExpander replacement
The SCEVExpander cannot deal with all SCEVs Polly allows in all kinds
  of expressions. To this end we introduce a ScopExpander that handles
  the additional expressions separatly and falls back to the
  SCEVExpander for everything else.

Reviewers: grosser, Meinersbur

Subscribers: #polly

Differential Revision: http://reviews.llvm.org/D12066

llvm-svn: 245288
2015-08-18 11:56:00 +00:00
Tobias Grosser 22adfb4373 Mark sdivs as 'exact' instead of lowering them ourselves
LLVM's instcombine already translates power-of-two sdivs that are known to be
exact to fast ashr instructions. Hence, there is no need to add this logic
ourselves.

Pointed-out-by: Johannes Doerfert
llvm-svn: 239025
2015-06-04 07:45:09 +00:00
Tobias Grosser 244c8297cf Lower signed-divisions without rounding to ashr instructions
llvm-svn: 238929
2015-06-03 15:14:58 +00:00
Tobias Grosser 224b162280 Only convert power-of-two floor-division with non-negative denominator
floord(a,b) === a ashr log_2 (b) holds for positive and negative a's, but
shifting only makes sense for positive values of b. The previous patch did
not consider this as isl currently always produces postive b's. To avoid future
surprises, we check that b is positive and only then apply the optimization.

We also now correctly check the return value of the dyn-cast.

No additional test case, as isl currently does not produce negative
denominators.

Reported-by: David Majnemer <david.majnemer@gmail.com>
llvm-svn: 238927
2015-06-03 14:43:01 +00:00
Tobias Grosser cb73f150d4 Translate power-of-two floor-division into ashr
Power-of-two floor divisions can be translated into an arithmetic shift
operation. This allows us to replace a complex lowering that requires division
operations:

  %pexp.fdiv_q.0 = sub i64 %21, 128
  %pexp.fdiv_q.1 = add i64 %pexp.fdiv_q.0, 1
  %pexp.fdiv_q.2 = icmp slt i64 %21, 0
  %pexp.fdiv_q.3 = select i1 %pexp.fdiv_q.2, i64 %pexp.fdiv_q.1, i64 %21
  %pexp.fdiv_q.4 = sdiv i64 %pexp.fdiv_q.3, 128

with a simple ashr:

  %polly.fdiv_q.shr = ashr i64 %21, 7

llvm-svn: 238905
2015-06-03 06:31:30 +00:00
Tobias Grosser cdb38e5625 Exploit non-negative numerators
isl marks known non-negative numerators in modulo (and soon also division)
operations. We now exploit this by generating unsigned operations. This is
beneficial as unsigned operations with power-of-two denominators will be
translated by isl to fast bitshift or bitwise and operations.

llvm-svn: 238577
2015-05-29 17:08:19 +00:00
Tobias Grosser 5db5d2da13 Use base-pointer address space when creating new access functions
llvm-svn: 237785
2015-05-20 11:02:12 +00:00
Tobias Grosser 49ad36ca16 Add printing and testing to ScopArrayInfo
Being here, we extend the interface to return the element type and not a pointer
to the element type. We also provide a function to get the size (in bytes) of
the elements stored in this array.

We currently still store the element size as an innermost dimension in
ScopArrayInfo, which is somehow inconsistent and should be addressed in future
patches.

llvm-svn: 237779
2015-05-20 08:05:31 +00:00
Tobias Grosser ba0d09227c Sort include directives
Upcoming revisions of isl require us to include header files explicitly, which
have previously been already transitively included. Before we add them, we sort
the existing includes.

Thanks to Chandler for sort_includes.py. A simple, but very convenient script.

llvm-svn: 236930
2015-05-09 09:13:42 +00:00
Tobias Grosser eb18649ead Sign-extend in case of non-matching bitwidth
This change ensures that we sign-extend integer types in case non-matching
operands are encountered when generating a multi-dimensional access offset.

This fixes http://llvm.org/PR23124

Reported-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
llvm-svn: 234122
2015-04-05 17:36:42 +00:00
Tobias Grosser 3284f1975c Assert in isl expression builder if id can not be found [NFC]
llvm-svn: 231865
2015-03-10 22:35:43 +00:00
Tobias Grosser 90078c5580 Add sign-extension during codegen of index expressions
When code generating array index expressions the types of the different
components of the index expressions may not always match. We extend the type of
the index expression (if possible) and assert otherwise.

llvm-svn: 231592
2015-03-08 15:08:32 +00:00
Tobias Grosser b021a4faad Add support for conditional 'and' and 'or' expressions
No test cases unfortunately as we do not yet generate isl_ast_op_and_then or
isl_ast_op_or_else. Those will be added in a later commit.

llvm-svn: 231268
2015-03-04 18:14:59 +00:00
Johannes Doerfert 0837c2da74 [FIX] Partially fix the pointer negation crash
llvm-svn: 227805
2015-02-02 15:25:09 +00:00
Johannes Doerfert ef61def9d5 [FIX] Handle pointer-pointer comparisons
This should fix a problem introduced by r225464.

llvm-svn: 227404
2015-01-29 00:41:33 +00:00
Tobias Grosser c642e95402 Use types of matching size when generating multi-dimensional address expressions
This change ensures that the values that represent the array size of a
multi-dimensional access are correctly sign-extended when used to compute a
memory address used in the run-time alias check.

To make the test case more readable, we name the instructions that we generate.

llvm-svn: 225818
2015-01-13 19:37:59 +00:00
Tobias Grosser 55bc4c0767 Add support for pointer types in expressions
llvm-svn: 225464
2015-01-08 19:26:53 +00:00
Tobias Grosser 314587d743 Use explicit StringRef Type
We previously used a Twine here, but as pointed out by David Blaikie
and Mehdi Amini storing a temporary StringRef in a Twine is not a good
idea, as the StringRef will be freed before the Twine is used leaving
a Twine that points to uninitialized memory. We now make it explicit that
we use a StringRef here.

llvm-svn: 225342
2015-01-07 07:43:34 +00:00
Tobias Grosser 5dfcb1a7e0 Do not use a const Twine here
This has caused segfaults when using Polly in the context of Julia, that are
not reproducible on my machine in 'make check-polly'.

llvm-svn: 225326
2015-01-07 00:30:01 +00:00
Tobias Grosser 13e222ca55 Update to the latest version of isl
Isl now specifically marks modulo operations that are compared against zero.
They can be implemented with the C/LLVM remainder operation.

We also update a couple of test cases where the output of isl has slightly
changed.

llvm-svn: 223607
2014-12-07 16:04:29 +00:00
Johannes Doerfert 219b20e1a3 [Fix] Non i1 typed select condition for weird pw aff functions.
In case the pieceweise affine function used to create an isl_ast_expr
  had empty cases (e.g., with contradicting constraints on the
  parameters), it was possible that the condition of the isl_ast_expr
  select was not a comparison but a constant (thus of type i64).

  This patch does two thing:
   1) Handle the case the condition of a select is not a i1 type like C.
   2) Try to simplify the pieceweise affine functions for the min/max
      access when we generate runtime alias checks. That step can often
      remove empty or redundant cases as well as redundant constrains.

  This fixes bug: http://llvm.org/PR21167

Differential Revision: http://reviews.llvm.org/D5627

llvm-svn: 219208
2014-10-07 14:37:59 +00:00
Johannes Doerfert 2ef33e9f16 Allow multidimensional accesses in the IslExprBuilder.
This resolved the issues with delinearized accesses that might alias,
  thus delinearization doesn't deactivate runtime alias checks anymore.

Differential Revision: http://reviews.llvm.org/D5614

llvm-svn: 219078
2014-10-05 11:33:59 +00:00
Johannes Doerfert 1a28a8938e Introduce the ScopArrayInfo class.
This class allows to store information about the arrays in the SCoP.
  For each base pointer in the SCoP one object is created storing the
  type and dimension sizes of the array. The objects can be obtained via
  the SCoP, a MemoryAccess or the isl_id associated with the output
  dimension of a MemoryAccess (the description of what is accessed).

  So far we use the information in the IslExprBuilder to create the
  right base type before indexing into the base array. This fixes the
  bug http://llvm.org/bugs/show_bug.cgi?id=21113 (both test cases are
  included). On top of that we can now build runtime alias checks for
  delinearized arrays as the dimension sizes are also part of the
  ScopArrayInfo objects.

Differential Revision: http://reviews.llvm.org/D5613

llvm-svn: 219077
2014-10-05 11:32:18 +00:00
Johannes Doerfert 77bd5ae3d9 [Fix] Allow pointer types as access elements and compare them correctly
This fixes two problems which are usualy caused together:
    1) The elements of an isl AST access expression could be pointers
       not only integers, floats and vectores thereof.
    2) The runtime alias checks need to compare pointers but if they
       are of a different type we need to cast them into a "max" type
       similar to the non pointer case.

llvm-svn: 218113
2014-09-19 08:49:02 +00:00
Johannes Doerfert b164c795b7 [RTC] Runtime Alias Checks for the ISL backend
This change will build all alias groups (minimal/maximal accesses
  to possible aliasing base pointers) we have to check before
  we can assume an alias free environment. It will also use these
  to create Runtime Alias Checks (RTC) in the ISL code generation
  backend, thus allow us to optimize SCoPs despite possibly aliasing
  pointers when this backend is used.

  This feature will be enabled for the isl code generator, e.g.,
  --polly-code-generator=isl, but disabled for:
    - The cloog code generator (still the default).
    - The case delinearization is enabled.
    - The case non-affine accesses are allowed.

llvm-svn: 218046
2014-09-18 11:17:17 +00:00
Johannes Doerfert dcb5f1dcf6 Allow the IslExprBuilder to build address of expressions
llvm-svn: 218045
2014-09-18 11:14:30 +00:00
Johannes Doerfert 5e8de624b5 Allow the IslExprBuilder to compare pointers
llvm-svn: 218044
2014-09-18 11:14:07 +00:00
Johannes Doerfert b7e4083599 Updated to isl 2c19ecd444095d6f560349018f68993bc0e03691
Changed test cases and fixed warnings.

llvm-svn: 218043
2014-09-18 11:13:35 +00:00
Johannes Doerfert a63b2579c6 Fix the modifiable access creation
+ Remove the class IslGenerator which duplicates the functionality of
    IslExprBuilder.
  + Use the IslExprBuilder to create code for memory access relations.
    + Also handle array types during access creation.
  + Enable scev codegen for one of the transformed memory access tests,
    thus access creation without canonical induction variables available.
  + Update one test case to the new output.

llvm-svn: 214659
2014-08-03 01:51:59 +00:00
Johannes Doerfert ed87831113 Allow the IslExprBuilder to generate access operations
llvm-svn: 214658
2014-08-03 01:50:50 +00:00
Johannes Doerfert 13c5c64b5d [Refactor] Expose the IslExprBuilder (missing files)
llvm-svn: 214220
2014-07-29 21:06:08 +00:00