1 ; RUN: llc -mcpu=ppc64 -O0 -disable-fp-elim -fast-isel=false < %s | FileCheck %s 2 3 target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v128:128:128-n32:64" 4 target triple = "powerpc64-unknown-linux-gnu" 5 6 %struct.s1 = type { i8 } 7 %struct.s2 = type { i16 } 8 %struct.s4 = type { i32 } 9 %struct.t1 = type { i8 } 10 %struct.t3 = type <{ i16, i8 }> 11 %struct.t5 = type <{ i32, i8 }> 12 %struct.t6 = type <{ i32, i16 }> 13 %struct.t7 = type <{ i32, i16, i8 }> 14 %struct.s3 = type { i16, i8 } 15 %struct.s5 = type { i32, i8 } 16 %struct.s6 = type { i32, i16 } 17 %struct.s7 = type { i32, i16, i8 } 18 %struct.t2 = type <{ i16 }> 19 %struct.t4 = type <{ i32 }> 20 21 @caller1.p1 = private unnamed_addr constant %struct.s1 { i8 1 }, align 1 22 @caller1.p2 = private unnamed_addr constant %struct.s2 { i16 2 }, align 2 23 @caller1.p3 = private unnamed_addr constant { i16, i8, i8 } { i16 4, i8 8, i8 undef }, align 2 24 @caller1.p4 = private unnamed_addr constant %struct.s4 { i32 16 }, align 4 25 @caller1.p5 = private unnamed_addr constant { i32, i8, [3 x i8] } { i32 32, i8 64, [3 x i8] undef }, align 4 26 @caller1.p6 = private unnamed_addr constant { i32, i16, [2 x i8] } { i32 128, i16 256, [2 x i8] undef }, align 4 27 @caller1.p7 = private unnamed_addr constant { i32, i16, i8, i8 } { i32 512, i16 1024, i8 -3, i8 undef }, align 4 28 @caller2.p1 = private unnamed_addr constant %struct.t1 { i8 1 }, align 1 29 @caller2.p2 = private unnamed_addr constant { i16 } { i16 2 }, align 1 30 @caller2.p3 = private unnamed_addr constant %struct.t3 <{ i16 4, i8 8 }>, align 1 31 @caller2.p4 = private unnamed_addr constant { i32 } { i32 16 }, align 1 32 @caller2.p5 = private unnamed_addr constant %struct.t5 <{ i32 32, i8 64 }>, align 1 33 @caller2.p6 = private unnamed_addr constant %struct.t6 <{ i32 128, i16 256 }>, align 1 34 @caller2.p7 = private unnamed_addr constant %struct.t7 <{ i32 512, i16 1024, i8 -3 }>, align 1 35 36 define i32 @caller1() nounwind { 37 entry: 38 %p1 = alloca %struct.s1, align 1 39 %p2 = alloca %struct.s2, align 2 40 %p3 = alloca %struct.s3, align 2 41 %p4 = alloca %struct.s4, align 4 42 %p5 = alloca %struct.s5, align 4 43 %p6 = alloca %struct.s6, align 4 44 %p7 = alloca %struct.s7, align 4 45 %0 = bitcast %struct.s1* %p1 to i8* 46 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %0, i8* getelementptr inbounds (%struct.s1, %struct.s1* @caller1.p1, i32 0, i32 0), i64 1, i32 1, i1 false) 47 %1 = bitcast %struct.s2* %p2 to i8* 48 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %1, i8* bitcast (%struct.s2* @caller1.p2 to i8*), i64 2, i32 2, i1 false) 49 %2 = bitcast %struct.s3* %p3 to i8* 50 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %2, i8* bitcast ({ i16, i8, i8 }* @caller1.p3 to i8*), i64 4, i32 2, i1 false) 51 %3 = bitcast %struct.s4* %p4 to i8* 52 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %3, i8* bitcast (%struct.s4* @caller1.p4 to i8*), i64 4, i32 4, i1 false) 53 %4 = bitcast %struct.s5* %p5 to i8* 54 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %4, i8* bitcast ({ i32, i8, [3 x i8] }* @caller1.p5 to i8*), i64 8, i32 4, i1 false) 55 %5 = bitcast %struct.s6* %p6 to i8* 56 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %5, i8* bitcast ({ i32, i16, [2 x i8] }* @caller1.p6 to i8*), i64 8, i32 4, i1 false) 57 %6 = bitcast %struct.s7* %p7 to i8* 58 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %6, i8* bitcast ({ i32, i16, i8, i8 }* @caller1.p7 to i8*), i64 8, i32 4, i1 false) 59 %call = call i32 @callee1(i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, %struct.s1* byval %p1, %struct.s2* byval %p2, %struct.s3* byval %p3, %struct.s4* byval %p4, %struct.s5* byval %p5, %struct.s6* byval %p6, %struct.s7* byval %p7) 60 ret i32 %call 61 62 ; CHECK: stb {{[0-9]+}}, 119(1) 63 ; CHECK: sth {{[0-9]+}}, 126(1) 64 ; CHECK: stw {{[0-9]+}}, 132(1) 65 ; CHECK: stw {{[0-9]+}}, 140(1) 66 ; CHECK: std {{[0-9]+}}, 144(1) 67 ; CHECK: std {{[0-9]+}}, 152(1) 68 ; CHECK: std {{[0-9]+}}, 160(1) 69 } 70 71 declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind 72 73 define internal i32 @callee1(i32 %z1, i32 %z2, i32 %z3, i32 %z4, i32 %z5, i32 %z6, i32 %z7, i32 %z8, %struct.s1* byval %v1, %struct.s2* byval %v2, %struct.s3* byval %v3, %struct.s4* byval %v4, %struct.s5* byval %v5, %struct.s6* byval %v6, %struct.s7* byval %v7) nounwind { 74 entry: 75 %z1.addr = alloca i32, align 4 76 %z2.addr = alloca i32, align 4 77 %z3.addr = alloca i32, align 4 78 %z4.addr = alloca i32, align 4 79 %z5.addr = alloca i32, align 4 80 %z6.addr = alloca i32, align 4 81 %z7.addr = alloca i32, align 4 82 %z8.addr = alloca i32, align 4 83 store i32 %z1, i32* %z1.addr, align 4 84 store i32 %z2, i32* %z2.addr, align 4 85 store i32 %z3, i32* %z3.addr, align 4 86 store i32 %z4, i32* %z4.addr, align 4 87 store i32 %z5, i32* %z5.addr, align 4 88 store i32 %z6, i32* %z6.addr, align 4 89 store i32 %z7, i32* %z7.addr, align 4 90 store i32 %z8, i32* %z8.addr, align 4 91 %a = getelementptr inbounds %struct.s1, %struct.s1* %v1, i32 0, i32 0 92 %0 = load i8, i8* %a, align 1 93 %conv = zext i8 %0 to i32 94 %a1 = getelementptr inbounds %struct.s2, %struct.s2* %v2, i32 0, i32 0 95 %1 = load i16, i16* %a1, align 2 96 %conv2 = sext i16 %1 to i32 97 %add = add nsw i32 %conv, %conv2 98 %a3 = getelementptr inbounds %struct.s3, %struct.s3* %v3, i32 0, i32 0 99 %2 = load i16, i16* %a3, align 2 100 %conv4 = sext i16 %2 to i32 101 %add5 = add nsw i32 %add, %conv4 102 %a6 = getelementptr inbounds %struct.s4, %struct.s4* %v4, i32 0, i32 0 103 %3 = load i32, i32* %a6, align 4 104 %add7 = add nsw i32 %add5, %3 105 %a8 = getelementptr inbounds %struct.s5, %struct.s5* %v5, i32 0, i32 0 106 %4 = load i32, i32* %a8, align 4 107 %add9 = add nsw i32 %add7, %4 108 %a10 = getelementptr inbounds %struct.s6, %struct.s6* %v6, i32 0, i32 0 109 %5 = load i32, i32* %a10, align 4 110 %add11 = add nsw i32 %add9, %5 111 %a12 = getelementptr inbounds %struct.s7, %struct.s7* %v7, i32 0, i32 0 112 %6 = load i32, i32* %a12, align 4 113 %add13 = add nsw i32 %add11, %6 114 ret i32 %add13 115 116 ; CHECK: lha {{[0-9]+}}, 126(1) 117 ; CHECK: lha {{[0-9]+}}, 132(1) 118 ; CHECK: lbz {{[0-9]+}}, 119(1) 119 ; CHECK: lwz {{[0-9]+}}, 140(1) 120 ; CHECK: lwz {{[0-9]+}}, 144(1) 121 ; CHECK: lwz {{[0-9]+}}, 152(1) 122 ; CHECK: lwz {{[0-9]+}}, 160(1) 123 } 124 125 define i32 @caller2() nounwind { 126 entry: 127 %p1 = alloca %struct.t1, align 1 128 %p2 = alloca %struct.t2, align 1 129 %p3 = alloca %struct.t3, align 1 130 %p4 = alloca %struct.t4, align 1 131 %p5 = alloca %struct.t5, align 1 132 %p6 = alloca %struct.t6, align 1 133 %p7 = alloca %struct.t7, align 1 134 %0 = bitcast %struct.t1* %p1 to i8* 135 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %0, i8* getelementptr inbounds (%struct.t1, %struct.t1* @caller2.p1, i32 0, i32 0), i64 1, i32 1, i1 false) 136 %1 = bitcast %struct.t2* %p2 to i8* 137 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %1, i8* bitcast ({ i16 }* @caller2.p2 to i8*), i64 2, i32 1, i1 false) 138 %2 = bitcast %struct.t3* %p3 to i8* 139 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %2, i8* bitcast (%struct.t3* @caller2.p3 to i8*), i64 3, i32 1, i1 false) 140 %3 = bitcast %struct.t4* %p4 to i8* 141 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %3, i8* bitcast ({ i32 }* @caller2.p4 to i8*), i64 4, i32 1, i1 false) 142 %4 = bitcast %struct.t5* %p5 to i8* 143 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %4, i8* bitcast (%struct.t5* @caller2.p5 to i8*), i64 5, i32 1, i1 false) 144 %5 = bitcast %struct.t6* %p6 to i8* 145 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %5, i8* bitcast (%struct.t6* @caller2.p6 to i8*), i64 6, i32 1, i1 false) 146 %6 = bitcast %struct.t7* %p7 to i8* 147 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %6, i8* bitcast (%struct.t7* @caller2.p7 to i8*), i64 7, i32 1, i1 false) 148 %call = call i32 @callee2(i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, %struct.t1* byval %p1, %struct.t2* byval %p2, %struct.t3* byval %p3, %struct.t4* byval %p4, %struct.t5* byval %p5, %struct.t6* byval %p6, %struct.t7* byval %p7) 149 ret i32 %call 150 151 ; CHECK: stb {{[0-9]+}}, 119(1) 152 ; CHECK: sth {{[0-9]+}}, 126(1) 153 ; CHECK: stb {{[0-9]+}}, 135(1) 154 ; CHECK: sth {{[0-9]+}}, 133(1) 155 ; CHECK: stw {{[0-9]+}}, 140(1) 156 ; CHECK: stb {{[0-9]+}}, 151(1) 157 ; CHECK: stw {{[0-9]+}}, 147(1) 158 ; CHECK: sth {{[0-9]+}}, 158(1) 159 ; CHECK: stw {{[0-9]+}}, 154(1) 160 ; CHECK: stb {{[0-9]+}}, 167(1) 161 ; CHECK: sth {{[0-9]+}}, 165(1) 162 ; CHECK: stw {{[0-9]+}}, 161(1) 163 } 164 165 define internal i32 @callee2(i32 %z1, i32 %z2, i32 %z3, i32 %z4, i32 %z5, i32 %z6, i32 %z7, i32 %z8, %struct.t1* byval %v1, %struct.t2* byval %v2, %struct.t3* byval %v3, %struct.t4* byval %v4, %struct.t5* byval %v5, %struct.t6* byval %v6, %struct.t7* byval %v7) nounwind { 166 entry: 167 %z1.addr = alloca i32, align 4 168 %z2.addr = alloca i32, align 4 169 %z3.addr = alloca i32, align 4 170 %z4.addr = alloca i32, align 4 171 %z5.addr = alloca i32, align 4 172 %z6.addr = alloca i32, align 4 173 %z7.addr = alloca i32, align 4 174 %z8.addr = alloca i32, align 4 175 store i32 %z1, i32* %z1.addr, align 4 176 store i32 %z2, i32* %z2.addr, align 4 177 store i32 %z3, i32* %z3.addr, align 4 178 store i32 %z4, i32* %z4.addr, align 4 179 store i32 %z5, i32* %z5.addr, align 4 180 store i32 %z6, i32* %z6.addr, align 4 181 store i32 %z7, i32* %z7.addr, align 4 182 store i32 %z8, i32* %z8.addr, align 4 183 %a = getelementptr inbounds %struct.t1, %struct.t1* %v1, i32 0, i32 0 184 %0 = load i8, i8* %a, align 1 185 %conv = zext i8 %0 to i32 186 %a1 = getelementptr inbounds %struct.t2, %struct.t2* %v2, i32 0, i32 0 187 %1 = load i16, i16* %a1, align 1 188 %conv2 = sext i16 %1 to i32 189 %add = add nsw i32 %conv, %conv2 190 %a3 = getelementptr inbounds %struct.t3, %struct.t3* %v3, i32 0, i32 0 191 %2 = load i16, i16* %a3, align 1 192 %conv4 = sext i16 %2 to i32 193 %add5 = add nsw i32 %add, %conv4 194 %a6 = getelementptr inbounds %struct.t4, %struct.t4* %v4, i32 0, i32 0 195 %3 = load i32, i32* %a6, align 1 196 %add7 = add nsw i32 %add5, %3 197 %a8 = getelementptr inbounds %struct.t5, %struct.t5* %v5, i32 0, i32 0 198 %4 = load i32, i32* %a8, align 1 199 %add9 = add nsw i32 %add7, %4 200 %a10 = getelementptr inbounds %struct.t6, %struct.t6* %v6, i32 0, i32 0 201 %5 = load i32, i32* %a10, align 1 202 %add11 = add nsw i32 %add9, %5 203 %a12 = getelementptr inbounds %struct.t7, %struct.t7* %v7, i32 0, i32 0 204 %6 = load i32, i32* %a12, align 1 205 %add13 = add nsw i32 %add11, %6 206 ret i32 %add13 207 208 ; CHECK: lha {{[0-9]+}}, 126(1) 209 ; CHECK: lha {{[0-9]+}}, 133(1) 210 ; CHECK: lbz {{[0-9]+}}, 119(1) 211 ; CHECK: lwz {{[0-9]+}}, 140(1) 212 ; CHECK: lwz {{[0-9]+}}, 147(1) 213 ; CHECK: lwz {{[0-9]+}}, 154(1) 214 ; CHECK: lwz {{[0-9]+}}, 161(1) 215 } 216