xref: /llvm-project/llvm/test/Transforms/SimplifyCFG/X86/invalidate-dom.ll (revision 8979ae42769e529b0f6fce3268492ffb49bd54b9)
1; RUN: opt -passes="default<O2>" -disable-output %s
2; REQUIRES: asserts
3; PR42272
4
5target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
6target triple = "x86_64-unknown-linux-gnu"
7
8@b = external global i32, align 4
9@f = external global i32, align 4
10@g = external global i32, align 4
11
12define ptr @a(i32 %h) #0 {
13entry:
14  %h.addr = alloca i32, align 4
15  store i32 %h, ptr %h.addr, align 4
16  %tmp0 = load i32, ptr %h.addr, align 4
17  switch i32 %tmp0, label %sw.default [
18    i32 4, label %sw.bb
19    i32 3, label %sw.bb1
20    i32 2, label %sw.bb3
21  ]
22
23sw.bb:                                            ; preds = %entry
24  %call = call i32 (...) @c()
25  unreachable
26
27sw.bb1:                                           ; preds = %entry
28  %call2 = call i32 (...) @c()
29  unreachable
30
31sw.bb3:                                           ; preds = %entry
32  %call4 = call i32 (...) @c()
33  %conv = sext i32 %call4 to i64
34  %tmp1 = inttoptr i64 %conv to ptr
35  ret ptr %tmp1
36
37sw.default:                                       ; preds = %entry
38  unreachable
39}
40
41define i32 @m() #1 {
42entry:
43  %call = call i32 @j()
44  %call1 = call i32 @j()
45  ret i32 undef
46}
47
48define internal i32 @j() #0 {
49entry:
50  %i = alloca i32, align 4
51  store i32 0, ptr %i, align 4
52  br label %for.cond
53
54for.cond:                                         ; preds = %for.body, %entry
55  %tmp0 = load i32, ptr %i, align 4
56  %tmp1 = load i32, ptr @f, align 4
57  %cmp = icmp ult i32 %tmp0, %tmp1
58  br i1 %cmp, label %for.body, label %for.cond.cleanup
59
60for.cond.cleanup:                                 ; preds = %for.cond
61  %tmp2 = load i32, ptr @f, align 4
62  %call3 = call ptr @a(i32 %tmp2)
63  ret i32 undef
64
65for.body:                                         ; preds = %for.cond
66  %call = call i32 (...) @c()
67  %call1 = call i32 (...) @c()
68  %call2 = call i32 (...) @c()
69  %tmp3 = load i32, ptr @b, align 4
70  %tmp4 = load i32, ptr @g, align 4
71  %sub = sub nsw i32 %tmp4, %tmp3
72  store i32 %sub, ptr @g, align 4
73  %tmp5 = load i32, ptr %i, align 4
74  %inc = add i32 %tmp5, 1
75  store i32 %inc, ptr %i, align 4
76  br label %for.cond
77}
78
79declare i32 @c(...) #0
80
81; Function Attrs: argmemonly nounwind
82declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2
83
84; Function Attrs: argmemonly nounwind
85declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2
86
87attributes #0 = { "use-soft-float"="false" }
88attributes #1 = { "target-cpu"="x86-64" }
89attributes #2 = { argmemonly nounwind }
90
91