SymbolicSIV.ll 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. ; RUN: opt < %s -analyze -basicaa -da | FileCheck %s
  2. ; ModuleID = 'SymbolicSIV.bc'
  3. target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
  4. target triple = "x86_64-apple-macosx10.6.0"
  5. ;; for (long int i = 0; i < n; i++) {
  6. ;; A[2*i + n] = i;
  7. ;; *B++ = A[3*i + 3*n];
  8. define void @symbolicsiv0(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
  9. entry:
  10. %cmp1 = icmp eq i64 %n, 0
  11. br i1 %cmp1, label %for.end, label %for.body.preheader
  12. ; CHECK: da analyze - none!
  13. ; CHECK: da analyze - none!
  14. ; CHECK: da analyze - confused!
  15. ; CHECK: da analyze - none!
  16. ; CHECK: da analyze - confused!
  17. ; CHECK: da analyze - none!
  18. for.body.preheader: ; preds = %entry
  19. br label %for.body
  20. for.body: ; preds = %for.body.preheader, %for.body
  21. %i.03 = phi i64 [ %inc, %for.body ], [ 0, %for.body.preheader ]
  22. %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %for.body.preheader ]
  23. %conv = trunc i64 %i.03 to i32
  24. %mul = shl nsw i64 %i.03, 1
  25. %add = add i64 %mul, %n
  26. %arrayidx = getelementptr inbounds i32, i32* %A, i64 %add
  27. store i32 %conv, i32* %arrayidx, align 4
  28. %mul14 = add i64 %i.03, %n
  29. %add3 = mul i64 %mul14, 3
  30. %arrayidx4 = getelementptr inbounds i32, i32* %A, i64 %add3
  31. %0 = load i32, i32* %arrayidx4, align 4
  32. %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.02, i64 1
  33. store i32 %0, i32* %B.addr.02, align 4
  34. %inc = add nsw i64 %i.03, 1
  35. %exitcond = icmp ne i64 %inc, %n
  36. br i1 %exitcond, label %for.body, label %for.end.loopexit
  37. for.end.loopexit: ; preds = %for.body
  38. br label %for.end
  39. for.end: ; preds = %for.end.loopexit, %entry
  40. ret void
  41. }
  42. ;; for (long int i = 0; i < n; i++) {
  43. ;; A[2*i + 5*n] = i;
  44. ;; *B++ = A[3*i + 2*n];
  45. define void @symbolicsiv1(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
  46. entry:
  47. %cmp1 = icmp eq i64 %n, 0
  48. br i1 %cmp1, label %for.end, label %for.body.preheader
  49. ; CHECK: da analyze - none!
  50. ; CHECK: da analyze - none!
  51. ; CHECK: da analyze - confused!
  52. ; CHECK: da analyze - none!
  53. ; CHECK: da analyze - confused!
  54. ; CHECK: da analyze - none!
  55. for.body.preheader: ; preds = %entry
  56. br label %for.body
  57. for.body: ; preds = %for.body.preheader, %for.body
  58. %i.03 = phi i64 [ %inc, %for.body ], [ 0, %for.body.preheader ]
  59. %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %for.body.preheader ]
  60. %conv = trunc i64 %i.03 to i32
  61. %mul = shl nsw i64 %i.03, 1
  62. %mul1 = mul i64 %n, 5
  63. %add = add i64 %mul, %mul1
  64. %arrayidx = getelementptr inbounds i32, i32* %A, i64 %add
  65. store i32 %conv, i32* %arrayidx, align 4
  66. %mul2 = mul nsw i64 %i.03, 3
  67. %mul3 = shl i64 %n, 1
  68. %add4 = add i64 %mul2, %mul3
  69. %arrayidx5 = getelementptr inbounds i32, i32* %A, i64 %add4
  70. %0 = load i32, i32* %arrayidx5, align 4
  71. %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.02, i64 1
  72. store i32 %0, i32* %B.addr.02, align 4
  73. %inc = add nsw i64 %i.03, 1
  74. %exitcond = icmp ne i64 %inc, %n
  75. br i1 %exitcond, label %for.body, label %for.end.loopexit
  76. for.end.loopexit: ; preds = %for.body
  77. br label %for.end
  78. for.end: ; preds = %for.end.loopexit, %entry
  79. ret void
  80. }
  81. ;; for (long int i = 0; i < n; i++) {
  82. ;; A[2*i - n] = i;
  83. ;; *B++ = A[-i + 2*n];
  84. define void @symbolicsiv2(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
  85. entry:
  86. %cmp1 = icmp eq i64 %n, 0
  87. br i1 %cmp1, label %for.end, label %for.body.preheader
  88. ; CHECK: da analyze - none!
  89. ; CHECK: da analyze - none!
  90. ; CHECK: da analyze - confused!
  91. ; CHECK: da analyze - none!
  92. ; CHECK: da analyze - confused!
  93. ; CHECK: da analyze - none!
  94. for.body.preheader: ; preds = %entry
  95. br label %for.body
  96. for.body: ; preds = %for.body.preheader, %for.body
  97. %i.03 = phi i64 [ %inc, %for.body ], [ 0, %for.body.preheader ]
  98. %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %for.body.preheader ]
  99. %conv = trunc i64 %i.03 to i32
  100. %mul = shl nsw i64 %i.03, 1
  101. %sub = sub i64 %mul, %n
  102. %arrayidx = getelementptr inbounds i32, i32* %A, i64 %sub
  103. store i32 %conv, i32* %arrayidx, align 4
  104. %mul2 = shl i64 %n, 1
  105. %add = sub i64 %mul2, %i.03
  106. %arrayidx3 = getelementptr inbounds i32, i32* %A, i64 %add
  107. %0 = load i32, i32* %arrayidx3, align 4
  108. %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.02, i64 1
  109. store i32 %0, i32* %B.addr.02, align 4
  110. %inc = add nsw i64 %i.03, 1
  111. %exitcond = icmp ne i64 %inc, %n
  112. br i1 %exitcond, label %for.body, label %for.end.loopexit
  113. for.end.loopexit: ; preds = %for.body
  114. br label %for.end
  115. for.end: ; preds = %for.end.loopexit, %entry
  116. ret void
  117. }
  118. ;; for (long int i = 0; i < n; i++) {
  119. ;; A[-2*i + n + 1] = i;
  120. ;; *B++ = A[i - 2*n];
  121. define void @symbolicsiv3(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
  122. entry:
  123. %cmp1 = icmp eq i64 %n, 0
  124. br i1 %cmp1, label %for.end, label %for.body.preheader
  125. ; CHECK: da analyze - none!
  126. ; CHECK: da analyze - none!
  127. ; CHECK: da analyze - confused!
  128. ; CHECK: da analyze - none!
  129. ; CHECK: da analyze - confused!
  130. ; CHECK: da analyze - none!
  131. for.body.preheader: ; preds = %entry
  132. br label %for.body
  133. for.body: ; preds = %for.body.preheader, %for.body
  134. %i.03 = phi i64 [ %inc, %for.body ], [ 0, %for.body.preheader ]
  135. %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %for.body.preheader ]
  136. %conv = trunc i64 %i.03 to i32
  137. %mul = mul nsw i64 %i.03, -2
  138. %add = add i64 %mul, %n
  139. %add1 = add i64 %add, 1
  140. %arrayidx = getelementptr inbounds i32, i32* %A, i64 %add1
  141. store i32 %conv, i32* %arrayidx, align 4
  142. %mul2 = shl i64 %n, 1
  143. %sub = sub i64 %i.03, %mul2
  144. %arrayidx3 = getelementptr inbounds i32, i32* %A, i64 %sub
  145. %0 = load i32, i32* %arrayidx3, align 4
  146. %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.02, i64 1
  147. store i32 %0, i32* %B.addr.02, align 4
  148. %inc = add nsw i64 %i.03, 1
  149. %exitcond = icmp ne i64 %inc, %n
  150. br i1 %exitcond, label %for.body, label %for.end.loopexit
  151. for.end.loopexit: ; preds = %for.body
  152. br label %for.end
  153. for.end: ; preds = %for.end.loopexit, %entry
  154. ret void
  155. }
  156. ;; for (long int i = 0; i < n; i++) {
  157. ;; A[-2*i + 3*n] = i;
  158. ;; *B++ = A[-i + n];
  159. define void @symbolicsiv4(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
  160. entry:
  161. %cmp1 = icmp eq i64 %n, 0
  162. br i1 %cmp1, label %for.end, label %for.body.preheader
  163. ; CHECK: da analyze - none!
  164. ; CHECK: da analyze - none!
  165. ; CHECK: da analyze - confused!
  166. ; CHECK: da analyze - none!
  167. ; CHECK: da analyze - confused!
  168. ; CHECK: da analyze - none!
  169. for.body.preheader: ; preds = %entry
  170. br label %for.body
  171. for.body: ; preds = %for.body.preheader, %for.body
  172. %i.03 = phi i64 [ %inc, %for.body ], [ 0, %for.body.preheader ]
  173. %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %for.body.preheader ]
  174. %conv = trunc i64 %i.03 to i32
  175. %mul = mul nsw i64 %i.03, -2
  176. %mul1 = mul i64 %n, 3
  177. %add = add i64 %mul, %mul1
  178. %arrayidx = getelementptr inbounds i32, i32* %A, i64 %add
  179. store i32 %conv, i32* %arrayidx, align 4
  180. %add2 = sub i64 %n, %i.03
  181. %arrayidx3 = getelementptr inbounds i32, i32* %A, i64 %add2
  182. %0 = load i32, i32* %arrayidx3, align 4
  183. %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.02, i64 1
  184. store i32 %0, i32* %B.addr.02, align 4
  185. %inc = add nsw i64 %i.03, 1
  186. %exitcond = icmp ne i64 %inc, %n
  187. br i1 %exitcond, label %for.body, label %for.end.loopexit
  188. for.end.loopexit: ; preds = %for.body
  189. br label %for.end
  190. for.end: ; preds = %for.end.loopexit, %entry
  191. ret void
  192. }
  193. ;; for (long int i = 0; i < n; i++) {
  194. ;; A[-2*i - 2*n] = i;
  195. ;; *B++ = A[-i - n];
  196. define void @symbolicsiv5(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
  197. entry:
  198. %cmp1 = icmp eq i64 %n, 0
  199. br i1 %cmp1, label %for.end, label %for.body.preheader
  200. ; CHECK: da analyze - none!
  201. ; CHECK: da analyze - none!
  202. ; CHECK: da analyze - confused!
  203. ; CHECK: da analyze - none!
  204. ; CHECK: da analyze - confused!
  205. ; CHECK: da analyze - none!
  206. for.body.preheader: ; preds = %entry
  207. br label %for.body
  208. for.body: ; preds = %for.body.preheader, %for.body
  209. %i.03 = phi i64 [ %inc, %for.body ], [ 0, %for.body.preheader ]
  210. %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %for.body.preheader ]
  211. %conv = trunc i64 %i.03 to i32
  212. %mul = mul nsw i64 %i.03, -2
  213. %mul1 = shl i64 %n, 1
  214. %sub = sub i64 %mul, %mul1
  215. %arrayidx = getelementptr inbounds i32, i32* %A, i64 %sub
  216. store i32 %conv, i32* %arrayidx, align 4
  217. %sub2 = sub nsw i64 0, %i.03
  218. %sub3 = sub i64 %sub2, %n
  219. %arrayidx4 = getelementptr inbounds i32, i32* %A, i64 %sub3
  220. %0 = load i32, i32* %arrayidx4, align 4
  221. %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.02, i64 1
  222. store i32 %0, i32* %B.addr.02, align 4
  223. %inc = add nsw i64 %i.03, 1
  224. %exitcond = icmp ne i64 %inc, %n
  225. br i1 %exitcond, label %for.body, label %for.end.loopexit
  226. for.end.loopexit: ; preds = %for.body
  227. br label %for.end
  228. for.end: ; preds = %for.end.loopexit, %entry
  229. ret void
  230. }
  231. ;; why doesn't SCEV package understand that n >= 0?
  232. ;; for (long unsigned i = 0; i < n; i++) {
  233. ;; A[i + n + 1] = i;
  234. ;; *B++ = A[-i];
  235. define void @weaktest(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
  236. entry:
  237. %cmp1 = icmp eq i64 %n, 0
  238. br i1 %cmp1, label %for.end, label %for.body.preheader
  239. ; CHECK: da analyze - none!
  240. ; CHECK: da analyze - flow [*|<] splitable!
  241. ; CHECK: da analyze - split level = 1, iteration = ((0 smax (-1 + (-1 * %n))) /u 2)!
  242. ; CHECK: da analyze - confused!
  243. ; CHECK: da analyze - none!
  244. ; CHECK: da analyze - confused!
  245. ; CHECK: da analyze - none!
  246. for.body.preheader: ; preds = %entry
  247. br label %for.body
  248. for.body: ; preds = %for.body.preheader, %for.body
  249. %i.03 = phi i64 [ %inc, %for.body ], [ 0, %for.body.preheader ]
  250. %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %for.body.preheader ]
  251. %conv = trunc i64 %i.03 to i32
  252. %add = add i64 %i.03, %n
  253. %add1 = add i64 %add, 1
  254. %arrayidx = getelementptr inbounds i32, i32* %A, i64 %add1
  255. store i32 %conv, i32* %arrayidx, align 4
  256. %sub = sub i64 0, %i.03
  257. %arrayidx2 = getelementptr inbounds i32, i32* %A, i64 %sub
  258. %0 = load i32, i32* %arrayidx2, align 4
  259. %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.02, i64 1
  260. store i32 %0, i32* %B.addr.02, align 4
  261. %inc = add i64 %i.03, 1
  262. %exitcond = icmp ne i64 %inc, %n
  263. br i1 %exitcond, label %for.body, label %for.end.loopexit
  264. for.end.loopexit: ; preds = %for.body
  265. br label %for.end
  266. for.end: ; preds = %for.end.loopexit, %entry
  267. ret void
  268. }
  269. ;; for (long int i = 0; i < n; i++) {
  270. ;; A[4*N*i + M] = i;
  271. ;; *B++ = A[4*N*i + 3*M + 1];
  272. define void @symbolicsiv6(i32* %A, i32* %B, i64 %n, i64 %N, i64 %M) nounwind uwtable ssp {
  273. entry:
  274. %cmp1 = icmp eq i64 %n, 0
  275. br i1 %cmp1, label %for.end, label %for.body.preheader
  276. ; CHECK: da analyze - none!
  277. ; CHECK: da analyze - none!
  278. ; CHECK: da analyze - confused!
  279. ; CHECK: da analyze - none!
  280. ; CHECK: da analyze - confused!
  281. ; CHECK: da analyze - none!
  282. for.body.preheader: ; preds = %entry
  283. br label %for.body
  284. for.body: ; preds = %for.body.preheader, %for.body
  285. %i.03 = phi i64 [ %inc, %for.body ], [ 0, %for.body.preheader ]
  286. %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %for.body.preheader ]
  287. %conv = trunc i64 %i.03 to i32
  288. %mul = shl i64 %N, 2
  289. %mul1 = mul i64 %mul, %i.03
  290. %add = add i64 %mul1, %M
  291. %arrayidx = getelementptr inbounds i32, i32* %A, i64 %add
  292. store i32 %conv, i32* %arrayidx, align 4
  293. %mul2 = shl i64 %N, 2
  294. %mul3 = mul i64 %mul2, %i.03
  295. %mul4 = mul i64 %M, 3
  296. %add5 = add i64 %mul3, %mul4
  297. %add6 = add i64 %add5, 1
  298. %arrayidx7 = getelementptr inbounds i32, i32* %A, i64 %add6
  299. %0 = load i32, i32* %arrayidx7, align 4
  300. %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.02, i64 1
  301. store i32 %0, i32* %B.addr.02, align 4
  302. %inc = add nsw i64 %i.03, 1
  303. %exitcond = icmp ne i64 %inc, %n
  304. br i1 %exitcond, label %for.body, label %for.end.loopexit
  305. for.end.loopexit: ; preds = %for.body
  306. br label %for.end
  307. for.end: ; preds = %for.end.loopexit, %entry
  308. ret void
  309. }
  310. ;; for (long int i = 0; i < n; i++) {
  311. ;; A[2*N*i + M] = i;
  312. ;; *B++ = A[2*N*i - 3*M + 2];
  313. define void @symbolicsiv7(i32* %A, i32* %B, i64 %n, i64 %N, i64 %M) nounwind uwtable ssp {
  314. entry:
  315. %cmp1 = icmp eq i64 %n, 0
  316. br i1 %cmp1, label %for.end, label %for.body.preheader
  317. ; CHECK: da analyze - none!
  318. ; CHECK: da analyze - flow [<>]!
  319. ; CHECK: da analyze - confused!
  320. ; CHECK: da analyze - none!
  321. ; CHECK: da analyze - confused!
  322. ; CHECK: da analyze - none!
  323. for.body.preheader: ; preds = %entry
  324. br label %for.body
  325. for.body: ; preds = %for.body.preheader, %for.body
  326. %i.03 = phi i64 [ %inc, %for.body ], [ 0, %for.body.preheader ]
  327. %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %for.body.preheader ]
  328. %conv = trunc i64 %i.03 to i32
  329. %mul = shl i64 %N, 1
  330. %mul1 = mul i64 %mul, %i.03
  331. %add = add i64 %mul1, %M
  332. %arrayidx = getelementptr inbounds i32, i32* %A, i64 %add
  333. store i32 %conv, i32* %arrayidx, align 4
  334. %mul2 = shl i64 %N, 1
  335. %mul3 = mul i64 %mul2, %i.03
  336. %0 = mul i64 %M, -3
  337. %sub = add i64 %mul3, %0
  338. %add5 = add i64 %sub, 2
  339. %arrayidx6 = getelementptr inbounds i32, i32* %A, i64 %add5
  340. %1 = load i32, i32* %arrayidx6, align 4
  341. %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.02, i64 1
  342. store i32 %1, i32* %B.addr.02, align 4
  343. %inc = add nsw i64 %i.03, 1
  344. %exitcond = icmp ne i64 %inc, %n
  345. br i1 %exitcond, label %for.body, label %for.end.loopexit
  346. for.end.loopexit: ; preds = %for.body
  347. br label %for.end
  348. for.end: ; preds = %for.end.loopexit, %entry
  349. ret void
  350. }