llvm-project/polly/test/ScopDetect
Michael Kruse 6744efa8d8 [ScopDetection] Only allow SCoP-wide available base pointers.
Simplify ScopDetection::isInvariant(). Essentially deny everything that
is defined within the SCoP and is not load-hoisted.

The previous understanding of "invariant" has a few holes:

- Expressions without side-effects with only invariant arguments, but
  are defined withing the SCoP's region with the exception of selects
  and PHIs. These should be part of the index expression derived by
  ScalarEvolution and not of the base pointer.

- Function calls with that are !mayHaveSideEffects() (typically
  functions with "readnone nounwind" attributes). An example is given
  below.

      @C = external global i32
      declare float* @getNextBasePtr(float*) readnone nounwind
      ...
      %ptr = call float* @getNextBasePtr(float* %A, float %B)

  The call might return:

  * %A, so %ptr aliases with it in the SCoP
  * %B, so %ptr aliases with it in the SCoP
  * @C, so %ptr aliases with it in the SCoP
  * a new pointer everytime it is called, such as malloc()
  * a pointer into the allocated block of one of the aforementioned
  * any of the above, at random at each call

  Hence and contrast to a comment in the base_pointer.ll regression
  test, %ptr is not necessarily the same all the time. It might also
  alias with anything and no AliasAnalysis can tell otherwise if the
  definition is external. It is hence not suitable in the role of a
  base pointer.

The practical problem with base pointers defined in SCoP statements is
that it is not available globally in the SCoP. The statement instance
must be executed first before the base pointer can be used. This is no
problem if the base pointer is transferred as a scalar value between
statements. Uses of MemoryAccess::setNewAccessRelation may add a use of
the base pointer anywhere in the array. setNewAccessRelation is used by
JSONImporter, DeLICM and D28518. Indeed, BlockGenerator currently
assumes that base pointers are available globally and generates invalid
code for new access relation (referring to the base pointer of the
original code) if not, even if the base pointer would be available in
the statement.

This could be fixed with some added complexity and restrictions. The
ExprBuilder must lookup the local BBMap and code that call
setNewAccessRelation must check whether the base pointer is available
first.

The code would still be incorrect in the presence of aliasing. There
is the switch -polly-ignore-aliasing to explicitly allow this, but
it is hardly a justification for the additional complexity. It would
still be mostly useless because in most cases either getNextBasePtr()
has external linkage in which case the readnone nounwind attributes
cannot be derived in the translation unit itself, or is defined in the
same translation unit and gets inlined.

Reviewed By: grosser

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

