• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1;; RUN: opt -S < %s -indvars | FileCheck %s
2
3;; Check if IndVarSimplify understands !range metadata.
4
5declare void @abort()
6
7define i1 @iterate(i32* nocapture readonly %buffer) {
8entry:
9  %length = load i32, i32* %buffer, !range !0
10  br label %loop.preheader
11
12loop.preheader:
13  br label %loop
14
15loop:
16  %idx = phi i32 [ %idx.inc, %loop.next ], [ 0, %loop.preheader ]
17  %oob.pred = icmp slt i32 %idx, %length
18  br i1 %oob.pred, label %loop.next, label %oob
19; CHECK: br i1 true, label %loop.next, label %oob
20
21loop.next:
22  %idx.inc = add i32 %idx, 1
23  %exit.pred = icmp slt i32 %idx.inc, %length
24  br i1 %exit.pred, label %loop, label %abort.loopexit
25
26abort.loopexit:
27  br label %abort
28
29abort:
30  ret i1 false
31
32oob:
33  tail call void @abort()
34  ret i1 false
35}
36
37!0 = !{i32 1, i32 100}
38