[llvm] a10bf55 - [MemCpyOpt] Add additional tests for memcpy of undef (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 13 11:38:21 PST 2021
Author: Nikita Popov
Date: 2021-03-13T20:38:09+01:00
New Revision: a10bf5572d2ab11f5965e8a940343734b8802797
URL: https://github.com/llvm/llvm-project/commit/a10bf5572d2ab11f5965e8a940343734b8802797
DIFF: https://github.com/llvm/llvm-project/commit/a10bf5572d2ab11f5965e8a940343734b8802797.diff
LOG: [MemCpyOpt] Add additional tests for memcpy of undef (NFC)
Added:
Modified:
llvm/test/Transforms/MemCpyOpt/memcpy-undef.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/MemCpyOpt/memcpy-undef.ll b/llvm/test/Transforms/MemCpyOpt/memcpy-undef.ll
index 360ccde6c891..561c4cc3d645 100644
--- a/llvm/test/Transforms/MemCpyOpt/memcpy-undef.ll
+++ b/llvm/test/Transforms/MemCpyOpt/memcpy-undef.ll
@@ -1,6 +1,6 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt < %s -basic-aa -memcpyopt -S -enable-memcpyopt-memoryssa=0 | FileCheck %s
-; RUN: opt < %s -basic-aa -memcpyopt -S -enable-memcpyopt-memoryssa=1 -verify-memoryssa | FileCheck %s
+; RUN: opt < %s -basic-aa -memcpyopt -S -enable-memcpyopt-memoryssa=0 | FileCheck %s --check-prefixes=CHECK,NO-MSSA
+; RUN: opt < %s -basic-aa -memcpyopt -S -enable-memcpyopt-memoryssa=1 -verify-memoryssa | FileCheck %s --check-prefixes=CHECK,MSSA
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"
target triple = "x86_64-apple-macosx10.8.0"
@@ -65,6 +65,106 @@ define void @test_lifetime_may_alias(i8* %lifetime, i8* %src, i8* %dst) {
ret void
}
+; lifetime.start on full alloca size, copy in range.
+define void @test_lifetime_partial_alias_1(i8* noalias %dst) {
+; NO-MSSA-LABEL: @test_lifetime_partial_alias_1(
+; NO-MSSA-NEXT: [[A:%.*]] = alloca [16 x i8], align 1
+; NO-MSSA-NEXT: [[A_I8:%.*]] = bitcast [16 x i8]* [[A]] to i8*
+; NO-MSSA-NEXT: call void @llvm.lifetime.start.p0i8(i64 16, i8* [[A_I8]])
+; NO-MSSA-NEXT: [[GEP:%.*]] = getelementptr i8, i8* [[A_I8]], i64 8
+; NO-MSSA-NEXT: ret void
+;
+; MSSA-LABEL: @test_lifetime_partial_alias_1(
+; MSSA-NEXT: [[A:%.*]] = alloca [16 x i8], align 1
+; MSSA-NEXT: [[A_I8:%.*]] = bitcast [16 x i8]* [[A]] to i8*
+; MSSA-NEXT: call void @llvm.lifetime.start.p0i8(i64 16, i8* [[A_I8]])
+; MSSA-NEXT: [[GEP:%.*]] = getelementptr i8, i8* [[A_I8]], i64 8
+; MSSA-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[DST:%.*]], i8* [[GEP]], i64 8, i1 false)
+; MSSA-NEXT: ret void
+;
+ %a = alloca [16 x i8]
+ %a.i8 = bitcast [16 x i8]* %a to i8*
+ call void @llvm.lifetime.start.p0i8(i64 16, i8* %a.i8)
+ %gep = getelementptr i8, i8* %a.i8, i64 8
+ call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dst, i8* %gep, i64 8, i1 false)
+ ret void
+}
+
+; lifetime.start on full alloca size, copy out of range.
+define void @test_lifetime_partial_alias_2(i8* noalias %dst) {
+; NO-MSSA-LABEL: @test_lifetime_partial_alias_2(
+; NO-MSSA-NEXT: [[A:%.*]] = alloca [16 x i8], align 1
+; NO-MSSA-NEXT: [[A_I8:%.*]] = bitcast [16 x i8]* [[A]] to i8*
+; NO-MSSA-NEXT: call void @llvm.lifetime.start.p0i8(i64 16, i8* [[A_I8]])
+; NO-MSSA-NEXT: [[GEP:%.*]] = getelementptr i8, i8* [[A_I8]], i64 8
+; NO-MSSA-NEXT: ret void
+;
+; MSSA-LABEL: @test_lifetime_partial_alias_2(
+; MSSA-NEXT: [[A:%.*]] = alloca [16 x i8], align 1
+; MSSA-NEXT: [[A_I8:%.*]] = bitcast [16 x i8]* [[A]] to i8*
+; MSSA-NEXT: call void @llvm.lifetime.start.p0i8(i64 16, i8* [[A_I8]])
+; MSSA-NEXT: [[GEP:%.*]] = getelementptr i8, i8* [[A_I8]], i64 8
+; MSSA-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[DST:%.*]], i8* [[GEP]], i64 16, i1 false)
+; MSSA-NEXT: ret void
+;
+ %a = alloca [16 x i8]
+ %a.i8 = bitcast [16 x i8]* %a to i8*
+ call void @llvm.lifetime.start.p0i8(i64 16, i8* %a.i8)
+ %gep = getelementptr i8, i8* %a.i8, i64 8
+ call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dst, i8* %gep, i64 16, i1 false)
+ ret void
+}
+
+; lifetime.start on part of alloca, copy in range.
+define void @test_lifetime_partial_alias_3(i8* noalias %dst) {
+; NO-MSSA-LABEL: @test_lifetime_partial_alias_3(
+; NO-MSSA-NEXT: [[A:%.*]] = alloca [16 x i8], align 1
+; NO-MSSA-NEXT: [[A_I8:%.*]] = bitcast [16 x i8]* [[A]] to i8*
+; NO-MSSA-NEXT: call void @llvm.lifetime.start.p0i8(i64 12, i8* [[A_I8]])
+; NO-MSSA-NEXT: [[GEP:%.*]] = getelementptr i8, i8* [[A_I8]], i64 8
+; NO-MSSA-NEXT: ret void
+;
+; MSSA-LABEL: @test_lifetime_partial_alias_3(
+; MSSA-NEXT: [[A:%.*]] = alloca [16 x i8], align 1
+; MSSA-NEXT: [[A_I8:%.*]] = bitcast [16 x i8]* [[A]] to i8*
+; MSSA-NEXT: call void @llvm.lifetime.start.p0i8(i64 12, i8* [[A_I8]])
+; MSSA-NEXT: [[GEP:%.*]] = getelementptr i8, i8* [[A_I8]], i64 8
+; MSSA-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[DST:%.*]], i8* [[GEP]], i64 4, i1 false)
+; MSSA-NEXT: ret void
+;
+ %a = alloca [16 x i8]
+ %a.i8 = bitcast [16 x i8]* %a to i8*
+ call void @llvm.lifetime.start.p0i8(i64 12, i8* %a.i8)
+ %gep = getelementptr i8, i8* %a.i8, i64 8
+ call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dst, i8* %gep, i64 4, i1 false)
+ ret void
+}
+
+; lifetime.start on part of alloca, copy out of range.
+define void @test_lifetime_partial_alias_4(i8* noalias %dst) {
+; NO-MSSA-LABEL: @test_lifetime_partial_alias_4(
+; NO-MSSA-NEXT: [[A:%.*]] = alloca [16 x i8], align 1
+; NO-MSSA-NEXT: [[A_I8:%.*]] = bitcast [16 x i8]* [[A]] to i8*
+; NO-MSSA-NEXT: call void @llvm.lifetime.start.p0i8(i64 12, i8* [[A_I8]])
+; NO-MSSA-NEXT: [[GEP:%.*]] = getelementptr i8, i8* [[A_I8]], i64 8
+; NO-MSSA-NEXT: ret void
+;
+; MSSA-LABEL: @test_lifetime_partial_alias_4(
+; MSSA-NEXT: [[A:%.*]] = alloca [16 x i8], align 1
+; MSSA-NEXT: [[A_I8:%.*]] = bitcast [16 x i8]* [[A]] to i8*
+; MSSA-NEXT: call void @llvm.lifetime.start.p0i8(i64 12, i8* [[A_I8]])
+; MSSA-NEXT: [[GEP:%.*]] = getelementptr i8, i8* [[A_I8]], i64 8
+; MSSA-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[DST:%.*]], i8* [[GEP]], i64 8, i1 false)
+; MSSA-NEXT: ret void
+;
+ %a = alloca [16 x i8]
+ %a.i8 = bitcast [16 x i8]* %a to i8*
+ call void @llvm.lifetime.start.p0i8(i64 12, i8* %a.i8)
+ %gep = getelementptr i8, i8* %a.i8, i64 8
+ call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dst, i8* %gep, i64 8, i1 false)
+ ret void
+}
+
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i1) nounwind
declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) nounwind
More information about the llvm-commits
mailing list