llvm.org GIT mirror llvm / a00e39f
[SCEV] Consider delinearization pattern with extension with identity factor Summary: The delinearization algorithm did not consider terms which had an extension without a multiply factor, i.e. a identify factor. We lose cases where size is char type where there will no multiply factor. Reviewers: sanjoy, grosser Subscribers: mzolotukhin, Eugene.Zelenko, llvm-commits, mssimpso, sanjoy, grosser Differential Revision: https://reviews.llvm.org/D16492 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284378 91177308-0d34-0410-b5e6-96231b3b80d8 Tobias Grosser 4 years ago
2 changed file(s) with 66 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
89478947 : Terms(T) {}
89488948
89498949 bool follow(const SCEV *S) {
8950 if (isa(S) || isa(S)) {
8950 if (isa(S) || isa(S) ||
8951 isa(S)) {
89518952 if (!containsUndefs(S))
89528953 Terms.push_back(S);
89538954
0 ; REQUIRES: asserts
1 ; RUN: opt < %s -analyze -delinearize -debug 2>&1 | FileCheck %s
2 ; void foo (int m, int n, char *A) {
3 ; for (int i=0; i < m; i++)
4 ; for(int j=0; j< n; j++)
5 ; A[i*n+j] += 1;
6 ;}
7
8 ; ModuleID = 'delin.cpp'
9 ;target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
10 ;target triple = "aarch64--linux-gnu"
11
12 ; CHECK-LABEL: Delinearization on function foo
13 ; CHECK: Inst: %4 = load i8, i8* %arrayidx.us, align 1
14 ; CHECK: Subscripts
15 ; CHECK-NEXT: {0,+,1}<%for.body3.lr.ph.us>
16 ; CHECK-NEXT: {0,+,1}<%for.body3.us>
17 ; CHECK: succeeded to delinearize
18
19 define void @foo(i32 %m, i32 %n, i8* nocapture %A) #0 {
20 entry:
21 br label %entry.split
22
23 entry.split: ; preds = %entry
24 %cmp15 = icmp sgt i32 %m, 0
25 %cmp213 = icmp sgt i32 %n, 0
26 %or.cond = and i1 %cmp15, %cmp213
27 br i1 %or.cond, label %for.cond1.preheader.lr.ph.split.us, label %for.end8
28
29 for.cond1.preheader.lr.ph.split.us: ; preds = %entry.split
30 %0 = add i32 %n, -1
31 %1 = sext i32 %n to i64
32 %2 = add i32 %m, -1
33 br label %for.body3.lr.ph.us
34
35 for.body3.us: ; preds = %for.body3.us, %for.body3.lr.ph.us
36 %indvars.iv = phi i64 [ 0, %for.body3.lr.ph.us ], [ %indvars.iv.next, %for.body3.us ]
37 %3 = add nsw i64 %indvars.iv, %5
38 %arrayidx.us = getelementptr inbounds i8, i8* %A, i64 %3
39 %4 = load i8, i8* %arrayidx.us, align 1
40 %add4.us = add i8 %4, 1
41 store i8 %add4.us, i8* %arrayidx.us, align 1
42 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
43 %lftr.wideiv = trunc i64 %indvars.iv to i32
44 %exitcond = icmp eq i32 %lftr.wideiv, %0
45 br i1 %exitcond, label %for.cond1.for.inc6_crit_edge.us, label %for.body3.us
46
47 for.body3.lr.ph.us: ; preds = %for.cond1.for.inc6_crit_edge.us, %for.cond1.preheader.lr.ph.split.us
48 %indvars.iv19 = phi i64 [ %indvars.iv.next20, %for.cond1.for.inc6_crit_edge.us ], [ 0, %for.cond1.preheader.lr.ph.split.us ]
49 %5 = mul nsw i64 %indvars.iv19, %1
50 br label %for.body3.us
51
52 for.cond1.for.inc6_crit_edge.us: ; preds = %for.body3.us
53 %indvars.iv.next20 = add nuw nsw i64 %indvars.iv19, 1
54 %lftr.wideiv22 = trunc i64 %indvars.iv19 to i32
55 %exitcond23 = icmp eq i32 %lftr.wideiv22, %2
56 br i1 %exitcond23, label %for.end8.loopexit, label %for.body3.lr.ph.us
57
58 for.end8.loopexit: ; preds = %for.cond1.for.inc6_crit_edge.us
59 br label %for.end8
60
61 for.end8: ; preds = %for.end8.loopexit, %entry.split
62 ret void
63 }