• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -simplifycfg -S < %s | FileCheck %s
2
3; This load is safe to speculate, as it's from a safe offset
4; within an alloca.
5
6; CHECK-LABEL: @yes(
7; CHECK-NOT: br
8
9define void @yes(i1 %c) nounwind {
10entry:
11  %a = alloca [4 x i64*], align 8
12  %__a.addr = getelementptr [4 x i64*], [4 x i64*]* %a, i64 0, i64 3
13  call void @frob(i64** %__a.addr)
14  br i1 %c, label %if.then, label %if.end
15
16if.then:                                          ; preds = %entry
17  br label %return
18
19if.end:                                           ; preds = %entry
20  %tmp5 = load i64*, i64** %__a.addr, align 8
21  br label %return
22
23return:                                           ; preds = %if.end, %if.then
24  %storemerge = phi i64* [ undef, %if.then ], [ %tmp5, %if.end ]
25  ret void
26}
27
28; CHECK-LABEL: @no0(
29; CHECK: br i1 %c
30
31define void @no0(i1 %c) nounwind {
32entry:
33  %a = alloca [4 x i64*], align 8
34  %__a.addr = getelementptr [4 x i64*], [4 x i64*]* %a, i64 0, i64 4
35  call void @frob(i64** %__a.addr)
36  br i1 %c, label %if.then, label %if.end
37
38if.then:                                          ; preds = %entry
39  br label %return
40
41if.end:                                           ; preds = %entry
42  %tmp5 = load i64*, i64** %__a.addr, align 8
43  br label %return
44
45return:                                           ; preds = %if.end, %if.then
46  %storemerge = phi i64* [ undef, %if.then ], [ %tmp5, %if.end ]
47  ret void
48}
49
50; CHECK-LABEL: @no1(
51; CHECK: br i1 %c
52
53define void @no1(i1 %c, i64 %n) nounwind {
54entry:
55  %a = alloca [4 x i64*], align 8
56  %__a.addr = getelementptr [4 x i64*], [4 x i64*]* %a, i64 0, i64 %n
57  call void @frob(i64** %__a.addr)
58  br i1 %c, label %if.then, label %if.end
59
60if.then:                                          ; preds = %entry
61  br label %return
62
63if.end:                                           ; preds = %entry
64  %tmp5 = load i64*, i64** %__a.addr, align 8
65  br label %return
66
67return:                                           ; preds = %if.end, %if.then
68  %storemerge = phi i64* [ undef, %if.then ], [ %tmp5, %if.end ]
69  ret void
70}
71
72; CHECK-LABEL: @no2(
73; CHECK: br i1 %c
74
75define void @no2(i1 %c, i64 %n) nounwind {
76entry:
77  %a = alloca [4 x i64*], align 8
78  %__a.addr = getelementptr [4 x i64*], [4 x i64*]* %a, i64 1, i64 0
79  call void @frob(i64** %__a.addr)
80  br i1 %c, label %if.then, label %if.end
81
82if.then:                                          ; preds = %entry
83  br label %return
84
85if.end:                                           ; preds = %entry
86  %tmp5 = load i64*, i64** %__a.addr, align 8
87  br label %return
88
89return:                                           ; preds = %if.end, %if.then
90  %storemerge = phi i64* [ undef, %if.then ], [ %tmp5, %if.end ]
91  ret void
92}
93
94declare void @frob(i64** nocapture %p)
95