OSDN Git Service

[LICM][NFC] Add tests from D50730
authorPhilip Reames <listmail@philipreames.com>
Tue, 21 Aug 2018 00:37:09 +0000 (00:37 +0000)
committerPhilip Reames <listmail@philipreames.com>
Tue, 21 Aug 2018 00:37:09 +0000 (00:37 +0000)
Landing tests so corresponding change can show effects clearly.  see
D50730 [AST] Generalize argument specific aliasing

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340243 91177308-0d34-0410-b5e6-96231b3b80d8

test/Transforms/LICM/argmemonly-call.ll

index b7d7d6a..c66391b 100644 (file)
@@ -95,3 +95,41 @@ loop:
   br label %loop
 }
 
+
+; memcpy doesn't write to it's source argument, so loads to that location
+; can still be hoisted
+define void @test6(i32* noalias %loc, i32* noalias %loc2) {
+; CHECK-LABEL: @test6
+; CHECK: %val = load i32, i32* %loc2
+; CHECK-LABEL: loop:
+; CHECK: @llvm.memcpy
+  br label %loop
+
+loop:
+  %val = load i32, i32* %loc2
+  store i32 %val, i32* %loc
+  %dest = bitcast i32* %loc to i8*
+  %src = bitcast i32* %loc2 to i8*
+  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dest, i8* %src, i64 8, i1 false)
+  br label %loop
+}
+
+; FIXME: argument aliasing should let us do this transform
+define void @test7(i32* noalias %loc, i32* noalias %loc2) {
+; CHECK-LABEL: @test7
+; CHECK-LABEL: loop:
+; CHECK: %val = load i32, i32* %loc2
+; CHECK: @custom_memcpy
+  br label %loop
+
+loop:
+  %val = load i32, i32* %loc2
+  store i32 %val, i32* %loc
+  %dest = bitcast i32* %loc to i8*
+  %src = bitcast i32* %loc2 to i8*
+  call void @custom_memcpy(i8* %dest, i8* %src)
+  br label %loop
+}
+
+declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i1)
+declare void @custom_memcpy(i8* nocapture writeonly, i8* nocapture readonly) argmemonly nounwind