1 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s
2 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-ibm-aix-xcoff < %s | FileCheck %s --check-prefix=AIX64
3 ; RUN: llc -verify-machineinstrs -mtriple=powerpc-ibm-aix-xcoff < %s | FileCheck %s --check-prefix=AIX32
5 define signext i32 @test1(i32 signext %i, ptr nocapture %Func, ptr nocapture %Func2) {
9 ; CHECK-NOT: std 2, 24(1)
13 ; AIX64-NOT: std 2, 40(1)
17 ; AIX32-NOT: std 2, 20(1)
18 %call = tail call signext i32 %Func(i32 signext %i)
19 %call1 = tail call signext i32 %Func2(i32 signext %i)
20 %add2 = add nsw i32 %call1, %call
24 define signext i32 @test2(i32 signext %i, i32 signext %j, ptr nocapture %Func, ptr nocapture %Func2) {
28 ; CHECK-NOT: std 2, 24(1)
32 ; AIX64-NOT: std 2, 40(1)
36 ; AIX32-NOT: std 2, 20(1)
37 %call = tail call signext i32 %Func(i32 signext %i)
38 %tobool = icmp eq i32 %j, 0
39 br i1 %tobool, label %if.end, label %if.then
41 if.then: ; preds = %entry
42 %call1 = tail call signext i32 %Func(i32 signext %i)
43 %add2 = add nsw i32 %call1, %call
44 %call3 = tail call signext i32 %Func2(i32 signext %i)
45 %add4 = add nsw i32 %add2, %call3
48 if.end: ; preds = %entry, %if.then
49 %Sum.0 = phi i32 [ %add4, %if.then ], [ %call, %entry ]
50 %call5 = tail call signext i32 %Func(i32 signext %i)
51 %add6 = add nsw i32 %call5, %Sum.0
55 ; Check for multiple TOC saves with if then else where neither dominates the other.
56 define signext i32 @test3(i32 signext %i, ptr nocapture %Func, ptr nocapture %Func2) {
59 ; CHECK-NOT: std 2, 24(1)
62 ; AIX64-COUNT-3: std 2, 40(1)
65 ; AIX32-COUNT-3: stw 2, 20(1)
67 %tobool = icmp eq i32 %i, 0
68 br i1 %tobool, label %if.else, label %if.then
70 if.then: ; preds = %entry
71 %call = tail call signext i32 %Func(i32 signext %i)
74 if.else: ; preds = %entry
75 %call1 = tail call signext i32 %Func2(i32 signext 0)
78 if.end: ; preds = %if.else, %if.then
79 %Sum.0 = phi i32 [ %call, %if.then ], [ %call1, %if.else ]
80 %call3 = tail call signext i32 %Func(i32 signext %i)
81 %add4 = add nsw i32 %call3, %Sum.0
85 define signext i32 @test4(i32 signext %i, ptr nocapture %Func, ptr nocapture %Func2) {
88 ; CHECK-NOT: std 2, 24(1)
92 ; AIX64-NOT: std 2, 40(1)
96 ; AIX32-NOT: std 2, 20(1)
98 %call = tail call signext i32 %Func(i32 signext %i)
99 %tobool = icmp eq i32 %i, 0
100 br i1 %tobool, label %if.else, label %if.then
102 if.then: ; preds = %entry
103 %call1 = tail call signext i32 %Func(i32 signext %i)
106 if.else: ; preds = %entry
107 %call3 = tail call signext i32 %Func2(i32 signext 0)
110 if.end: ; preds = %if.else, %if.then
111 %call1.pn = phi i32 [ %call1, %if.then ], [ %call3, %if.else ]
112 %Sum.0 = add nsw i32 %call1.pn, %call
116 ; Check for multiple TOC saves with if then where neither is redundant.
117 define signext i32 @test5(i32 signext %i, ptr nocapture %Func, ptr nocapture readnone %Func2) {
119 ; CHECK-LABEL: test5:
120 ; CHECK: std 2, 24(1)
122 ; AIX64-LABEL: test5:
123 ; AIX64: std 2, 40(1)
125 ; AIX32-LABEL: test5:
126 ; AIX32: stw 2, 20(1)
127 %tobool = icmp eq i32 %i, 0
128 br i1 %tobool, label %if.end, label %if.then
130 if.then: ; preds = %entry
131 %call = tail call signext i32 %Func(i32 signext %i)
134 if.end: ; preds = %entry, %if.then
135 %Sum.0 = phi i32 [ %call, %if.then ], [ 0, %entry ]
136 %call1 = tail call signext i32 %Func(i32 signext %i)
137 %add2 = add nsw i32 %call1, %Sum.0
141 ; Check for multiple TOC saves if there are dynamic allocations on the stack.
142 define signext i32 @test6(i32 signext %i, ptr nocapture %Func, ptr nocapture %Func2) {
144 ; CHECK-LABEL: test6:
145 ; CHECK: std 2, 24(1)
146 ; CHECK: std 2, 24(1)
148 ; AIX64-LABEL: test6:
149 ; AIX64: std 2, 40(1)
150 ; AIX64: std 2, 40(1)
152 ; AIX32-LABEL: test6:
153 ; AIX32: stw 2, 20(1)
154 ; AIX32: stw 2, 20(1)
155 %conv = sext i32 %i to i64
156 %0 = alloca i8, i64 %conv, align 16
157 %call = tail call signext i32 %Func(i32 signext %i)
158 call void @useAlloca(ptr nonnull %0, i32 signext %call)
159 %call1 = call signext i32 %Func2(i32 signext %i)
160 %add2 = add nsw i32 %call1, %call
164 declare void @useAlloca(ptr, i32 signext)