aboutsummaryrefslogtreecommitdiffstats
path: root/test/Transforms/LoopStrengthReduce/quadradic-exit-value.ll
blob: 59f14fcd1ce51864a9882aed78688f6e59bd32a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
; RUN: opt < %s -analyze -iv-users | grep {\{1,+,3,+,2\}<%loop> (post-inc with loop %loop)}

; The value of %r is dependent on a polynomial iteration expression.

define i64 @foo(i64 %n) {
entry:
  br label %loop

loop:
  %indvar = phi i64 [ 0, %entry ], [ %indvar.next, %loop ]
  %indvar.next = add i64 %indvar, 1
  %c = icmp eq i64 %indvar.next, %n
  br i1 %c, label %exit, label %loop

exit:
  %r = mul i64 %indvar.next, %indvar.next
  ret i64 %r
}