• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1;RUN: opt -S %s -indvars | FileCheck %s
2
3; Provide legal integer types.
4target datalayout = "n8:16:32:64"
5
6
7; CHECK-LABEL: @foo(
8; CHECK-NOT: %lftr.wideiv = trunc i32 %indvars.iv.next to i16
9; CHECK: %exitcond = icmp ne i32 %indvars.iv.next, 512
10define void @foo() #0 {
11entry:
12  br label %for.body
13
14for.body:                                         ; preds = %entry, %for.body
15  %i.01 = phi i16 [ 0, %entry ], [ %inc, %for.body ]
16  %conv2 = sext i16 %i.01 to i32
17  call void @bar(i32 %conv2) #1
18  %inc = add i16 %i.01, 1
19  %cmp = icmp slt i16 %inc, 512
20  br i1 %cmp, label %for.body, label %for.end
21
22for.end:                                          ; preds = %for.body
23  ret void
24}
25
26; Check that post-incrementing the backedge taken count does not overflow.
27; CHECK-LABEL: @postinc(
28; CHECK: icmp eq i32 %indvars.iv, 255
29define i32 @postinc() #0 {
30entry:
31  br label %do.body
32
33do.body:                                          ; preds = %do.body, %entry
34  %first.0 = phi i8 [ 0, %entry ], [ %inc, %do.body ]
35  %conv = zext i8 %first.0 to i32
36  call void  @bar(i32 %conv) #1
37  %inc = add i8 %first.0, 1
38  %cmp = icmp eq i8 %first.0, -1
39  br i1 %cmp, label %do.end, label %do.body
40
41do.end:                                           ; preds = %do.body
42  ret i32 0
43}
44
45declare void @bar(i32)
46
47attributes #0 = { nounwind uwtable }
48attributes #1 = { nounwind }
49