1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -memcpyopt -S < %s -verify-memoryssa | FileCheck %s
4 declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i1) nounwind
6 @undef = internal constant i32 undef, align 4
7 define void @test_undef() nounwind {
8 ; CHECK-LABEL: @test_undef(
9 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
10 ; CHECK-NEXT: [[I8:%.*]] = bitcast i32* [[A]] to i8*
11 ; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 4 [[I8]], i8 undef, i64 4, i1 false)
12 ; CHECK-NEXT: ret void
14 %a = alloca i32, align 4
15 %i8 = bitcast i32* %a to i8*
16 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %i8, i8* align 4 bitcast (i32* @undef to i8*), i64 4, i1 false)
20 @i32x3 = internal constant [3 x i32] [i32 -1, i32 -1, i32 -1], align 4
21 define void @test_i32x3() nounwind {
22 ; CHECK-LABEL: @test_i32x3(
23 ; CHECK-NEXT: [[A:%.*]] = alloca [3 x i32], align 4
24 ; CHECK-NEXT: [[I8:%.*]] = bitcast [3 x i32]* [[A]] to i8*
25 ; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 4 [[I8]], i8 -1, i64 12, i1 false)
26 ; CHECK-NEXT: ret void
28 %a = alloca [3 x i32], align 4
29 %i8 = bitcast [3 x i32]* %a to i8*
30 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)
34 @i32x3_undef = internal constant [3 x i32] [i32 -1, i32 undef, i32 -1], align 4
35 define void @test_i32x3_undef() nounwind {
36 ; CHECK-LABEL: @test_i32x3_undef(
37 ; CHECK-NEXT: [[A:%.*]] = alloca [3 x i32], align 4
38 ; CHECK-NEXT: [[I8:%.*]] = bitcast [3 x i32]* [[A]] to i8*
39 ; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 4 [[I8]], i8 -1, i64 12, i1 false)
40 ; CHECK-NEXT: ret void
42 %a = alloca [3 x i32], align 4
43 %i8 = bitcast [3 x i32]* %a to i8*
44 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)
48 %struct.bitfield = type { i8, [3 x i8] }
49 @bitfield = private unnamed_addr constant %struct.bitfield { i8 -86, [3 x i8] [i8 -86, i8 -86, i8 -86] }, align 4
50 define void @test_bitfield() nounwind {
51 ; CHECK-LABEL: @test_bitfield(
52 ; CHECK-NEXT: [[A:%.*]] = alloca [[STRUCT_BITFIELD:%.*]], align 4
53 ; CHECK-NEXT: [[I8:%.*]] = bitcast %struct.bitfield* [[A]] to i8*
54 ; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 4 [[I8]], i8 -86, i64 4, i1 false)
55 ; CHECK-NEXT: ret void
57 %a = alloca %struct.bitfield, align 4
58 %i8 = bitcast %struct.bitfield* %a to i8*
59 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %i8, i8* align 4 bitcast (%struct.bitfield* @bitfield to i8*), i64 4, i1 false)
63 @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
64 define void @test_i1x16_zero() nounwind {
65 ; CHECK-LABEL: @test_i1x16_zero(
66 ; CHECK-NEXT: [[A:%.*]] = alloca <16 x i1>, align 4
67 ; CHECK-NEXT: [[I8:%.*]] = bitcast <16 x i1>* [[A]] to i8*
68 ; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 4 [[I8]], i8 0, i64 16, i1 false)
69 ; CHECK-NEXT: ret void
71 %a = alloca <16 x i1>, align 4
72 %i8 = bitcast <16 x i1>* %a to i8*
73 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)
77 ; i1 isn't currently handled. Should it?
78 @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
79 define void @test_i1x16_one() nounwind {
80 ; CHECK-LABEL: @test_i1x16_one(
81 ; CHECK-NEXT: [[A:%.*]] = alloca <16 x i1>, align 4
82 ; CHECK-NEXT: [[I8:%.*]] = bitcast <16 x i1>* [[A]] to i8*
83 ; CHECK-NEXT: 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)
84 ; CHECK-NEXT: ret void
86 %a = alloca <16 x i1>, align 4
87 %i8 = bitcast <16 x i1>* %a to i8*
88 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)
92 @half = internal constant half 0xH0000, align 4
93 define void @test_half() nounwind {
94 ; CHECK-LABEL: @test_half(
95 ; CHECK-NEXT: [[A:%.*]] = alloca half, align 4
96 ; CHECK-NEXT: [[I8:%.*]] = bitcast half* [[A]] to i8*
97 ; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 4 [[I8]], i8 0, i64 2, i1 false)
98 ; CHECK-NEXT: ret void
100 %a = alloca half, align 4
101 %i8 = bitcast half* %a to i8*
102 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %i8, i8* align 4 bitcast (half* @half to i8*), i64 2, i1 false)