1 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s
2 define signext i32 @test1(i32 signext %i, i32 (i32)* nocapture %Func, i32 (i32)* nocapture %Func2) {
6 ; CHECK-NOT: std 2, 24(1)
7 %call = tail call signext i32 %Func(i32 signext %i)
8 %call1 = tail call signext i32 %Func2(i32 signext %i)
9 %add2 = add nsw i32 %call1, %call
13 define signext i32 @test2(i32 signext %i, i32 signext %j, i32 (i32)* nocapture %Func, i32 (i32)* nocapture %Func2) {
17 ; CHECK-NOT: std 2, 24(1)
18 %call = tail call signext i32 %Func(i32 signext %i)
19 %tobool = icmp eq i32 %j, 0
20 br i1 %tobool, label %if.end, label %if.then
22 if.then: ; preds = %entry
23 %call1 = tail call signext i32 %Func(i32 signext %i)
24 %add2 = add nsw i32 %call1, %call
25 %call3 = tail call signext i32 %Func2(i32 signext %i)
26 %add4 = add nsw i32 %add2, %call3
29 if.end: ; preds = %entry, %if.then
30 %Sum.0 = phi i32 [ %add4, %if.then ], [ %call, %entry ]
31 %call5 = tail call signext i32 %Func(i32 signext %i)
32 %add6 = add nsw i32 %call5, %Sum.0
36 ; Check for multiple TOC saves with if then else where neither dominates the other.
37 define signext i32 @test3(i32 signext %i, i32 (i32)* nocapture %Func, i32 (i32)* nocapture %Func2) {
40 ; CHECK-NOT: std 2, 24(1)
42 %tobool = icmp eq i32 %i, 0
43 br i1 %tobool, label %if.else, label %if.then
45 if.then: ; preds = %entry
46 %call = tail call signext i32 %Func(i32 signext %i)
49 if.else: ; preds = %entry
50 %call1 = tail call signext i32 %Func2(i32 signext 0)
53 if.end: ; preds = %if.else, %if.then
54 %Sum.0 = phi i32 [ %call, %if.then ], [ %call1, %if.else ]
55 %call3 = tail call signext i32 %Func(i32 signext %i)
56 %add4 = add nsw i32 %call3, %Sum.0
60 define signext i32 @test4(i32 signext %i, i32 (i32)* nocapture %Func, i32 (i32)* nocapture %Func2) {
63 ; CHECK-NOT: std 2, 24(1)
66 %call = tail call signext i32 %Func(i32 signext %i)
67 %tobool = icmp eq i32 %i, 0
68 br i1 %tobool, label %if.else, label %if.then
70 if.then: ; preds = %entry
71 %call1 = tail call signext i32 %Func(i32 signext %i)
74 if.else: ; preds = %entry
75 %call3 = tail call signext i32 %Func2(i32 signext 0)
78 if.end: ; preds = %if.else, %if.then
79 %call1.pn = phi i32 [ %call1, %if.then ], [ %call3, %if.else ]
80 %Sum.0 = add nsw i32 %call1.pn, %call
84 ; Check for multiple TOC saves with if then where neither is redundant.
85 define signext i32 @test5(i32 signext %i, i32 (i32)* nocapture %Func, i32 (i32)* nocapture readnone %Func2) {
90 %tobool = icmp eq i32 %i, 0
91 br i1 %tobool, label %if.end, label %if.then
93 if.then: ; preds = %entry
94 %call = tail call signext i32 %Func(i32 signext %i)
97 if.end: ; preds = %entry, %if.then
98 %Sum.0 = phi i32 [ %call, %if.then ], [ 0, %entry ]
99 %call1 = tail call signext i32 %Func(i32 signext %i)
100 %add2 = add nsw i32 %call1, %Sum.0
104 ; Check for multiple TOC saves if there are dynamic allocations on the stack.
105 define signext i32 @test6(i32 signext %i, i32 (i32)* nocapture %Func, i32 (i32)* nocapture %Func2) {
107 ; CHECK-LABEL: test6:
108 ; CHECK: std 2, 24(1)
109 ; CHECK: std 2, 24(1)
111 %conv = sext i32 %i to i64
112 %0 = alloca i8, i64 %conv, align 16
113 %1 = bitcast i8* %0 to i32*
114 %call = tail call signext i32 %Func(i32 signext %i)
115 call void @useAlloca(i32* nonnull %1, i32 signext %call)
116 %call1 = call signext i32 %Func2(i32 signext %i)
117 %add2 = add nsw i32 %call1, %call
121 declare void @useAlloca(i32*, i32 signext)