1 ; RUN: opt < %s -O1 -S | FileCheck %s
3 ; The attribute nomerge prevents the 3 bar() calls from being sunk/hoisted into
4 ; one inside a function. Check that there are still 3 tail calls.
6 ; Test case for preventing sinking
7 ; CHECK-LABEL: define void @sink
9 ; CHECK-NEXT: tail call void @bar()
11 ; CHECK-NEXT: tail call void @bar()
13 ; CHECK-NEXT: tail call void @bar()
14 define void @sink(i32 %i) {
16 switch i32 %i, label %if.end3 [
18 i32 7, label %if.then2
22 tail call void @bar() #0
26 tail call void @bar() #0
30 tail call void @bar() #0
34 ; Test case for preventing hoisting
35 ; CHECK-LABEL: define void @hoist
37 ; CHECK-NEXT: tail call void @bar()
39 ; CHECK-NEXT: tail call void @bar()
41 ; CHECK-NEXT: tail call void @bar()
42 define void @hoist(i32 %i) {
44 %i.addr = alloca i32, align 4
45 store i32 %i, ptr %i.addr, align 4
46 %0 = load i32, ptr %i.addr, align 4
47 %cmp = icmp eq i32 %0, 5
48 br i1 %cmp, label %if.then, label %if.else
51 tail call void @bar() #1
55 %1 = load i32, ptr %i.addr, align 4
56 %cmp1 = icmp eq i32 %i, 7
57 br i1 %cmp1, label %if.then2, label %if.end
60 tail call void @bar() #1
64 tail call void @bar() #1
70 attributes #0 = { nomerge }
71 attributes #1 = { noreturn nomerge }