llvm-svn: 297281
2017-03-08 15:14:46 +00:00
..
aliasing_parametric_simple_1.ll Remove -polly-code-generator=isl from many test cases 2015-11-21 23:05:48 +00:00
aliasing_parametric_simple_2.ll Remove -polly-code-generator=isl from many test cases 2015-11-21 23:05:48 +00:00
aliasing_simple_1.ll Remove -polly-code-generator=isl from many test cases 2015-11-21 23:05:48 +00:00
aliasing_simple_2.ll Remove -polly-code-generator=isl from many test cases 2015-11-21 23:05:48 +00:00
base_pointer.ll [ScopDetection] Only allow SCoP-wide available base pointers. 2017-03-08 15:14:46 +00:00
base_pointer_is_inst_inside_invariant_1___%for.i---%exit.jscop [ScopDetection] Only allow SCoP-wide available base pointers. 2017-03-08 15:14:46 +00:00
base_pointer_load_is_inst_inside_invariant_1___%for.i---%exit.jscop [ScopDetection] Require LoadInst base pointers to be hoisted. 2017-03-07 20:28:43 +00:00
base_pointer_load_setNewAccessRelation.ll [ScopDetection] Require LoadInst base pointers to be hoisted. 2017-03-07 20:28:43 +00:00
base_pointer_setNewAccessRelation.ll [ScopDetection] Only allow SCoP-wide available base pointers. 2017-03-08 15:14:46 +00:00
cross_loop_non_single_exit.ll tests: Drop -polly-detect-unprofitable and -polly-no-early-exit 2015-10-06 15:36:44 +00:00
cross_loop_non_single_exit_2.ll tests: Drop -polly-detect-unprofitable and -polly-no-early-exit 2015-10-06 15:36:44 +00:00
dependency_to_phi_node_outside_of_region.ll tests: Drop -polly-detect-unprofitable and -polly-no-early-exit 2015-10-06 15:36:44 +00:00
dot-scops.ll [ScopDetect] Depend transitively on ScalarEvolution. 2016-10-17 13:29:20 +00:00
error-block-always-executed.ll Remove -polly-code-generator=isl from many test cases 2015-11-21 23:05:48 +00:00
error-block-referenced-from-scop.ll Remove -polly-code-generator=isl from many test cases 2015-11-21 23:05:48 +00:00
expand-region-correctly-2.ll tests: Add test cases for LLVM commit r251267 2015-10-25 22:56:42 +00:00
expand-region-correctly.ll tests: Add test cases for LLVM commit r251267 2015-10-25 22:56:42 +00:00
index_from_unpredictable_loop.ll test: add more details to non-affine test case 2016-11-22 06:28:08 +00:00
indvars.ll tests: Drop -polly-detect-unprofitable and -polly-no-early-exit 2015-10-06 15:36:44 +00:00
intrinsics_1.ll tests: Drop -polly-detect-unprofitable and -polly-no-early-exit 2015-10-06 15:36:44 +00:00
intrinsics_2.ll tests: Drop -polly-detect-unprofitable and -polly-no-early-exit 2015-10-06 15:36:44 +00:00
intrinsics_3.ll tests: Drop -polly-detect-unprofitable and -polly-no-early-exit 2015-10-06 15:36:44 +00:00
invalid-latch-conditions.ll Introduce -polly-process-unprofitable 2015-10-06 16:10:29 +00:00
invalidate_scalar_evolution.ll tests: Drop -polly-detect-unprofitable and -polly-no-early-exit 2015-10-06 15:36:44 +00:00
keep_going_expansion.ll tests: Drop -polly-detect-unprofitable and -polly-no-early-exit 2015-10-06 15:36:44 +00:00
mod_ref_read_pointer.ll Add option to disallow modref function calls in scops. 2016-03-23 06:40:15 +00:00
more-than-one-loop.ll Remove -polly-code-generator=isl from many test cases 2015-11-21 23:05:48 +00:00
multidim-with-undef-size.ll ScopDetection: Always refuse multi-dimensional memory accesses with 'undef' in 2015-10-25 08:40:38 +00:00
multidim.ll ScopDetection: Do not crash if we find zero array size candidates for delinearization 2015-10-25 08:40:44 +00:00
multidim_indirect_access.ll tests: Drop -polly-detect-unprofitable and -polly-no-early-exit 2015-10-06 15:36:44 +00:00
multidim_two_accesses_different_delinearization.ll Drop explicit -polly-delinearize parameter 2016-03-23 13:21:02 +00:00
nested_loop_single_exit.ll tests: Drop -polly-detect-unprofitable and -polly-no-early-exit 2015-10-06 15:36:44 +00:00
non-affine-conditional.ll tests: Drop -polly-detect-unprofitable and -polly-no-early-exit 2015-10-06 15:36:44 +00:00
non-affine-float-compare.ll tests: Drop -polly-detect-unprofitable and -polly-no-early-exit 2015-10-06 15:36:44 +00:00
non-affine-loop-condition-dependent-access.ll Allow invariant loads in the SCoP description 2015-10-07 20:17:36 +00:00
non-affine-loop-condition-dependent-access_2.ll tests: Drop -polly-detect-unprofitable and -polly-no-early-exit 2015-10-06 15:36:44 +00:00
non-affine-loop-condition-dependent-access_3.ll tests: Drop -polly-detect-unprofitable and -polly-no-early-exit 2015-10-06 15:36:44 +00:00
non-affine-loop.ll Introduce -polly-process-unprofitable 2015-10-06 16:10:29 +00:00
non-beneficial-loops-small-trip-count.ll Introduce -polly-process-unprofitable 2015-10-06 16:10:29 +00:00
non-constant-add-rec-start-expr.ll [ScopDetect] Do not assert in case of AddRecs with non-constant start expression 2016-08-15 20:59:30 +00:00
non-simple-memory-accesses.ll ScopDetect: Bail out for non-simple memory accesses 2015-10-25 13:48:40 +00:00
non_affine_loop_condition.ll Introduce -polly-process-unprofitable 2015-10-06 16:10:29 +00:00
only-one-affine-loop.ll Weaken profitability constraints during ScopDetection 2016-05-10 14:42:30 +00:00
parametric-multiply-in-scev-2.ll Allow invariant loads in the SCoP description 2015-10-07 20:17:36 +00:00
parametric-multiply-in-scev.ll tests: Drop -polly-detect-unprofitable and -polly-no-early-exit 2015-10-06 15:36:44 +00:00
phi_with_multi_exiting_edges.ll tests: Drop -polly-detect-unprofitable and -polly-no-early-exit 2015-10-06 15:36:44 +00:00
profitability-large-basic-blocks.ll Add option to assume single-loop scops with sufficient compute are profitable 2015-12-21 21:00:43 +00:00
remove_all_children.ll tests: Drop -polly-detect-unprofitable and -polly-no-early-exit 2015-10-06 15:36:44 +00:00
report-scop-location.ll Update debug metadata after LLVM commits r266445+r266446 2016-04-15 20:51:27 +00:00
restrict-undef-size-scopdetect.ll Do not detect scops that are delinearized to arrays with "undef" size 2015-07-29 13:52:05 +00:00
run_time_alias_check.ll Remove -polly-code-generator=isl from many test cases 2015-11-21 23:05:48 +00:00
scev_remove_max.ll Fix of a comment. 2015-12-17 20:47:10 +00:00
sequential_loops.ll tests: Drop -polly-detect-unprofitable and -polly-no-early-exit 2015-10-06 15:36:44 +00:00
simple_loop.ll tests: Drop -polly-detect-unprofitable and -polly-no-early-exit 2015-10-06 15:36:44 +00:00
simple_loop_non_single_entry.ll Do not enforce lcssa 2015-11-21 17:00:02 +00:00
simple_loop_non_single_exit.ll tests: Drop -polly-detect-unprofitable and -polly-no-early-exit 2015-10-06 15:36:44 +00:00
simple_loop_non_single_exit_2.ll tests: Drop -polly-detect-unprofitable and -polly-no-early-exit 2015-10-06 15:36:44 +00:00
simple_loop_two_phi_nodes.ll tests: Drop -polly-detect-unprofitable and -polly-no-early-exit 2015-10-06 15:36:44 +00:00
simple_loop_with_param.ll tests: Drop -polly-detect-unprofitable and -polly-no-early-exit 2015-10-06 15:36:44 +00:00
simple_loop_with_param_2.ll tests: Drop -polly-detect-unprofitable and -polly-no-early-exit 2015-10-06 15:36:44 +00:00
simple_non_single_entry.ll tests: Drop -polly-detect-unprofitable and -polly-no-early-exit 2015-10-06 15:36:44 +00:00
skip_function_attribute.ll tests: Drop -polly-detect-unprofitable and -polly-no-early-exit 2015-10-06 15:36:44 +00:00
srem_with_parametric_divisor.ll Add support for srem instruction 2015-06-24 04:13:29 +00:00
statistics.ll [ScopDetection] Compute the maximal loop depth correctly 2017-02-17 08:08:54 +00:00
switch-in-loop-patch.ll Do not allow switch statements in loop latches 2016-11-10 05:20:29 +00:00