File: interchange-refcost-overflow.ll

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.6-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,304 kB
  • sloc: cpp: 7,438,677; ansic: 1,393,822; asm: 1,012,926; python: 241,650; f90: 86,635; objc: 75,479; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (37 lines) | stat: -rw-r--r-- 1,181 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
; RUN: opt <  %s  -passes='print<loop-cache-cost>' -disable-output 2>&1 | FileCheck  %s

; For a loop with a very large iteration count, make sure the cost
; calculation does not overflow:
;
; void a(int b) {
;   for (int c;; c += b)
;     for (long d = 0; d < -3ULL; d += 2ULL)
;       A[c][d][d] = 0;
; }

; CHECK: Loop 'outer.loop' has cost = 9223372036854775807
; CHECK: Loop 'inner.loop' has cost = 9223372036854775807

@A = local_unnamed_addr global [11 x [11 x [11 x i32]]] zeroinitializer, align 16

define void @foo(i32 noundef %b) {
entry:
  %0 = sext i32 %b to i64
  br label %outer.loop

outer.loop:
  %indvars.iv = phi i64 [ %indvars.iv.next, %outer.loop.cleanup ], [ 0, %entry ]
  br label %inner.loop

outer.loop.cleanup:
  %indvars.iv.next = add nsw i64 %indvars.iv, %0
  br label %outer.loop

inner.loop:
  %inner.iv = phi i64 [ 0, %outer.loop ], [ %add, %inner.loop ]
  %arrayidx3 = getelementptr inbounds [11 x [11 x [11 x i32]]], ptr @A, i64 0, i64 %indvars.iv, i64 %inner.iv, i64 %inner.iv
  store i32 0, ptr %arrayidx3, align 4
  %add = add nuw i64 %inner.iv, 2
  %cmp = icmp ult i64 %inner.iv, -5
  br i1 %cmp, label %inner.loop, label %outer.loop.cleanup
}