1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=memcpyopt -S < %s -verify-memoryssa | FileCheck %s
4 declare void @llvm.memcpy.p0.p0.i64(ptr nocapture, ptr 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: call void @llvm.memset.p0.i64(ptr align 4 [[A]], i8 undef, i64 4, i1 false)
11 ; CHECK-NEXT: ret void
13 %a = alloca i32, align 4
14 call void @llvm.memcpy.p0.p0.i64(ptr align 4 %a, ptr align 4 @undef, i64 4, i1 false)
18 @i32x3 = internal constant [3 x i32] [i32 -1, i32 -1, i32 -1], align 4
19 define void @test_i32x3() nounwind {
20 ; CHECK-LABEL: @test_i32x3(
21 ; CHECK-NEXT: [[A:%.*]] = alloca [3 x i32], align 4
22 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 4 [[A]], i8 -1, i64 12, i1 false)
23 ; CHECK-NEXT: ret void
25 %a = alloca [3 x i32], align 4
26 call void @llvm.memcpy.p0.p0.i64(ptr align 4 %a, ptr align 4 @i32x3, i64 12, i1 false)
30 @i32x3_undef = internal constant [3 x i32] [i32 -1, i32 undef, i32 -1], align 4
31 define void @test_i32x3_undef() nounwind {
32 ; CHECK-LABEL: @test_i32x3_undef(
33 ; CHECK-NEXT: [[A:%.*]] = alloca [3 x i32], align 4
34 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 4 [[A]], i8 -1, i64 12, i1 false)
35 ; CHECK-NEXT: ret void
37 %a = alloca [3 x i32], align 4
38 call void @llvm.memcpy.p0.p0.i64(ptr align 4 %a, ptr align 4 @i32x3_undef, i64 12, i1 false)
42 %struct.bitfield = type { i8, [3 x i8] }
43 @bitfield = private unnamed_addr constant %struct.bitfield { i8 -86, [3 x i8] [i8 -86, i8 -86, i8 -86] }, align 4
44 define void @test_bitfield() nounwind {
45 ; CHECK-LABEL: @test_bitfield(
46 ; CHECK-NEXT: [[A:%.*]] = alloca [[STRUCT_BITFIELD:%.*]], align 4
47 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 4 [[A]], i8 -86, i64 4, i1 false)
48 ; CHECK-NEXT: ret void
50 %a = alloca %struct.bitfield, align 4
51 call void @llvm.memcpy.p0.p0.i64(ptr align 4 %a, ptr align 4 @bitfield, i64 4, i1 false)
55 @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
56 define void @test_i1x16_zero() nounwind {
57 ; CHECK-LABEL: @test_i1x16_zero(
58 ; CHECK-NEXT: [[A:%.*]] = alloca <16 x i1>, align 4
59 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 4 [[A]], i8 0, i64 16, i1 false)
60 ; CHECK-NEXT: ret void
62 %a = alloca <16 x i1>, align 4
63 call void @llvm.memcpy.p0.p0.i64(ptr align 4 %a, ptr align 4 @i1x16_zero, i64 16, i1 false)
67 ; i1 isn't currently handled. Should it?
68 @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
69 define void @test_i1x16_one() nounwind {
70 ; CHECK-LABEL: @test_i1x16_one(
71 ; CHECK-NEXT: [[A:%.*]] = alloca <16 x i1>, align 4
72 ; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 [[A]], ptr align 4 @i1x16_one, i64 16, i1 false)
73 ; CHECK-NEXT: ret void
75 %a = alloca <16 x i1>, align 4
76 call void @llvm.memcpy.p0.p0.i64(ptr align 4 %a, ptr align 4 @i1x16_one, i64 16, i1 false)
80 @half = internal constant half 0xH0000, align 4
81 define void @test_half() nounwind {
82 ; CHECK-LABEL: @test_half(
83 ; CHECK-NEXT: [[A:%.*]] = alloca half, align 4
84 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 4 [[A]], i8 0, i64 2, i1 false)
85 ; CHECK-NEXT: ret void
87 %a = alloca half, align 4
88 call void @llvm.memcpy.p0.p0.i64(ptr align 4 %a, ptr align 4 @half, i64 2, i1 false)