[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / polly / test / DependenceInfo / nonaffine-condition-buildMemoryAccess.ll
blob25c7e3d6e442205ad1f780843937fc0384a6efd8
1 ; RUN: opt %loadPolly -polly-codegen -polly-allow-nonaffine-loops -polly-allow-nonaffine -debug-only=polly-dependence < %s 2>&1 | FileCheck %s
2 ; REQUIRES: asserts
4 ; CHECK:        MayWriteAccess :=   [Reduction Type: NONE] [Scalar: 0]
5 ; CHECK-NEXT:       { Stmt_for_body__TO__for_inc11[i0] -> MemRef_A[o0] : 0 <= o0 <= 699 };
6 ; CHECK-NEXT:   MayWriteAccess :=   [Reduction Type: NONE] [Scalar: 0]
7 ; CHECK-NEXT:       { Stmt_for_body__TO__for_inc11[i0] -> MemRef_B[700] };
9 ; The if condition C[i] is a non-affine condition, which make the nested loop boxed. The memory access for A should be a range A[0...699]. The memory access for B should be simplified to B[700].
11 ; int A[1000], B[1000], C[1000];
13 ; void foo(int n, int m, int N) {
14 ;   for (int i = 0; i < 500; i+=1) { /* affine loop */
15 ;      C[i] += i;
16 ;      if (C[i]) { /* non-affine subregion */
17 ;          int j;
18 ;          for (j = 0; j < 700; j+=1) { /* boxed loop */
19 ;            A[j] = 1;
20 ;          }
21 ;          B[j] = 2;
22 ;      }
23 ;    }
24 ; }
27 target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
29 @C = common global [1000 x i32] zeroinitializer, align 4
30 @A = common global [1000 x i32] zeroinitializer, align 4
31 @B = common global [1000 x i32] zeroinitializer, align 4
33 ; Function Attrs: norecurse nounwind
34 define void @foo(i32 %n, i32 %m, i32 %N) #0 {
35 entry:
36   br label %entry.split
38 entry.split:                                      ; preds = %entry
39   br label %for.body
41 for.cond.cleanup:                                 ; preds = %for.inc11
42   ret void
44 for.body:                                         ; preds = %for.inc11, %entry.split
45   %indvars.iv25 = phi i64 [ 0, %entry.split ], [ %indvars.iv.next26, %for.inc11 ]
46   %arrayidx = getelementptr inbounds [1000 x i32], ptr @C, i64 0, i64 %indvars.iv25
47   %0 = load i32, ptr %arrayidx, align 4
48   %1 = trunc i64 %indvars.iv25 to i32
49   %add = add nsw i32 %0, %1
50   store i32 %add, ptr %arrayidx, align 4
51   %tobool = icmp eq i32 %add, 0
52   br i1 %tobool, label %for.inc11, label %for.body5.preheader
54 for.body5.preheader:                              ; preds = %for.body
55   br label %for.body5
57 for.body5:                                        ; preds = %for.body5.preheader, %for.body5
58   %indvars.iv = phi i64 [ %indvars.iv.next, %for.body5 ], [ 0, %for.body5.preheader ]
59   %arrayidx7 = getelementptr inbounds [1000 x i32], ptr @A, i64 0, i64 %indvars.iv
60   store i32 1, ptr %arrayidx7, align 4
61   %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
62   %exitcond = icmp eq i64 %indvars.iv, 699
63   br i1 %exitcond, label %for.end, label %for.body5
65 for.end:                                          ; preds = %for.body5
66   store i32 2, ptr getelementptr inbounds ([1000 x i32], ptr @B, i64 0, i64 700), align 4
67   br label %for.inc11
69 for.inc11:                                        ; preds = %for.body, %for.end
70   %indvars.iv.next26 = add nuw nsw i64 %indvars.iv25, 1
71   %exitcond27 = icmp eq i64 %indvars.iv25, 499
72   br i1 %exitcond27, label %for.cond.cleanup, label %for.body