llvm.org GIT mirror llvm / d541e6e
in findGCD of multiply expr return the gcd we used to return 1 instead of the gcd git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205800 91177308-0d34-0410-b5e6-96231b3b80d8 Sebastian Pop 6 years ago
2 changed file(s) with 157 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
69616961 if (PartialGCD != One)
69626962 return PartialGCD;
69636963
6964 // Failed to find a PartialGCD: set the Remainder to the full expression,
6965 // and return the GCD.
69646966 Remainder = Expr;
69656967 const SCEVMulExpr *Mul = dyn_cast(GCD);
69666968 if (!Mul)
6967 return PartialGCD;
6969 return GCD;
69686970
69696971 // When the GCD is a multiply expression, try to decompose it:
69706972 // this occurs when Step does not divide the Start expression
69786980 }
69796981 }
69806982
6981 return PartialGCD;
6983 return GCD;
69826984 }
69836985
69846986 const SCEV *visitUDivExpr(const SCEVUDivExpr *Expr) {
0 ; RUN: opt < %s -basicaa -da -analyze -delinearize
1 ;
2 ; a, b, c, d, g, h;
3 ; char *f;
4 ; static fn1(p1) {
5 ; char *e = p1;
6 ; for (; d;) {
7 ; a = 0;
8 ; for (;; ++a)
9 ; for (; b; ++b)
10 ; c = e[b + a];
11 ; }
12 ; }
13 ;
14 ; fn2() {
15 ; for (;;)
16 ; fn1(&f[g * h]);
17 ; }
18
19 @g = common global i32 0, align 4
20 @h = common global i32 0, align 4
21 @f = common global i8* null, align 4
22 @a = common global i32 0, align 4
23 @b = common global i32 0, align 4
24 @c = common global i32 0, align 4
25 @d = common global i32 0, align 4
26
27 define i32 @fn2() {
28 entry:
29 %.pr = load i32* @d, align 4
30 %phitmp = icmp eq i32 %.pr, 0
31 br label %for.cond
32
33 for.cond:
34 %0 = phi i1 [ true, %for.cond ], [ %phitmp, %entry ]
35 br i1 %0, label %for.cond, label %for.cond2thread-pre-split.preheader.i
36
37 for.cond2thread-pre-split.preheader.i:
38 %1 = load i32* @g, align 4
39 %2 = load i32* @h, align 4
40 %mul = mul nsw i32 %2, %1
41 %3 = load i8** @f, align 4
42 %.pr.pre.i = load i32* @b, align 4
43 br label %for.cond2thread-pre-split.i
44
45 for.cond2thread-pre-split.i:
46 %.pr.i = phi i32 [ 0, %for.inc5.i ], [ %.pr.pre.i, %for.cond2thread-pre-split.preheader.i ]
47 %storemerge.i = phi i32 [ %inc6.i, %for.inc5.i ], [ 0, %for.cond2thread-pre-split.preheader.i ]
48 store i32 %storemerge.i, i32* @a, align 4
49 %tobool31.i = icmp eq i32 %.pr.i, 0
50 br i1 %tobool31.i, label %for.inc5.i, label %for.body4.preheader.i
51
52 for.body4.preheader.i:
53 %4 = icmp slt i32 %.pr.i, -7
54 %add.i = add i32 %storemerge.i, %mul
55 br i1 %4, label %for.body4.i.preheader, label %for.body4.ur.i.preheader
56
57 for.body4.i.preheader:
58 %5 = sub i32 -8, %.pr.i
59 %6 = lshr i32 %5, 3
60 %7 = mul i32 %6, 8
61 br label %for.body4.i
62
63 for.body4.i:
64 %8 = phi i32 [ %inc.7.i, %for.body4.i ], [ %.pr.i, %for.body4.i.preheader ]
65 %arrayidx.sum1 = add i32 %add.i, %8
66 %arrayidx.i = getelementptr inbounds i8* %3, i32 %arrayidx.sum1
67 %9 = load i8* %arrayidx.i, align 1
68 %conv.i = sext i8 %9 to i32
69 store i32 %conv.i, i32* @c, align 4
70 %inc.i = add nsw i32 %8, 1
71 store i32 %inc.i, i32* @b, align 4
72 %arrayidx.sum2 = add i32 %add.i, %inc.i
73 %arrayidx.1.i = getelementptr inbounds i8* %3, i32 %arrayidx.sum2
74 %10 = load i8* %arrayidx.1.i, align 1
75 %conv.1.i = sext i8 %10 to i32
76 store i32 %conv.1.i, i32* @c, align 4
77 %inc.1.i = add nsw i32 %8, 2
78 store i32 %inc.1.i, i32* @b, align 4
79 %arrayidx.sum3 = add i32 %add.i, %inc.1.i
80 %arrayidx.2.i = getelementptr inbounds i8* %3, i32 %arrayidx.sum3
81 %11 = load i8* %arrayidx.2.i, align 1
82 %conv.2.i = sext i8 %11 to i32
83 store i32 %conv.2.i, i32* @c, align 4
84 %inc.2.i = add nsw i32 %8, 3
85 store i32 %inc.2.i, i32* @b, align 4
86 %arrayidx.sum4 = add i32 %add.i, %inc.2.i
87 %arrayidx.3.i = getelementptr inbounds i8* %3, i32 %arrayidx.sum4
88 %12 = load i8* %arrayidx.3.i, align 1
89 %conv.3.i = sext i8 %12 to i32
90 store i32 %conv.3.i, i32* @c, align 4
91 %inc.3.i = add nsw i32 %8, 4
92 store i32 %inc.3.i, i32* @b, align 4
93 %arrayidx.sum5 = add i32 %add.i, %inc.3.i
94 %arrayidx.4.i = getelementptr inbounds i8* %3, i32 %arrayidx.sum5
95 %13 = load i8* %arrayidx.4.i, align 1
96 %conv.4.i = sext i8 %13 to i32
97 store i32 %conv.4.i, i32* @c, align 4
98 %inc.4.i = add nsw i32 %8, 5
99 store i32 %inc.4.i, i32* @b, align 4
100 %arrayidx.sum6 = add i32 %add.i, %inc.4.i
101 %arrayidx.5.i = getelementptr inbounds i8* %3, i32 %arrayidx.sum6
102 %14 = load i8* %arrayidx.5.i, align 1
103 %conv.5.i = sext i8 %14 to i32
104 store i32 %conv.5.i, i32* @c, align 4
105 %inc.5.i = add nsw i32 %8, 6
106 store i32 %inc.5.i, i32* @b, align 4
107 %arrayidx.sum7 = add i32 %add.i, %inc.5.i
108 %arrayidx.6.i = getelementptr inbounds i8* %3, i32 %arrayidx.sum7
109 %15 = load i8* %arrayidx.6.i, align 1
110 %conv.6.i = sext i8 %15 to i32
111 store i32 %conv.6.i, i32* @c, align 4
112 %inc.6.i = add nsw i32 %8, 7
113 store i32 %inc.6.i, i32* @b, align 4
114 %arrayidx.sum8 = add i32 %add.i, %inc.6.i
115 %arrayidx.7.i = getelementptr inbounds i8* %3, i32 %arrayidx.sum8
116 %16 = load i8* %arrayidx.7.i, align 1
117 %conv.7.i = sext i8 %16 to i32
118 store i32 %conv.7.i, i32* @c, align 4
119 %inc.7.i = add nsw i32 %8, 8
120 store i32 %inc.7.i, i32* @b, align 4
121 %tobool3.7.i = icmp sgt i32 %inc.7.i, -8
122 br i1 %tobool3.7.i, label %for.inc5.loopexit.ur-lcssa.i, label %for.body4.i
123
124 for.inc5.loopexit.ur-lcssa.i:
125 %17 = add i32 %.pr.i, 8
126 %18 = add i32 %17, %7
127 %19 = icmp eq i32 %18, 0
128 br i1 %19, label %for.inc5.i, label %for.body4.ur.i.preheader
129
130 for.body4.ur.i.preheader:
131 %.ph = phi i32 [ %18, %for.inc5.loopexit.ur-lcssa.i ], [ %.pr.i, %for.body4.preheader.i ]
132 br label %for.body4.ur.i
133
134 for.body4.ur.i:
135 %20 = phi i32 [ %inc.ur.i, %for.body4.ur.i ], [ %.ph, %for.body4.ur.i.preheader ]
136 %arrayidx.sum = add i32 %add.i, %20
137 %arrayidx.ur.i = getelementptr inbounds i8* %3, i32 %arrayidx.sum
138 %21 = load i8* %arrayidx.ur.i, align 1
139 %conv.ur.i = sext i8 %21 to i32
140 store i32 %conv.ur.i, i32* @c, align 4
141 %inc.ur.i = add nsw i32 %20, 1
142 store i32 %inc.ur.i, i32* @b, align 4
143 %tobool3.ur.i = icmp eq i32 %inc.ur.i, 0
144 br i1 %tobool3.ur.i, label %for.inc5.i.loopexit, label %for.body4.ur.i
145
146 for.inc5.i.loopexit:
147 br label %for.inc5.i
148
149 for.inc5.i:
150 %inc6.i = add nsw i32 %storemerge.i, 1
151 br label %for.cond2thread-pre-split.i
152 }