llvm-project/polly/test/ScopDetect
Michael Kruse beffdb9daa [ScopDetect] Reject loop with multiple exit blocks.
The current statement domain derivation algorithm does not (always)
consider that different exit blocks of a loop can have different
conditions to be reached.

From the code

      for (int i = n; ; i-=2) {
        if (i <= 0) goto even;
        if (i <= 1) goto odd;
        A[i] = i;
      }
    even:
      A[0] = 42;
      return;
    odd:
      A[1] = 21;
      return;

Polly currently derives the following domains:

        Stmt_even_critedge
            Domain :=
                [n] -> { Stmt_even_critedge[] };
        Stmt_odd
            Domain :=
                [n] -> { Stmt_odd[] : (1 + n) mod 2 = 0 and n > 0 };

while the domain for the odd case is correct, Stmt_even is assumed to be
executed unconditionally, which is obviously wrong. While projecting out
the loop dimension in `adjustDomainDimensions`, it does not consider
that there are other exit condition that have matched before.

I don't know a how to fix this without changing a lot of code. Therefore
This patch rejects loops with multiple exist blocks to fix the
miscompile of test-suite's uuencode.

The odd condition is transformed by LLVM to

    %cmp1 = icmp eq i64 %indvars.iv, 1

such that the project_out in adjustDomainDimensions() indeed only
matches for odd n (using this condition only, we'd have an infinite loop
otherwise).

The even condition manifests as

    %cmp = icmp slt i64 %indvars.iv, 3

Because buildDomainsWithBranchConstraints() does not consider other exit
conditions, it has to assume that the induction variable will eventually
be lower than 3 and taking this exit.

IMHO we need to reuse the algorithm that determines the number of
iterations (addLoopBoundsToHeaderDomain) to determine which exit
condition applies first. It has to happen in
buildDomainsWithBranchConstraints() because the result will need to
propagate to successor BBs. Currently addLoopBoundsToHeaderDomain() just
look for union of all backedge conditions (which means leaving not the
loop here). The patch in llvm.org/PR35465 changes it to look for exit
conditions instead. This is required because there might be other exit
conditions that do not alternatively go back to the loop header.

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

llvm-svn: 330858
2018-04-25 18:53:33 +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 [JSON] Make the failure to parse a jscop file a hard error 2017-08-10 14:53:25 +00:00
base_pointer_load_setNewAccessRelation.ll Check whether IslAstInfo and DependenceInfo were computed for the same Scop. 2017-09-21 00:01:13 +00:00
base_pointer_setNewAccessRelation.ll [tests] Set -polly-import-jscop-dir=%S always 2017-07-11 10:39:01 +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
error-block-unreachable.ll [ScopHelper] Do not crash on unreachable blocks 2017-09-03 18:01:22 +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
ignore_func_flag_regex.ll [ScopDetect] add `-polly-ignore-func` flag to ignore functions by name. 2017-07-28 11:47:24 +00:00
index_from_unpredictable_loop.ll [ScopDetect] Reject loop with multiple exit blocks. 2018-04-25 18:53:33 +00:00
index_from_unpredictable_loop2.ll [ScopDetect] Reject loop with multiple exit blocks. 2018-04-25 18:53:33 +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
invariant-load-before-scop.ll [ScopDetect] Do not add loads out of the SCoP to required invariant loads. 2017-10-01 22:19:28 +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 Remove immediate dominator heuristic for error block detection. 2018-04-09 06:07:44 +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
only_func_flag.ll [Polly] [ScopDetection] Allow passing multiple functions to `-polly-only-func`. 2017-06-09 08:23:40 +00:00
only_func_flag_regex.ll [Polly] [NFC] [ScopDetection] Make `polly-only-func` perform regex scop name match. 2017-07-24 12:40:52 +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
profitability-two-nested-loops.ll [Detect] Consider nested loop profitable if entry block is not in loop 2017-08-27 21:39:25 +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
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
statistics.ll [ScopDetect / ScopInfo] Get statistics for scops without any loop correctly 2018-04-18 20:03:36 +00:00
switch-in-loop-patch.ll Do not allow switch statements in loop latches 2016-11-10 05:20:29 +00:00
tlr_is_hoistable_load.ll Handle Top-Level-Regions in polly::isHoistableLoad 2017-11-30 13:06:10 +00:00