[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / polly / test / CodeGen / OpenMP / invariant_base_pointer_preloaded_pass_only_needed.ll
blob49b9321c40b80593f60acffecadcd53f6b14013b
1 ; RUN: opt %loadPolly -polly-codegen -polly-invariant-load-hoisting=true -polly-parallel \
2 ; RUN: -polly-parallel-force -S < %s | FileCheck %s
4 ; Test to verify that we hand down the preloaded A[0] to the OpenMP subfunction but
5 ; not B[0] as it is not needed
7 ;    void f(float *A, float *B) {
8 ;      // Not parallel
9 ;      for (int i = 1; i < 1000; i++) {
10 ;        B[i] = B[i+1] + B[0];
11 ;        // Parallel
12 ;        for (int j = 1; j < 1000; j++)
13 ;          A[j] += A[0];
14 ;      }
15 ;    }
17 ;                                           i    A[0]    A
18 ; CHECK: %polly.par.userContext = alloca { i64, float, ptr }
20 ; CHECK:  %polly.access.B.load =
21 ; CHECK:  %polly.subfn.storeaddr.polly.access.A.load = getelementptr inbounds
22 ; CHECK:  store float %polly.access.A.load, ptr %polly.subfn.storeaddr.polly.access.A.load
23 ; CHECK-NOT:  store float %polly.access.B.load, ptr %polly.subfn.storeaddr.polly.access.B.load
25 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
27 define void @f(ptr %A, ptr %B) {
28 entry:
29   br label %for.cond
31 for.cond:                                         ; preds = %for.inc.9, %entry
32   %indvars.iv1 = phi i64 [ %indvars.iv.next2, %for.inc.9 ], [ 1, %entry ]
33   %exitcond3 = icmp ne i64 %indvars.iv1, 1000
34   br i1 %exitcond3, label %for.body, label %for.end.11
36 for.body:                                         ; preds = %for.cond
37   %tmp = load float, ptr %B, align 4
38   %arrayidx1 = getelementptr inbounds float, ptr %B, i64 %indvars.iv1
39   %iv.add = add nsw i64 %indvars.iv1, 1
40   %arrayidx2 = getelementptr inbounds float, ptr %B, i64 %iv.add
41   %tmp4 = load float, ptr %arrayidx2, align 4
42   %add = fadd float %tmp4, %tmp
43   store float %add, ptr %arrayidx1, align 4
44   br label %for.cond.2
46 for.cond.2:                                       ; preds = %for.inc, %for.body
47   %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 1, %for.body ]
48   %exitcond = icmp ne i64 %indvars.iv, 1000
49   br i1 %exitcond, label %for.body.4, label %for.end
51 for.body.4:                                       ; preds = %for.cond.2
52   %tmp5 = load float, ptr %A, align 4
53   %arrayidx7 = getelementptr inbounds float, ptr %A, i64 %indvars.iv
54   %tmp6 = load float, ptr %arrayidx7, align 4
55   %add8 = fadd float %tmp6, %tmp5
56   store float %add8, ptr %arrayidx7, align 4
57   br label %for.inc
59 for.inc:                                          ; preds = %for.body.4
60   %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
61   br label %for.cond.2
63 for.end:                                          ; preds = %for.cond.2
64   br label %for.inc.9
66 for.inc.9:                                        ; preds = %for.end
67   %indvars.iv.next2 = add nuw nsw i64 %indvars.iv1, 1
68   br label %for.cond
70 for.end.11:                                       ; preds = %for.cond
71   ret void