File: shifted-tripcount.ll

package info (click to toggle)
llvm-toolchain-16 1%3A16.0.6-15~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,634,792 kB
  • sloc: cpp: 6,179,261; ansic: 1,216,205; asm: 741,319; python: 196,614; objc: 75,325; f90: 49,640; lisp: 32,396; pascal: 12,286; sh: 9,394; perl: 7,442; ml: 5,494; awk: 3,523; makefile: 2,723; javascript: 1,206; xml: 886; fortran: 581; cs: 573
file content (104 lines) | stat: -rw-r--r-- 4,709 bytes parent folder | download | duplicates (2)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -passes=loop-unroll -unroll-count=2 -S | FileCheck %s

; LoopUnroll should unroll this loop into one big basic block.
define void @latch_exit(ptr nocapture %p, i64 %n) nounwind {
; CHECK-LABEL: @latch_exit(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[MUL10:%.*]] = shl i64 [[N:%.*]], 1
; CHECK-NEXT:    br label [[FOR_BODY:%.*]]
; CHECK:       for.body:
; CHECK-NEXT:    [[I_013:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[TMP16_1:%.*]], [[FOR_BODY]] ]
; CHECK-NEXT:    [[ARRAYIDX7:%.*]] = getelementptr double, ptr [[P:%.*]], i64 [[I_013]]
; CHECK-NEXT:    [[TMP16:%.*]] = add nuw nsw i64 [[I_013]], 1
; CHECK-NEXT:    [[ARRAYIDX:%.*]] = getelementptr double, ptr [[P]], i64 [[TMP16]]
; CHECK-NEXT:    [[TMP4:%.*]] = load double, ptr [[ARRAYIDX]], align 8
; CHECK-NEXT:    [[TMP8:%.*]] = load double, ptr [[ARRAYIDX7]], align 8
; CHECK-NEXT:    [[MUL9:%.*]] = fmul double [[TMP8]], [[TMP4]]
; CHECK-NEXT:    store double [[MUL9]], ptr [[ARRAYIDX7]], align 8
; CHECK-NEXT:    [[ARRAYIDX7_1:%.*]] = getelementptr double, ptr [[P]], i64 [[TMP16]]
; CHECK-NEXT:    [[TMP16_1]] = add i64 [[TMP16]], 1
; CHECK-NEXT:    [[ARRAYIDX_1:%.*]] = getelementptr double, ptr [[P]], i64 [[TMP16_1]]
; CHECK-NEXT:    [[TMP4_1:%.*]] = load double, ptr [[ARRAYIDX_1]], align 8
; CHECK-NEXT:    [[TMP8_1:%.*]] = load double, ptr [[ARRAYIDX7_1]], align 8
; CHECK-NEXT:    [[MUL9_1:%.*]] = fmul double [[TMP8_1]], [[TMP4_1]]
; CHECK-NEXT:    store double [[MUL9_1]], ptr [[ARRAYIDX7_1]], align 8
; CHECK-NEXT:    [[EXITCOND_1:%.*]] = icmp eq i64 [[TMP16_1]], [[MUL10]]
; CHECK-NEXT:    br i1 [[EXITCOND_1]], label [[FOR_END:%.*]], label [[FOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]
; CHECK:       for.end:
; CHECK-NEXT:    ret void
;
entry:
  %mul10 = shl i64 %n, 1
  br label %for.body

for.body:
  %i.013 = phi i64 [ %tmp16, %for.body ], [ 0, %entry ]
  %arrayidx7 = getelementptr double, ptr %p, i64 %i.013
  %tmp16 = add i64 %i.013, 1
  %arrayidx = getelementptr double, ptr %p, i64 %tmp16
  %tmp4 = load double, ptr %arrayidx
  %tmp8 = load double, ptr %arrayidx7
  %mul9 = fmul double %tmp8, %tmp4
  store double %mul9, ptr %arrayidx7
  %exitcond = icmp eq i64 %tmp16, %mul10
  br i1 %exitcond, label %for.end, label %for.body

for.end:
  ret void
}

; Same as previous test case, but with a non-latch exit. There shouldn't
; be a conditional branch after the first block.
define void @non_latch_exit(ptr nocapture %p, i64 %n) nounwind {
; CHECK-LABEL: @non_latch_exit(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[MUL10:%.*]] = shl i64 [[N:%.*]], 1
; CHECK-NEXT:    br label [[FOR_BODY:%.*]]
; CHECK:       for.body:
; CHECK-NEXT:    [[I_013:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[TMP16_1:%.*]], [[LATCH_1:%.*]] ]
; CHECK-NEXT:    [[ARRAYIDX7:%.*]] = getelementptr double, ptr [[P:%.*]], i64 [[I_013]]
; CHECK-NEXT:    [[TMP16:%.*]] = add nuw nsw i64 [[I_013]], 1
; CHECK-NEXT:    [[ARRAYIDX:%.*]] = getelementptr double, ptr [[P]], i64 [[TMP16]]
; CHECK-NEXT:    [[TMP4:%.*]] = load double, ptr [[ARRAYIDX]], align 8
; CHECK-NEXT:    [[TMP8:%.*]] = load double, ptr [[ARRAYIDX7]], align 8
; CHECK-NEXT:    [[MUL9:%.*]] = fmul double [[TMP8]], [[TMP4]]
; CHECK-NEXT:    store double [[MUL9]], ptr [[ARRAYIDX7]], align 8
; CHECK-NEXT:    br label [[LATCH:%.*]]
; CHECK:       latch:
; CHECK-NEXT:    [[ARRAYIDX7_1:%.*]] = getelementptr double, ptr [[P]], i64 [[TMP16]]
; CHECK-NEXT:    [[TMP16_1]] = add i64 [[TMP16]], 1
; CHECK-NEXT:    [[ARRAYIDX_1:%.*]] = getelementptr double, ptr [[P]], i64 [[TMP16_1]]
; CHECK-NEXT:    [[TMP4_1:%.*]] = load double, ptr [[ARRAYIDX_1]], align 8
; CHECK-NEXT:    [[TMP8_1:%.*]] = load double, ptr [[ARRAYIDX7_1]], align 8
; CHECK-NEXT:    [[MUL9_1:%.*]] = fmul double [[TMP8_1]], [[TMP4_1]]
; CHECK-NEXT:    store double [[MUL9_1]], ptr [[ARRAYIDX7_1]], align 8
; CHECK-NEXT:    [[EXITCOND_1:%.*]] = icmp eq i64 [[TMP16_1]], [[MUL10]]
; CHECK-NEXT:    br i1 [[EXITCOND_1]], label [[FOR_END:%.*]], label [[LATCH_1]]
; CHECK:       latch.1:
; CHECK-NEXT:    br label [[FOR_BODY]], !llvm.loop [[LOOP2:![0-9]+]]
; CHECK:       for.end:
; CHECK-NEXT:    ret void
;
entry:
  %mul10 = shl i64 %n, 1
  br label %for.body

for.body:
  %i.013 = phi i64 [ %tmp16, %latch ], [ 0, %entry ]
  %arrayidx7 = getelementptr double, ptr %p, i64 %i.013
  %tmp16 = add i64 %i.013, 1
  %arrayidx = getelementptr double, ptr %p, i64 %tmp16
  %tmp4 = load double, ptr %arrayidx
  %tmp8 = load double, ptr %arrayidx7
  %mul9 = fmul double %tmp8, %tmp4
  store double %mul9, ptr %arrayidx7
  %exitcond = icmp eq i64 %tmp16, %mul10
  br i1 %exitcond, label %for.end, label %latch

latch:
  br label %for.body

for.end:
  ret void
}