98 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt < %s -passes=instcombine -S | FileCheck %s3; RUN: opt < %s -passes=instcombine -S -data-layout=n32 | FileCheck %s4; RUN: opt < %s -passes=instcombine -S -data-layout=n32:64 | FileCheck %s5; RUN: opt < %s -passes=instcombine -S -data-layout=n32:64:128 | FileCheck %s6 7declare void @llvm.memcpy.p0.p0.i32(ptr nocapture, ptr nocapture, i32, i1) nounwind8 9; memcpy can be expanded inline with load/store (based on the datalayout?)10 11define void @copy_1_byte(ptr %d, ptr %s) {12; CHECK-LABEL: @copy_1_byte(13; CHECK-NEXT: [[TMP1:%.*]] = load i8, ptr [[S:%.*]], align 114; CHECK-NEXT: store i8 [[TMP1]], ptr [[D:%.*]], align 115; CHECK-NEXT: ret void16;17 call void @llvm.memcpy.p0.p0.i32(ptr %d, ptr %s, i32 1, i1 false)18 ret void19}20 21define void @copy_2_bytes(ptr %d, ptr %s) {22; CHECK-LABEL: @copy_2_bytes(23; CHECK-NEXT: [[TMP1:%.*]] = load i16, ptr [[S:%.*]], align 124; CHECK-NEXT: store i16 [[TMP1]], ptr [[D:%.*]], align 125; CHECK-NEXT: ret void26;27 call void @llvm.memcpy.p0.p0.i32(ptr %d, ptr %s, i32 2, i1 false)28 ret void29}30 31; We don't expand small non-power-of-2. Should we? Might be a target-dependent choice.32 33define void @copy_3_bytes(ptr %d, ptr %s) {34; CHECK-LABEL: @copy_3_bytes(35; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr noundef nonnull align 1 dereferenceable(3) [[D:%.*]], ptr noundef nonnull align 1 dereferenceable(3) [[S:%.*]], i32 3, i1 false)36; CHECK-NEXT: ret void37;38 call void @llvm.memcpy.p0.p0.i32(ptr %d, ptr %s, i32 3, i1 false)39 ret void40}41 42define void @copy_4_bytes(ptr %d, ptr %s) {43; CHECK-LABEL: @copy_4_bytes(44; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[S:%.*]], align 145; CHECK-NEXT: store i32 [[TMP1]], ptr [[D:%.*]], align 146; CHECK-NEXT: ret void47;48 call void @llvm.memcpy.p0.p0.i32(ptr %d, ptr %s, i32 4, i1 false)49 ret void50}51 52; We don't expand small non-power-of-2. Should we? Might be a target-dependent choice.53 54define void @copy_5_bytes(ptr %d, ptr %s) {55; CHECK-LABEL: @copy_5_bytes(56; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr noundef nonnull align 1 dereferenceable(5) [[D:%.*]], ptr noundef nonnull align 1 dereferenceable(5) [[S:%.*]], i32 5, i1 false)57; CHECK-NEXT: ret void58;59 call void @llvm.memcpy.p0.p0.i32(ptr %d, ptr %s, i32 5, i1 false)60 ret void61}62 63define void @copy_8_bytes(ptr %d, ptr %s) {64; CHECK-LABEL: @copy_8_bytes(65; CHECK-NEXT: [[TMP1:%.*]] = load i64, ptr [[S:%.*]], align 166; CHECK-NEXT: store i64 [[TMP1]], ptr [[D:%.*]], align 167; CHECK-NEXT: ret void68;69 call void @llvm.memcpy.p0.p0.i32(ptr %d, ptr %s, i32 8, i1 false)70 ret void71}72 73define void @copy_16_bytes(ptr %d, ptr %s) {74; CHECK-LABEL: @copy_16_bytes(75; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr noundef nonnull align 1 dereferenceable(16) [[D:%.*]], ptr noundef nonnull align 1 dereferenceable(16) [[S:%.*]], i32 16, i1 false)76; CHECK-NEXT: ret void77;78 call void @llvm.memcpy.p0.p0.i32(ptr %d, ptr %s, i32 16, i1 false)79 ret void80}81 82define void @copy_8_bytes_noalias(ptr %d, ptr %s) {83; CHECK-LABEL: @copy_8_bytes_noalias(84; CHECK-NEXT: [[TMP1:%.*]] = load i64, ptr [[S:%.*]], align 1, !alias.scope [[META0:![0-9]+]], !noalias [[META3:![0-9]+]]85; CHECK-NEXT: store i64 [[TMP1]], ptr [[D:%.*]], align 1, !alias.scope [[META0]], !noalias [[META3]]86; CHECK-NEXT: ret void87;88 call void @llvm.memcpy.p0.p0.i32(ptr %d, ptr %s, i32 8, i1 false), !alias.scope !4, !noalias !589 ret void90}91 92!0 = distinct !{!0, !"The domain"}93!1 = distinct !{!1}94!2 = !{!2, !0}95!3 = !{!3, !1}96!4 = !{!2}97!5 = !{!3}98