brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.1 KiB · e71c515 Raw
196 lines · plain
1; RUN: opt %loadNPMPolly -aa-pipeline=basic-aa '-passes=polly-custom<scops>' -polly-print-scops -disable-output < %s 2>&1 | FileCheck %s2; RUN: opt %loadNPMPolly -aa-pipeline=basic-aa '-passes=polly-custom<scops>' -polly-print-scops -disable-output < %s 2>&1 | FileCheck %s3 4; ModuleID = 'scalar_to_array.ll'5target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"6 7@A = common global [1024 x float] zeroinitializer, align 88 9; Terminating loops without side-effects will be optimized away, hence10; detecting a scop would be pointless.11; CHECK-NOT: Function: empty12; Function Attrs: nounwind13define i32 @empty() #0 {14entry:15  fence seq_cst16  br label %for.cond17 18for.cond:                                         ; preds = %for.inc, %entry19  %indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %entry ]20  %exitcond = icmp ne i64 %indvar, 102421  br i1 %exitcond, label %for.body, label %return22 23for.body:                                         ; preds = %for.cond24  br label %for.inc25 26for.inc:                                          ; preds = %for.body27  %indvar.next = add i64 %indvar, 128  br label %for.cond29 30return:                                           ; preds = %for.cond31  fence seq_cst32  ret i32 033}34 35; CHECK-LABEL: Function: array_access36; Function Attrs: nounwind37define i32 @array_access() #0 {38entry:39  fence seq_cst40  br label %for.cond41 42for.cond:                                         ; preds = %for.inc, %entry43  %indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %entry ]44  %exitcond = icmp ne i64 %indvar, 102445  br i1 %exitcond, label %for.body, label %return46 47for.body:                                         ; preds = %for.cond48  %arrayidx = getelementptr [1024 x float], ptr @A, i64 0, i64 %indvar49  %float = uitofp i64 %indvar to float50  store float %float, ptr %arrayidx51  br label %for.inc52; CHECK:     Stmt_for_body53; CHECK-NOT:     ReadAccess54; CHECK:         MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 0]55; CHECK-NEXT:        { Stmt_for_body[i0] -> MemRef_A[i0] };56 57for.inc:                                          ; preds = %for.body58  %indvar.next = add i64 %indvar, 159  br label %for.cond60 61return:                                           ; preds = %for.cond62  fence seq_cst63  ret i32 064}65 66; Function Attrs: nounwind67; CHECK-LABEL: Function: intra_scop_dep68define i32 @intra_scop_dep() #0 {69entry:70  fence seq_cst71  br label %for.cond72 73for.cond:                                         ; preds = %for.inc, %entry74  %indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %entry ]75  %exitcond = icmp ne i64 %indvar, 102476  br i1 %exitcond, label %for.body.a, label %return77 78for.body.a:                                       ; preds = %for.cond79  %arrayidx = getelementptr [1024 x float], ptr @A, i64 0, i64 %indvar80  %scalar = load float, ptr %arrayidx81  br label %for.body.b82; CHECK:      Stmt_for_body_a83; CHECK:          ReadAccess :=       [Reduction Type: NONE] [Scalar: 0]84; CHECK-NEXT:         { Stmt_for_body_a[i0] -> MemRef_A[i0] };85; CHECK:          MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 1]86; CHECK-NEXT:         { Stmt_for_body_a[i0] -> MemRef_scalar[] };87 88for.body.b:                                       ; preds = %for.body.a89  %arrayidx2 = getelementptr [1024 x float], ptr @A, i64 0, i64 %indvar90  %float = uitofp i64 %indvar to float91  %sum = fadd float %scalar, %float92  store float %sum, ptr %arrayidx293  br label %for.inc94; CHECK:      Stmt_for_body_b95; CHECK:          ReadAccess :=       [Reduction Type: NONE] [Scalar: 1]96; CHECK-NEXT:          { Stmt_for_body_b[i0] -> MemRef_scalar[] };97; CHECK:          MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 0]98; CHECK-NEXT:         { Stmt_for_body_b[i0] -> MemRef_A[i0] };99 100for.inc:                                          ; preds = %for.body.b101  %indvar.next = add i64 %indvar, 1102  br label %for.cond103 104return:                                           ; preds = %for.cond105  fence seq_cst106  ret i32 0107}108 109; It is not possible to have a scop which accesses a scalar element that is110; a global variable. All global variables are pointers containing possibly111; a single element. Hence they do not need to be handled anyways.112; Please note that this is still required when scalar to array rewriting is113; disabled.114 115; CHECK-LABEL: Function: use_after_scop116; Function Attrs: nounwind117define i32 @use_after_scop() #0 {118entry:119  %scalar.s2a = alloca float120  fence seq_cst121  br label %for.head122 123for.head:                                         ; preds = %for.inc, %entry124  %indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %entry ]125  br label %for.body126 127for.body:                                         ; preds = %for.head128  %arrayidx = getelementptr [1024 x float], ptr @A, i64 0, i64 %indvar129  %scalar = load float, ptr %arrayidx130  store float %scalar, ptr %scalar.s2a131; Escaped uses are still required to be rewritten to stack variable.132; CHECK:      Stmt_for_body133; CHECK:          ReadAccess :=       [Reduction Type: NONE] [Scalar: 0]134; CHECK-NEXT:         { Stmt_for_body[i0] -> MemRef_A[i0] };135; CHECK:          MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 0]136; CHECK-NEXT:         { Stmt_for_body[i0] -> MemRef_scalar_s2a[0] };137  br label %for.inc138 139for.inc:                                          ; preds = %for.body140  %indvar.next = add i64 %indvar, 1141  %exitcond = icmp ne i64 %indvar.next, 1024142  br i1 %exitcond, label %for.head, label %for.after143 144for.after:                                        ; preds = %for.inc145  %scalar.loadoutside = load float, ptr %scalar.s2a146  fence seq_cst147  %return_value = fptosi float %scalar.loadoutside to i32148  br label %return149 150return:                                           ; preds = %for.after151  ret i32 %return_value152}153 154; We currently do not transform scalar references, that have only read accesses155; in the scop. There are two reasons for this:156;157;  o We don't introduce additional memory references which may yield to compile158;    time overhead.159;  o For integer values, such a translation may block the use of scalar160;    evolution on those values.161;162; CHECK-LABEL: Function: before_scop163; Function Attrs: nounwind164define i32 @before_scop() #0 {165entry:166  br label %preheader167 168preheader:                                        ; preds = %entry169  %scalar = fadd float 4.000000e+00, 5.000000e+00170  fence seq_cst171  br label %for.cond172 173for.cond:                                         ; preds = %for.inc, %preheader174  %indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %preheader ]175  %exitcond = icmp ne i64 %indvar, 1024176  br i1 %exitcond, label %for.body, label %return177 178for.body:                                         ; preds = %for.cond179  %arrayidx = getelementptr [1024 x float], ptr @A, i64 0, i64 %indvar180  store float %scalar, ptr %arrayidx181  br label %for.inc182; CHECK:      Stmt_for_body183; CHECK:          MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 0]184; CHECK-NEXT:         { Stmt_for_body[i0] -> MemRef_A[i0] };185 186for.inc:                                          ; preds = %for.body187  %indvar.next = add i64 %indvar, 1188  br label %for.cond189 190return:                                           ; preds = %for.cond191  fence seq_cst192  ret i32 0193}194 195attributes #0 = { nounwind }196