2 ; RUN: opt < %s -analyze -enable-new-pm=0 -delinearize -debug 2>&1 | FileCheck %s
3 ; RUN: opt < %s -passes='print<delinearization>' -disable-output -debug 2>&1 2>&1 | FileCheck %s
4 ; void foo (int m, int n, char *A) {
5 ; for (int i=0; i < m; i++)
6 ; for(int j=0; j< n; j++)
10 ; ModuleID = 'delin.cpp'
11 ;target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
12 ;target triple = "aarch64--linux-gnu"
14 ; CHECK-LABEL: Delinearization on function foo
15 ; CHECK: Inst: %4 = load i8, i8* %arrayidx.us, align 1
17 ; CHECK-NEXT: {0,+,1}<nuw><nsw><%for.body3.lr.ph.us>
18 ; CHECK-NEXT: {0,+,1}<nuw><nsw><%for.body3.us>
19 ; CHECK: succeeded to delinearize
21 define void @foo(i32 %m, i32 %n, i8* nocapture %A) #0 {
25 entry.split: ; preds = %entry
26 %cmp15 = icmp sgt i32 %m, 0
27 %cmp213 = icmp sgt i32 %n, 0
28 %or.cond = and i1 %cmp15, %cmp213
29 br i1 %or.cond, label %for.cond1.preheader.lr.ph.split.us, label %for.end8
31 for.cond1.preheader.lr.ph.split.us: ; preds = %entry.split
33 %1 = sext i32 %n to i64
35 br label %for.body3.lr.ph.us
37 for.body3.us: ; preds = %for.body3.us, %for.body3.lr.ph.us
38 %indvars.iv = phi i64 [ 0, %for.body3.lr.ph.us ], [ %indvars.iv.next, %for.body3.us ]
39 %3 = add nsw i64 %indvars.iv, %5
40 %arrayidx.us = getelementptr inbounds i8, i8* %A, i64 %3
41 %4 = load i8, i8* %arrayidx.us, align 1
42 %add4.us = add i8 %4, 1
43 store i8 %add4.us, i8* %arrayidx.us, align 1
44 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
45 %lftr.wideiv = trunc i64 %indvars.iv to i32
46 %exitcond = icmp eq i32 %lftr.wideiv, %0
47 br i1 %exitcond, label %for.cond1.for.inc6_crit_edge.us, label %for.body3.us
49 for.body3.lr.ph.us: ; preds = %for.cond1.for.inc6_crit_edge.us, %for.cond1.preheader.lr.ph.split.us
50 %indvars.iv19 = phi i64 [ %indvars.iv.next20, %for.cond1.for.inc6_crit_edge.us ], [ 0, %for.cond1.preheader.lr.ph.split.us ]
51 %5 = mul nsw i64 %indvars.iv19, %1
52 br label %for.body3.us
54 for.cond1.for.inc6_crit_edge.us: ; preds = %for.body3.us
55 %indvars.iv.next20 = add nuw nsw i64 %indvars.iv19, 1
56 %lftr.wideiv22 = trunc i64 %indvars.iv19 to i32
57 %exitcond23 = icmp eq i32 %lftr.wideiv22, %2
58 br i1 %exitcond23, label %for.end8.loopexit, label %for.body3.lr.ph.us
60 for.end8.loopexit: ; preds = %for.cond1.for.inc6_crit_edge.us
63 for.end8: ; preds = %for.end8.loopexit, %entry.split