llvm-project/polly/test/ScopInfo/multidim_fold_constant_dim_...

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

60 lines
2.4 KiB
LLVM
Raw Normal View History

; RUN: opt %loadPolly -polly-stmt-granularity=bb -polly-scops -analyze -debug -S < %s 2>&1 | FileCheck %s
; REQUIRES: asserts
; This test case at some point crashed Polly due to a 'division by zero'
; when trying to fold the constant dimension into outer dimension.
; We verify that this scop is detected without crash. We also test the
; output to undertand that the scop has been analyzed, but has also been
; invalidated due to the zero size dimension.
; CHECK: Assumed Context:
; CHECK-NEXT: { : false }
; CHECK-NEXT: Invalid Context:
; CHECK-NEXT: { : false }
[Polly] Track defined behavior for PHI predecessor computation. ZoneAlgorithms's computePHI relies on being provided with consistent a schedule to compute the statement prodecessors of a statement containing PHINodes. Otherwise unexpected results such as PHI nodes with multiple predecessors can occur which would result in problems in the algorithms expecting consistent data. In the added test case, statement instances are scrubbed from the SCoP their execution would result in undefined behavior (Due to a nsw overflow). As already being undefined behavior in LLVM-IR, neither AssumedContext nor InvalidContext are updated, giving computePHI no means to avoid these cases. Intoduce a new SCoP property, the DefinedBehaviorContext, that among the runtime-checked conditions, also tracks the assumptions not needing a runtime check, in particular those affecting the assumed control flow. This replaces the manual combination of the 3 other contexts that was already done in computePHI and setNewAccessRelation. Currently, the only additional assumption is that loop induction variables will nsw flag for not wrap, but potentially more can be added. Use in hasFeasibleRuntimeContext, isl::ast_build and gisting are other potential uses. To limit computational complexity, the DefinedBehaviorContext is not availabe if it grows too large (atm hardcoded to 8 disjuncts). Possible other fixes include bailing out in computePHI when inconsistencies are detected, choose an arbitrary value for inconsistent cases (since it is undefined behavior anyways), or make the code receiving the result from ComputePHI handle inconsistent data. All of them reduce the quality of implementation having to bail out more often and disabling the ability to assert on actually wrong results. This fixes llvm.org/PR48783.
2021-01-22 11:20:53 +08:00
; CHECK: Arrays {
; CHECK-NEXT: i8 MemRef_arg[*][0]; // Element size 1
; CHECK-NEXT: }
; CHECK-NEXT: Arrays (Bounds as pw_affs) {
; CHECK-NEXT: i8 MemRef_arg[*][ { [] -> [(0)] } ]; // Element size 1
; CHECK-NEXT: }
; CHECK-NEXT: Alias Groups (0):
; CHECK-NEXT: n/a
; CHECK-NEXT: Statements {
; CHECK-NEXT: Stmt_bb2
; CHECK-NEXT: Domain :=
; CHECK-NEXT: { Stmt_bb2[] };
; CHECK-NEXT: Schedule :=
; CHECK-NEXT: { Stmt_bb2[] -> [] };
; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
; CHECK-NEXT: { Stmt_bb2[] -> MemRef_arg[0, 0] };
; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
; CHECK-NEXT: { Stmt_bb2[] -> MemRef_arg[o0, o1] : false };
; CHECK-NEXT: }
target datalayout = "e-p:64:64:64-S128-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f16:16:16-f32:32:32-f64:64:64-f128:128:128-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i32, i1) #0
define void @hoge([0 x [0 x i8]]* noalias %arg) {
bb:
br label %bb1
bb1: ; preds = %bb5, %bb
br i1 false, label %bb5, label %bb2
bb2: ; preds = %bb1
%tmp = getelementptr [0 x [0 x i8]], [0 x [0 x i8]]* %arg, i64 0, i64 0, i64 0
store i8 32, i8* %tmp, align 1
%tmp3 = getelementptr [0 x [0 x i8]], [0 x [0 x i8]]* %arg, i64 0, i64 0, i64 0
%tmp4 = getelementptr i8, i8* %tmp3, i64 1
tail call void @llvm.memset.p0i8.i64(i8* %tmp4, i8 32, i64 0, i32 1, i1 false)
br label %bb5
bb5: ; preds = %bb2, %bb1
br i1 undef, label %bb6, label %bb1
bb6: ; preds = %bb5
ret void
}