1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals
2 ; RUN: opt -passes=instcombine -S < %s | FileCheck %s
4 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-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
6 declare void @llvm.memcpy.p0.p0.i64(ptr nocapture, ptr nocapture, i64, i1) nounwind
8 ; Verify that instcombine preserves TBAA tags when converting a memcpy into
9 ; a scalar load and store.
11 %struct.test1 = type { float }
13 define void @test1(ptr nocapture %a, ptr nocapture %b) {
14 ; CHECK-LABEL: @test1(
16 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[B:%.*]], align 4, !tbaa [[TBAA0:![0-9]+]]
17 ; CHECK-NEXT: store i32 [[TMP0]], ptr [[A:%.*]], align 4, !tbaa [[TBAA0]]
18 ; CHECK-NEXT: ret void
21 tail call void @llvm.memcpy.p0.p0.i64(ptr align 4 %a, ptr align 4 %b, i64 4, i1 false), !tbaa.struct !3
25 %struct.test2 = type { ptr }
28 ; CHECK-LABEL: @test2(
29 ; CHECK-NEXT: store i1 true, ptr poison, align 1
30 ; CHECK-NEXT: ret ptr poison
32 %tmp = alloca %struct.test2, align 8
33 call void @llvm.memcpy.p0.p0.i64(ptr align 8 %tmp, ptr align 8 undef, i64 8, i1 false), !tbaa.struct !4
34 %tmp3 = load ptr, ptr %tmp
38 define void @test3_multiple_fields(ptr nocapture %a, ptr nocapture %b) {
39 ; CHECK-LABEL: @test3_multiple_fields(
41 ; CHECK-NEXT: [[TMP0:%.*]] = load i64, ptr [[B:%.*]], align 4
42 ; CHECK-NEXT: store i64 [[TMP0]], ptr [[A:%.*]], align 4
43 ; CHECK-NEXT: ret void
46 tail call void @llvm.memcpy.p0.p0.i64(ptr align 4 %a, ptr align 4 %b, i64 8, i1 false), !tbaa.struct !6
50 define void @test4_multiple_copy_first_field(ptr nocapture %a, ptr nocapture %b) {
51 ; CHECK-LABEL: @test4_multiple_copy_first_field(
53 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[B:%.*]], align 4, !tbaa [[TBAA0]]
54 ; CHECK-NEXT: store i32 [[TMP0]], ptr [[A:%.*]], align 4, !tbaa [[TBAA0]]
55 ; CHECK-NEXT: ret void
58 tail call void @llvm.memcpy.p0.p0.i64(ptr align 4 %a, ptr align 4 %b, i64 4, i1 false), !tbaa.struct !6
62 define void @test5_multiple_copy_more_than_first_field(ptr nocapture %a, ptr nocapture %b) {
63 ; CHECK-LABEL: @test5_multiple_copy_more_than_first_field(
65 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[B:%.*]], align 4
66 ; CHECK-NEXT: store i32 [[TMP0]], ptr [[A:%.*]], align 4
67 ; CHECK-NEXT: ret void
70 tail call void @llvm.memcpy.p0.p0.i64(ptr align 4 %a, ptr align 4 %b, i64 4, i1 false), !tbaa.struct !7
74 !0 = !{!"Simple C/C++ TBAA"}
75 !1 = !{!"omnipotent char", !0}
77 !3 = !{i64 0, i64 4, !2}
78 !4 = !{i64 0, i64 8, null}
80 !6 = !{i64 0, i64 4, !2, i64 4, i64 4, !2}
81 !7 = !{i64 0, i64 2, !2, i64 4, i64 6, !2}
84 ; CHECK: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
86 ; CHECK: [[TBAA0]] = !{[[META1:![0-9]+]], [[META1]], i64 0}
87 ; CHECK: [[META1]] = !{!"float", [[META2:![0-9]+]]}
88 ; CHECK: [[META2]] = !{!"Simple C/C++ TBAA"}