1 ; RUN: opt < %s -sroa -S | FileCheck %s
2 target datalayout = "e-p:64:64:64-p1:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-f80:128-v64:64:64-v128:128:128-a0:0:64-n8:16:32:64"
4 declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind
5 declare void @llvm.memset.p0i8.i32(i8* nocapture, i8, i32, i32, i1) nounwind
7 define void @no_split_on_non_byte_width(i32) {
8 ; This tests that allocas are not split into slices that are not byte width multiple
9 %arg = alloca i32 , align 8
10 store i32 %0, i32* %arg
14 ; CHECK-LABEL: load_i32:
15 ; CHECK-NOT: bitcast {{.*}} to i1
21 ; CHECK-LABEL: load_i1:
22 ; CHECK: bitcast {{.*}} to i1
23 %p1 = bitcast i32* %arg to i1*
28 ; PR18726: Check that we use memcpy and memset to fill out padding when we have
29 ; a slice with a simple single type whose store size is smaller than the slice
32 %union.Foo = type { x86_fp80, i64, i64 }
34 @foo_copy_source = external constant %union.Foo
35 @i64_sink = global i64 0
37 define void @memcpy_fp80_padding() {
38 %x = alloca %union.Foo
41 %x_i8 = bitcast %union.Foo* %x to i8*
42 call void @llvm.memcpy.p0i8.p0i8.i32(i8* %x_i8, i8* bitcast (%union.Foo* @foo_copy_source to i8*), i32 32, i32 16, i1 false)
44 ; Access a slice of the alloca to trigger SROA.
45 %mid_p = getelementptr %union.Foo* %x, i32 0, i32 1
46 %elt = load i64* %mid_p
47 store i64 %elt, i64* @i64_sink
50 ; CHECK-LABEL: define void @memcpy_fp80_padding
51 ; CHECK: alloca x86_fp80
52 ; CHECK: call void @llvm.memcpy.p0i8.p0i8.i32
53 ; CHECK: load i64* getelementptr inbounds (%union.Foo* @foo_copy_source, i64 0, i32 1)
54 ; CHECK: load i64* getelementptr inbounds (%union.Foo* @foo_copy_source, i64 0, i32 2)
56 define void @memset_fp80_padding() {
57 %x = alloca %union.Foo
60 %x_i8 = bitcast %union.Foo* %x to i8*
61 call void @llvm.memset.p0i8.i32(i8* %x_i8, i8 -1, i32 32, i32 16, i1 false)
63 ; Access a slice of the alloca to trigger SROA.
64 %mid_p = getelementptr %union.Foo* %x, i32 0, i32 1
65 %elt = load i64* %mid_p
66 store i64 %elt, i64* @i64_sink
69 ; CHECK-LABEL: define void @memset_fp80_padding
70 ; CHECK: alloca x86_fp80
71 ; CHECK: call void @llvm.memset.p0i8.i32(i8* %{{.*}}, i8 -1, i32 16, i32 16, i1 false)
72 ; CHECK: store i64 -1, i64* @i64_sink