• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -S -loop-rotate < %s | FileCheck %s
2; RUN: opt -S -passes='require<targetir>,require<assumptions>,loop(rotate)' < %s | FileCheck %s
3
4target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
5target triple = "x86_64-apple-darwin10.0.0"
6
7; PR5319 - The "arrayidx" gep should be hoisted, not duplicated.  We should
8; end up with one phi node.
9define void @test1() nounwind ssp {
10; CHECK-LABEL: @test1(
11entry:
12  %array = alloca [20 x i32], align 16
13  br label %for.cond
14
15for.cond:                                         ; preds = %for.body, %entry
16  %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
17  %cmp = icmp slt i32 %i.0, 100
18  %arrayidx = getelementptr inbounds [20 x i32], [20 x i32]* %array, i64 0, i64 0
19  br i1 %cmp, label %for.body, label %for.end
20
21; CHECK: for.body:
22; CHECK-NEXT: phi i32 [ 0
23; CHECK-NEXT: store i32 0
24
25for.body:                                         ; preds = %for.cond
26  store i32 0, i32* %arrayidx, align 16
27  %inc = add nsw i32 %i.0, 1
28  br label %for.cond
29
30for.end:                                          ; preds = %for.cond
31  %arrayidx.lcssa = phi i32* [ %arrayidx, %for.cond ]
32  call void @g(i32* %arrayidx.lcssa) nounwind
33  ret void
34}
35
36declare void @g(i32*)
37
38; CHECK-LABEL: @test2(
39define void @test2() nounwind ssp {
40entry:
41  %array = alloca [20 x i32], align 16
42  br label %for.cond
43
44for.cond:                                         ; preds = %for.body, %entry
45  %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
46  %cmp = icmp slt i32 %i.0, 100
47; CHECK: call void @f
48; CHECK-NOT: call void @f
49  call void @f() noduplicate
50  br i1 %cmp, label %for.body, label %for.end
51
52for.body:                                         ; preds = %for.cond
53  %inc = add nsw i32 %i.0, 1
54  call void @h()
55  br label %for.cond
56
57for.end:                                          ; preds = %for.cond
58  ret void
59; CHECK: }
60}
61
62declare void @f() noduplicate
63declare void @h()
64