1 ; RUN: opt -memcpyopt -S < %s | FileCheck %s
3 declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i1) nounwind
5 @undef = internal constant i32 undef, align 4
6 define void @test_undef() nounwind {
7 %a = alloca i32, align 4
8 %i8 = bitcast i32* %a to i8*
9 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %i8, i8* align 4 bitcast (i32* @undef to i8*), i64 4, i1 false)
11 ; CHECK-LABEL: @test_undef(
12 ; CHECK: call void @llvm.memset
13 ; CHECK-NOT: call void @llvm.memcpy
17 @i32x3 = internal constant [3 x i32] [i32 -1, i32 -1, i32 -1], align 4
18 define void @test_i32x3() nounwind {
19 %a = alloca [3 x i32], align 4
20 %i8 = bitcast [3 x i32]* %a to i8*
21 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %i8, i8* align 4 bitcast ([3 x i32]* @i32x3 to i8*), i64 12, i1 false)
23 ; CHECK-LABEL: @test_i32x3(
24 ; CHECK: call void @llvm.memset
25 ; CHECK-NOT: call void @llvm.memcpy
29 @i32x3_undef = internal constant [3 x i32] [i32 -1, i32 undef, i32 -1], align 4
30 define void @test_i32x3_undef() nounwind {
31 %a = alloca [3 x i32], align 4
32 %i8 = bitcast [3 x i32]* %a to i8*
33 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %i8, i8* align 4 bitcast ([3 x i32]* @i32x3_undef to i8*), i64 12, i1 false)
35 ; CHECK-LABEL: @test_i32x3_undef(
36 ; CHECK: call void @llvm.memset
37 ; CHECK-NOT: call void @llvm.memcpy
41 %struct.bitfield = type { i8, [3 x i8] }
42 @bitfield = private unnamed_addr constant %struct.bitfield { i8 -86, [3 x i8] [i8 -86, i8 -86, i8 -86] }, align 4
43 define void @test_bitfield() nounwind {
44 %a = alloca %struct.bitfield, align 4
45 %i8 = bitcast %struct.bitfield* %a to i8*
46 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %i8, i8* align 4 bitcast (%struct.bitfield* @bitfield to i8*), i64 4, i1 false)
48 ; CHECK-LABEL: @test_bitfield(
49 ; CHECK: call void @llvm.memset
50 ; CHECK-NOT: call void @llvm.memcpy
54 @i1x16_zero = internal constant <16 x i1> <i1 0, i1 0, i1 0, i1 0, i1 0, i1 0, i1 0, i1 0, i1 0, i1 0, i1 0, i1 0, i1 0, i1 0, i1 0, i1 0>, align 4
55 define void @test_i1x16_zero() nounwind {
56 %a = alloca <16 x i1>, align 4
57 %i8 = bitcast <16 x i1>* %a to i8*
58 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %i8, i8* align 4 bitcast (<16 x i1>* @i1x16_zero to i8*), i64 16, i1 false)
60 ; CHECK-LABEL: @test_i1x16_zero(
61 ; CHECK: call void @llvm.memset
62 ; CHECK-NOT: call void @llvm.memcpy
66 ; i1 isn't currently handled. Should it?
67 @i1x16_one = internal constant <16 x i1> <i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1>, align 4
68 define void @test_i1x16_one() nounwind {
69 %a = alloca <16 x i1>, align 4
70 %i8 = bitcast <16 x i1>* %a to i8*
71 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %i8, i8* align 4 bitcast (<16 x i1>* @i1x16_one to i8*), i64 16, i1 false)
73 ; CHECK-LABEL: @test_i1x16_one(
74 ; CHECK-NOT: call void @llvm.memset
75 ; CHECK: call void @llvm.memcpy
79 @half = internal constant half 0xH0000, align 4
80 define void @test_half() nounwind {
81 %a = alloca half, align 4
82 %i8 = bitcast half* %a to i8*
83 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %i8, i8* align 4 bitcast (half* @half to i8*), i64 2, i1 false)
85 ; CHECK-LABEL: @test_half(
86 ; CHECK: call void @llvm.memset
87 ; CHECK-NOT: call void @llvm.memcpy