diff options
Diffstat (limited to 'test/Transforms/GVN')
| -rw-r--r-- | test/Transforms/GVN/PRE/rle-addrspace-cast.ll | 2 | ||||
| -rw-r--r-- | test/Transforms/GVN/PRE/rle.ll | 4 | ||||
| -rw-r--r-- | test/Transforms/GVN/cond_br2.ll | 8 | ||||
| -rw-r--r-- | test/Transforms/GVN/debugloc.ll | 77 | ||||
| -rw-r--r-- | test/Transforms/GVN/fence.ll | 20 | ||||
| -rw-r--r-- | test/Transforms/GVN/invariant.group.ll | 6 | ||||
| -rw-r--r-- | test/Transforms/GVN/lifetime-simple.ll | 8 |
7 files changed, 111 insertions, 14 deletions
diff --git a/test/Transforms/GVN/PRE/rle-addrspace-cast.ll b/test/Transforms/GVN/PRE/rle-addrspace-cast.ll index 07fd7c11d1b50..d8de5b360ba18 100644 --- a/test/Transforms/GVN/PRE/rle-addrspace-cast.ll +++ b/test/Transforms/GVN/PRE/rle-addrspace-cast.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -default-data-layout="e-p:32:32:32-p1:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-n8:16:32" -basicaa -gvn -S -die | FileCheck %s +; RUN: opt < %s -data-layout="e-p:32:32:32-p1:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-n8:16:32" -basicaa -gvn -S -die | FileCheck %s define i8 @coerce_offset0_addrspacecast(i32 %V, i32* %P) { store i32 %V, i32* %P diff --git a/test/Transforms/GVN/PRE/rle.ll b/test/Transforms/GVN/PRE/rle.ll index c1946faab20e3..1d2cba2f1f646 100644 --- a/test/Transforms/GVN/PRE/rle.ll +++ b/test/Transforms/GVN/PRE/rle.ll @@ -1,5 +1,5 @@ -; RUN: opt < %s -default-data-layout="e-p:32:32:32-p1:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-n8:16:32" -basicaa -gvn -S -die | FileCheck %s -; RUN: opt < %s -default-data-layout="E-p:32:32:32-p1:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-n32" -basicaa -gvn -S -die | FileCheck %s +; RUN: opt < %s -data-layout="e-p:32:32:32-p1:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-n8:16:32" -basicaa -gvn -S -die | FileCheck %s +; RUN: opt < %s -data-layout="E-p:32:32:32-p1:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-n32" -basicaa -gvn -S -die | FileCheck %s ;; Trivial RLE test. define i32 @test0(i32 %V, i32* %P) { diff --git a/test/Transforms/GVN/cond_br2.ll b/test/Transforms/GVN/cond_br2.ll index baa282ec200cf..a3749510cb4ac 100644 --- a/test/Transforms/GVN/cond_br2.ll +++ b/test/Transforms/GVN/cond_br2.ll @@ -18,7 +18,7 @@ define void @_Z4testv() #0 personality i8* bitcast (i32 (...)* @__gxx_personalit entry: %sv = alloca %"class.llvm::SmallVector", align 16 %0 = bitcast %"class.llvm::SmallVector"* %sv to i8* - call void @llvm.lifetime.start(i64 64, i8* %0) #1 + call void @llvm.lifetime.start.p0i8(i64 64, i8* %0) #1 %BeginX.i.i.i.i.i.i = getelementptr inbounds %"class.llvm::SmallVector", %"class.llvm::SmallVector"* %sv, i64 0, i32 0, i32 0, i32 0, i32 0, i32 0 %FirstEl.i.i.i.i.i.i = getelementptr inbounds %"class.llvm::SmallVector", %"class.llvm::SmallVector"* %sv, i64 0, i32 0, i32 0, i32 0, i32 0, i32 3 %1 = bitcast %"union.llvm::SmallVectorBase::U"* %FirstEl.i.i.i.i.i.i to i8* @@ -94,7 +94,7 @@ if.then.i.i.i20: ; preds = %invoke.cont3 br label %_ZN4llvm11SmallVectorIiLj8EED1Ev.exit21 _ZN4llvm11SmallVectorIiLj8EED1Ev.exit21: ; preds = %invoke.cont3, %if.then.i.i.i20 - call void @llvm.lifetime.end(i64 64, i8* %0) #1 + call void @llvm.lifetime.end.p0i8(i64 64, i8* %0) #1 ret void lpad: ; preds = %if.end.i14, %if.end.i, %invoke.cont2 @@ -113,14 +113,14 @@ eh.resume: ; preds = %if.then.i.i.i, %lpa } ; Function Attrs: nounwind -declare void @llvm.lifetime.start(i64, i8* nocapture) #1 +declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #1 declare i32 @__gxx_personality_v0(...) declare void @_Z1gRN4llvm11SmallVectorIiLj8EEE(%"class.llvm::SmallVector"*) #2 ; Function Attrs: nounwind -declare void @llvm.lifetime.end(i64, i8* nocapture) #1 +declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #1 declare void @_ZN4llvm15SmallVectorBase8grow_podEmm(%"class.llvm::SmallVectorBase"*, i64, i64) #2 diff --git a/test/Transforms/GVN/debugloc.ll b/test/Transforms/GVN/debugloc.ll new file mode 100644 index 0000000000000..d8c1632d14421 --- /dev/null +++ b/test/Transforms/GVN/debugloc.ll @@ -0,0 +1,77 @@ +; RUN: opt < %s -gvn -S | FileCheck %s +; CHECK: {{^}}for.body: +; CHECK-NEXT: [[VREG1:%[^ ]+]] = phi{{.*}}[[VREG2:%[^ ]+]],{{.*}}%.sink, +; CHECK-NOT: !dbg +; CHECK-SAME: {{$}} +; CHECK: {{^}}for.inc: +; CHECK-NEXT: [[VREG2]] = phi{{.*}}%inc,{{.*}}[[VREG1]] + +target triple = "x86_64-unknown-linux-gnu" + +@g = external local_unnamed_addr global i32, align 4 + +; Function Attrs: nounwind uwtable +define void @foo(i32 %x, i32 %y, i32 %z) local_unnamed_addr #0 !dbg !4 { +entry: + %not.tobool = icmp eq i32 %x, 0, !dbg !8 + %.sink = zext i1 %not.tobool to i32, !dbg !8 + store i32 %.sink, i32* @g, align 4, !tbaa !9 + %cmp8 = icmp sgt i32 %y, 0, !dbg !13 + br i1 %cmp8, label %for.body.preheader, label %for.end, !dbg !17 + +for.body.preheader: ; preds = %entry + br label %for.body, !dbg !19 + +for.body: ; preds = %for.body.preheader, %for.inc + %i.09 = phi i32 [ %inc4, %for.inc ], [ 0, %for.body.preheader ] + %cmp1 = icmp sgt i32 %i.09, %z, !dbg !19 + br i1 %cmp1, label %if.then2, label %for.inc, !dbg !21 + +if.then2: ; preds = %for.body + %0 = load i32, i32* @g, align 4, !dbg !22, !tbaa !9 + %inc = add nsw i32 %0, 1, !dbg !22 + store i32 %inc, i32* @g, align 4, !dbg !22, !tbaa !9 + br label %for.inc, !dbg !23 + +for.inc: ; preds = %for.body, %if.then2 + %inc4 = add nuw nsw i32 %i.09, 1, !dbg !24 + %exitcond = icmp ne i32 %inc4, %y, !dbg !13 + br i1 %exitcond, label %for.body, label %for.end.loopexit, !dbg !17 + +for.end.loopexit: ; preds = %for.inc + br label %for.end, !dbg !26 + +for.end: ; preds = %for.end.loopexit, %entry + ret void, !dbg !26 +} + +!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1) +!1 = !DIFile(filename: "foo.c", directory: "b/") +!2 = !{i32 2, !"Dwarf Version", i32 4} +!3 = !{i32 2, !"Debug Info Version", i32 3} +!4 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 3, type: !5, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, unit: !0) +!5 = !DISubroutineType(types: !6) +!6 = !{null, !7, !7, !7} +!7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!8 = !DILocation(line: 4, column: 7, scope: !4) +!9 = !{!10, !10, i64 0} +!10 = !{!"int", !11, i64 0} +!11 = !{!"omnipotent char", !12, i64 0} +!12 = !{!"Simple C/C++ TBAA"} +!13 = !DILocation(line: 10, column: 13, scope: !14) +!14 = !DILexicalBlockFile(scope: !15, file: !1, discriminator: 1) +!15 = distinct !DILexicalBlock(scope: !16, file: !1, line: 10, column: 3) +!16 = distinct !DILexicalBlock(scope: !4, file: !1, line: 10, column: 3) +!17 = !DILocation(line: 10, column: 3, scope: !18) +!18 = !DILexicalBlockFile(scope: !16, file: !1, discriminator: 1) +!19 = !DILocation(line: 11, column: 11, scope: !20) +!20 = distinct !DILexicalBlock(scope: !15, file: !1, line: 11, column: 9) +!21 = !DILocation(line: 11, column: 9, scope: !15) +!22 = !DILocation(line: 12, column: 8, scope: !20) +!23 = !DILocation(line: 12, column: 7, scope: !20) +!24 = !DILocation(line: 10, column: 20, scope: !25) +!25 = !DILexicalBlockFile(scope: !15, file: !1, discriminator: 2) +!26 = !DILocation(line: 13, column: 1, scope: !4) + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!2, !3} diff --git a/test/Transforms/GVN/fence.ll b/test/Transforms/GVN/fence.ll index f68861dad1ac6..a2d98e13b3800 100644 --- a/test/Transforms/GVN/fence.ll +++ b/test/Transforms/GVN/fence.ll @@ -1,5 +1,6 @@ ; RUN: opt -S -basicaa -gvn < %s | FileCheck %s +@a = external constant i32 ; We can value forward across the fence since we can (semantically) ; reorder the following load before the fence. define i32 @test(i32* %addr.i) { @@ -52,6 +53,25 @@ define i32 @test3(i32* noalias %addr.i, i32* noalias %otheraddr) { ret i32 %res } +; We can forward the value forward the load +; across both the fences, because the load is from +; a constant memory location. +define i32 @test4(i32* %addr) { +; CHECK-LABEL: @test4 +; CHECK-NOT: load +; CHECK: fence release +; CHECK: store +; CHECK: fence seq_cst +; CHECK: ret i32 0 + %var = load i32, i32* @a + fence release + store i32 42, i32* %addr, align 8 + fence seq_cst + %var2 = load i32, i32* @a + %var3 = sub i32 %var, %var2 + ret i32 %var3 +} + ; Another example of why forwarding across an acquire fence is problematic ; can be seen in a normal locking operation. Say we had: ; *p = 5; unlock(l); lock(l); use(p); diff --git a/test/Transforms/GVN/invariant.group.ll b/test/Transforms/GVN/invariant.group.ll index 6f1f357cad656..570519bec520c 100644 --- a/test/Transforms/GVN/invariant.group.ll +++ b/test/Transforms/GVN/invariant.group.ll @@ -382,12 +382,12 @@ define void @testNotGlobal() { %b0 = bitcast i8* %a to i1* call void @fooBit(i1* %b0, i1 1) -; CHECK: %trunc = trunc i8 %b to i1 +; CHECK: %1 = trunc i8 %b to i1 %2 = load i1, i1* %b0, !invariant.group !0 -; CHECK-NEXT: call void @fooBit(i1* %b0, i1 %trunc) +; CHECK-NEXT: call void @fooBit(i1* %b0, i1 %1) call void @fooBit(i1* %b0, i1 %2) %3 = load i1, i1* %b0, !invariant.group !0 -; CHECK-NEXT: call void @fooBit(i1* %b0, i1 %trunc) +; CHECK-NEXT: call void @fooBit(i1* %b0, i1 %1) call void @fooBit(i1* %b0, i1 %3) ret void } diff --git a/test/Transforms/GVN/lifetime-simple.ll b/test/Transforms/GVN/lifetime-simple.ll index d03b62c8158a5..8da3e4cbd30f0 100644 --- a/test/Transforms/GVN/lifetime-simple.ll +++ b/test/Transforms/GVN/lifetime-simple.ll @@ -8,13 +8,13 @@ define i8 @test(i8* %P) nounwind { ; CHECK-NOT: load ; CHECK: lifetime.end entry: - call void @llvm.lifetime.start(i64 32, i8* %P) + call void @llvm.lifetime.start.p0i8(i64 32, i8* %P) %0 = load i8, i8* %P store i8 1, i8* %P - call void @llvm.lifetime.end(i64 32, i8* %P) + call void @llvm.lifetime.end.p0i8(i64 32, i8* %P) %1 = load i8, i8* %P ret i8 %1 } -declare void @llvm.lifetime.start(i64 %S, i8* nocapture %P) readonly -declare void @llvm.lifetime.end(i64 %S, i8* nocapture %P) +declare void @llvm.lifetime.start.p0i8(i64 %S, i8* nocapture %P) readonly +declare void @llvm.lifetime.end.p0i8(i64 %S, i8* nocapture %P) |
