diff --git a/test/Transforms/GVN/2007-07-25-InfiniteLoop.ll b/test/Transforms/GVN/2007-07-25-InfiniteLoop.ll index 0ffb34c39b4..98fb6b3c382 100644 --- a/test/Transforms/GVN/2007-07-25-InfiniteLoop.ll +++ b/test/Transforms/GVN/2007-07-25-InfiniteLoop.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -basicaa -gvn -S | not grep "tmp10 =" +; RUN: opt < %s -basicaa -gvn -S | FileCheck %s %struct.INT2 = type { i32, i32 } @blkshifts = external global %struct.INT2* ; <%struct.INT2**> [#uses=2] @@ -10,5 +10,6 @@ entry: bb: ; preds = %bb, %entry %tmp10 = load %struct.INT2*, %struct.INT2** @blkshifts, align 4 ; <%struct.INT2*> [#uses=0] +; CHECK-NOT: %tmp10 br label %bb } diff --git a/test/Transforms/GVN/2007-07-26-PhiErasure.ll b/test/Transforms/GVN/2007-07-26-PhiErasure.ll index 82af521ab3d..e9dab2bbac0 100644 --- a/test/Transforms/GVN/2007-07-26-PhiErasure.ll +++ b/test/Transforms/GVN/2007-07-26-PhiErasure.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -gvn -S | not grep phi +; RUN: opt < %s -gvn -S | FileCheck %s %struct..0anon = type { i32 } %struct.FILE = type { i8*, i32, i32, i16, i16, %struct.__sbuf, i32, i8*, i32 (i8*)*, i32 (i8*, i8*, i32)*, i64 (i8*, i64, i32)*, i32 (i8*, i8*, i32)*, %struct.__sbuf, %struct.__sFILEX*, i32, [3 x i8], [1 x i8], %struct.__sbuf, i32, i64 } @@ -26,3 +26,19 @@ bb2982.preheader: ; preds = %cond_next2943 ret i32 %tmp298316 } + +; CHECK: define i32 @reload(%struct.rtx_def* %first, i32 %global, %struct.FILE* %dumpfile) { +; CHECK-NEXT: cond_next2835.1: +; CHECK-NEXT: br label %bb2928 +; CHECK: bb2928: +; CHECK-NEXT: br i1 false, label %bb2928.cond_next2943_crit_edge, label %cond_true2935 +; CHECK: bb2928.cond_next2943_crit_edge: +; CHECK-NEXT: br label %cond_next2943 +; CHECK: cond_true2935: +; CHECK-NEXT: br label %cond_next2943 +; CHECK: cond_next2943: +; CHECK-NEXT: br i1 false, label %bb2982.preheader, label %bb2928 +; CHECK: bb2982.preheader: +; CHECK-NEXT: %tmp298316 = load i32, i32* @n_spills, align 4 +; CHECK-NEXT: ret i32 %tmp298316 +; CHECK-NEXT: } diff --git a/test/Transforms/GVN/2007-07-31-NoDomInherit.ll b/test/Transforms/GVN/2007-07-31-NoDomInherit.ll index b2e4c64ee77..ebd6ea247ef 100644 --- a/test/Transforms/GVN/2007-07-31-NoDomInherit.ll +++ b/test/Transforms/GVN/2007-07-31-NoDomInherit.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -basicaa -gvn -S | grep "tmp47 = phi i32 " +; RUN: opt < %s -basicaa -gvn -S | FileCheck %s %struct.anon = type { i32 (i32, i32, i32)*, i32, i32, [3 x i32], i8*, i8*, i8* } @debug = external constant i32 ; [#uses=0] @@ -214,6 +214,7 @@ bb18: ; preds = %bb49 %tmp46 = load i32, i32* %i ; [#uses=1] call void @fix_operands( i32 %tmp46 ) %tmp47 = load i32, i32* %i ; [#uses=1] +; CHECK: %tmp47 = phi i32 [ %tmp48, %bb18 ], [ 0, %bb17 ] %tmp48 = add i32 %tmp47, 1 ; [#uses=1] store i32 %tmp48, i32* %i br label %bb49 diff --git a/test/Transforms/GVN/2007-07-31-RedundantPhi.ll b/test/Transforms/GVN/2007-07-31-RedundantPhi.ll index b285560e6a9..11ec736d2df 100644 --- a/test/Transforms/GVN/2007-07-31-RedundantPhi.ll +++ b/test/Transforms/GVN/2007-07-31-RedundantPhi.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -basicaa -gvn -S | not grep "tmp701 =" +; RUN: opt < %s -basicaa -gvn -S | FileCheck %s @img_width = external global i16 ; [#uses=2] @@ -18,5 +18,6 @@ cond_false470: ; preds = %cond_next449 cond_next698: ; preds = %cond_true492 %tmp701 = load i16, i16* @img_width, align 2 ; [#uses=0] +; CHECK-NOT: %tmp701 = ret i32 0 } diff --git a/test/Transforms/GVN/2008-02-12-UndefLoad.ll b/test/Transforms/GVN/2008-02-12-UndefLoad.ll index a1aed867ec6..0e6b17c4aa5 100644 --- a/test/Transforms/GVN/2008-02-12-UndefLoad.ll +++ b/test/Transforms/GVN/2008-02-12-UndefLoad.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -gvn -S | not grep load +; RUN: opt < %s -gvn -S | FileCheck %s ; PR1996 %struct.anon = type { i32, i8, i8, i8, i8 } @@ -9,6 +9,7 @@ entry: %tmp = getelementptr %struct.anon, %struct.anon* %c, i32 0, i32 0 ; [#uses=1] %tmp1 = getelementptr i32, i32* %tmp, i32 1 ; [#uses=2] %tmp2 = load i32, i32* %tmp1, align 4 ; [#uses=1] +; CHECK-NOT: load %tmp3 = or i32 %tmp2, 11 ; [#uses=1] %tmp4 = and i32 %tmp3, -21 ; [#uses=1] store i32 %tmp4, i32* %tmp1, align 4 diff --git a/test/Transforms/GVN/2008-07-02-Unreachable.ll b/test/Transforms/GVN/2008-07-02-Unreachable.ll index d9932644da3..0cd80e8da0c 100644 --- a/test/Transforms/GVN/2008-07-02-Unreachable.ll +++ b/test/Transforms/GVN/2008-07-02-Unreachable.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -basicaa -gvn -S | grep "ret i8 [%]tmp3" +; RUN: opt < %s -basicaa -gvn -S | FileCheck %s ; PR2503 @g_3 = external global i8 ; [#uses=2] @@ -29,6 +29,7 @@ forinc: ; preds = %forbody afterfor: ; preds = %forcond, %forcond.thread %tmp10 = load i8, i8* @g_3 ; [#uses=0] ret i8 %tmp10 +; CHECK: ret i8 %tmp3 ifend: ; preds = %afterfor, %ifthen ret i8 0 diff --git a/test/Transforms/GVN/2008-12-09-SelfRemove.ll b/test/Transforms/GVN/2008-12-09-SelfRemove.ll index d8ab1bae48e..b0468b4def6 100644 --- a/test/Transforms/GVN/2008-12-09-SelfRemove.ll +++ b/test/Transforms/GVN/2008-12-09-SelfRemove.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -gvn -S | grep getelementptr | count 1 +; RUN: opt < %s -gvn -S | FileCheck %s target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" target triple = "i386-apple-darwin9.5" @@ -24,3 +24,15 @@ bb21: ; preds = %bb21, %bb return: ; preds = %entry ret void } + +; CHECK: define void @d_print_mod_list(%struct.d_print_info* %dpi, %struct.d_print_mod* %mods, i32 %suffix) #0 { +; CHECK: entry: +; CHECK: %0 = getelementptr %struct.d_print_info, %struct.d_print_info* %dpi, i32 0, i32 1 +; CHECK: br i1 false, label %return, label %bb +; CHECK: bb: +; CHECK: br label %bb21 +; CHECK: bb21: +; CHECK: br label %bb21 +; CHECK: return: +; CHECK: ret void +; CHECK: } diff --git a/test/Transforms/GVN/2009-06-17-InvalidPRE.ll b/test/Transforms/GVN/2009-06-17-InvalidPRE.ll index bf0a234da4a..ec592b0e9e8 100644 --- a/test/Transforms/GVN/2009-06-17-InvalidPRE.ll +++ b/test/Transforms/GVN/2009-06-17-InvalidPRE.ll @@ -1,4 +1,5 @@ -; RUN: opt < %s -gvn -enable-load-pre -S | not grep pre1 +; RUN: opt < %s -gvn -enable-load-pre -S | FileCheck %s +; CHECK-NOT: pre1 ; GVN load pre was hoisting the loads at %13 and %16 up to bb4.outer. ; This is invalid as it bypasses the check for %m.0.ph==null in bb4. ; ModuleID = 'mbuf.c' diff --git a/test/Transforms/GVN/basic.ll b/test/Transforms/GVN/basic.ll index 3e74f50990e..44b32130631 100644 --- a/test/Transforms/GVN/basic.ll +++ b/test/Transforms/GVN/basic.ll @@ -1,5 +1,5 @@ -; RUN: opt < %s -gvn -S | not grep "%z2 =" -; RUN: opt < %s -passes=gvn -S | not grep "%z2 =" +; RUN: opt < %s -gvn -S | FileCheck %s +; RUN: opt < %s -passes=gvn -S | FileCheck %s define i32 @main() { block1: @@ -9,3 +9,8 @@ block2: %z2 = bitcast i32 0 to i32 ret i32 %z2 } + +; CHECK: define i32 @main() { +; CHECK-NEXT: block1: +; CHECK-NEXT: ret i32 0 +; CHECK-NEXT: } diff --git a/test/Transforms/GVN/bitcast-of-call.ll b/test/Transforms/GVN/bitcast-of-call.ll index 55b4b6e9d31..930e4d7373d 100644 --- a/test/Transforms/GVN/bitcast-of-call.ll +++ b/test/Transforms/GVN/bitcast-of-call.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -gvn -S | not grep tmp2 +; RUN: opt < %s -gvn -S | FileCheck %s ; PR2213 define i32* @f(i8* %x) { @@ -6,6 +6,7 @@ entry: %tmp = call i8* @m( i32 12 ) ; [#uses=2] %tmp1 = bitcast i8* %tmp to i32* ; [#uses=0] %tmp2 = bitcast i8* %tmp to i32* ; [#uses=0] +; CHECK-NOT: %tmp2 ret i32* %tmp2 } diff --git a/test/Transforms/GVN/calls-nonlocal.ll b/test/Transforms/GVN/calls-nonlocal.ll index 24ef2e9ec41..d3c03d6c78d 100644 --- a/test/Transforms/GVN/calls-nonlocal.ll +++ b/test/Transforms/GVN/calls-nonlocal.ll @@ -1,4 +1,5 @@ -; RUN: opt < %s -basicaa -gvn -S | grep strlen | count 2 +; Two occurrences of strlen should be zapped. +; RUN: opt < %s -basicaa -gvn -S | FileCheck %s target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" target triple = "i386-apple-darwin9" @@ -46,4 +47,29 @@ return: ; preds = %bb27 ret i32 %tmp.0 } +; CHECK: define i32 @test(i32 %g, i8* %P) #0 { +; CHECK: entry: +; CHECK: %tmp2 = call i32 @strlen(i8* %P) #1 +; CHECK: %tmp3 = icmp eq i32 %tmp2, 100 +; CHECK: %tmp34 = zext i1 %tmp3 to i8 +; CHECK: br i1 %tmp3, label %bb, label %bb6 +; CHECK: bb: +; CHECK: br label %bb27 +; CHECK: bb6: +; CHECK: %tmp8 = add i32 %g, 42 +; CHECK: br i1 false, label %bb14, label %bb16 +; CHECK: bb14: +; CHECK: br label %bb27 +; CHECK: bb16: +; CHECK: %tmp18 = mul i32 %tmp8, 2 +; CHECK: br i1 false, label %bb24, label %bb26 +; CHECK: bb24: +; CHECK: br label %bb27 +; CHECK: bb26: +; CHECK: br label %bb27 +; CHECK: bb27: +; CHECK: %tmp.0 = phi i32 [ 11, %bb26 ], [ undef, %bb24 ], [ undef, %bb14 ], [ %g, %bb ] +; CHECK: ret i32 %tmp.0 +; CHECK: } + declare i32 @strlen(i8*) nounwind readonly diff --git a/test/Transforms/GVN/calls-readonly.ll b/test/Transforms/GVN/calls-readonly.ll index ba8ad661eab..35b69d49ac7 100644 --- a/test/Transforms/GVN/calls-readonly.ll +++ b/test/Transforms/GVN/calls-readonly.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -basicaa -gvn -S | grep "call.*strlen" | count 1 +; RUN: opt < %s -basicaa -gvn -S | FileCheck %s ; Should delete the second call to strlen even though the intervening strchr call exists. target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" @@ -24,6 +24,22 @@ bb1: ; preds = %bb, %entry ret i8* %6 } +; CHECK: define i8* @test(i8* %P, i8* %Q, i32 %x, i32 %y) #0 { +; CHECK: entry: +; CHECK-NEXT: %0 = tail call i32 @strlen(i8* %P) +; CHECK-NEXT: %1 = icmp eq i32 %0, 0 +; CHECK-NEXT: br i1 %1, label %bb, label %bb1 +; CHECK: bb: +; CHECK-NEXT: %2 = sdiv i32 %x, %y +; CHECK-NEXT: br label %bb1 +; CHECK: bb1: +; CHECK-NEXT: %x_addr.0 = phi i32 [ %2, %bb ], [ %x, %entry ] +; CHECK-NEXT: %3 = tail call i8* @strchr(i8* %Q, i32 97) +; CHECK-NEXT: %4 = add i32 %x_addr.0, %0 +; CHECK-NEXT: %5 = getelementptr i8, i8* %3, i32 %x_addr.0 +; CHECK-NEXT: ret i8* %5 +; CHECK: } + declare i32 @strlen(i8*) nounwind readonly declare i8* @strchr(i8*, i32) nounwind readonly diff --git a/test/Transforms/GVN/load-constant-mem.ll b/test/Transforms/GVN/load-constant-mem.ll index f870485630f..a61c83d3304 100644 --- a/test/Transforms/GVN/load-constant-mem.ll +++ b/test/Transforms/GVN/load-constant-mem.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -basicaa -gvn -instcombine -S | grep "ret i32 0" +; RUN: opt < %s -basicaa -gvn -instcombine -S | FileCheck %s ; PR4189 @G = external constant [4 x i32] @@ -11,3 +11,9 @@ entry: %C = sub i32 %A, %B ret i32 %C } + +; CHECK: define i32 @test(i8* %p, i32 %i) #0 { +; CHECK-NEXT: entry: +; CHECK-NEXT: store i8 4, i8* %p, align 1 +; CHECK-NEXT: ret i32 0 +; CHECK-NEXT: } diff --git a/test/Transforms/GVN/local-pre.ll b/test/Transforms/GVN/local-pre.ll index 2c92699dca9..943f351f17a 100644 --- a/test/Transforms/GVN/local-pre.ll +++ b/test/Transforms/GVN/local-pre.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -gvn -enable-pre -S | grep "b.pre" +; RUN: opt < %s -gvn -enable-pre -S | FileCheck %s define i32 @main(i32 %p, i32 %q) { block1: @@ -11,8 +11,12 @@ block2: block3: br label %block4 +; CHECK: %.pre = add i32 %p, 1 +; CHECK-NEXT: br label %block4 block4: %b = add i32 %p, 1 ret i32 %b +; CHECK: %b.pre-phi = phi i32 [ %.pre, %block3 ], [ %a, %block2 ] +; CHECK-NEXT: ret i32 %b.pre-phi } diff --git a/test/Transforms/GVN/nonescaping-malloc.ll b/test/Transforms/GVN/nonescaping-malloc.ll index f83b317fade..250e27c88f4 100644 --- a/test/Transforms/GVN/nonescaping-malloc.ll +++ b/test/Transforms/GVN/nonescaping-malloc.ll @@ -1,7 +1,9 @@ ; REQUIRES: asserts -; RUN: opt < %s -basicaa -gvn -stats -disable-output 2>&1 | grep "Number of loads deleted" +; RUN: opt < %s -basicaa -gvn -stats -disable-output 2>&1 | FileCheck %s ; rdar://7363102 +; CHECK: Number of loads deleted + ; GVN should be able to eliminate load %tmp22.i, because it is redundant with ; load %tmp8.i. This requires being able to prove that %tmp7.i doesn't ; alias the malloc'd value %tmp.i20.i.i, which it can do since %tmp7.i diff --git a/test/Transforms/GVN/pre-basic-add.ll b/test/Transforms/GVN/pre-basic-add.ll index fa4e2e3abde..f4000c56c35 100644 --- a/test/Transforms/GVN/pre-basic-add.ll +++ b/test/Transforms/GVN/pre-basic-add.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -gvn -enable-pre -S | grep ".pre" +; RUN: opt < %s -gvn -enable-pre -S | FileCheck %s @H = common global i32 0 ; [#uses=2] @G = common global i32 0 ; [#uses=1] @@ -12,6 +12,7 @@ entry: bb: ; preds = %entry %3 = add i32 %0, 42 ; [#uses=1] +; CHECK: %.pre = add i32 %0, 42 store i32 %3, i32* @G, align 4 br label %bb1 @@ -20,6 +21,10 @@ bb1: ; preds = %bb, %entry store i32 %4, i32* @H, align 4 br label %return +; CHECK: %.pre-phi = phi i32 [ %.pre, %entry.bb1_crit_edge ], [ %3, %bb ] +; CHECK-NEXT: store i32 %.pre-phi, i32* @H, align 4 +; CHECK-NEXT: ret i32 0 + return: ; preds = %bb1 ret i32 0 } diff --git a/test/Transforms/GVN/rle-must-alias.ll b/test/Transforms/GVN/rle-must-alias.ll index bf8b139a2e8..e5fafd9d6b3 100644 --- a/test/Transforms/GVN/rle-must-alias.ll +++ b/test/Transforms/GVN/rle-must-alias.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -basicaa -gvn -S | grep "DEAD = phi i32 " +; RUN: opt < %s -basicaa -gvn -S | FileCheck %s ; GVN should eliminate the fully redundant %9 GEP which ; allows DEAD to be removed. This is PR3198. @@ -33,6 +33,7 @@ bb1: ; preds = %entry bb3: ; preds = %bb1, %bb %9 = getelementptr [100 x i32], [100 x i32]* @H, i32 0, i32 %i ; [#uses=1] %DEAD = load i32, i32* %9, align 4 ; [#uses=1] +; CHECK: %DEAD = phi i32 [ 0, %bb1 ], [ %4, %bb ] ret i32 %DEAD bb4: ; preds = %bb1 diff --git a/test/Transforms/GVN/rle-semidominated.ll b/test/Transforms/GVN/rle-semidominated.ll index f80d040c93e..f9704d3efbf 100644 --- a/test/Transforms/GVN/rle-semidominated.ll +++ b/test/Transforms/GVN/rle-semidominated.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -basicaa -gvn -S | grep "DEAD = phi i32 " +; RUN: opt < %s -basicaa -gvn -S | FileCheck %s define i32 @main(i32* %p, i32 %x, i32 %y) { block1: @@ -18,3 +18,19 @@ block4: %DEAD = load i32, i32* %p ret i32 %DEAD } + +; CHECK: define i32 @main(i32* %p, i32 %x, i32 %y) { +; CHECK-NEXT: block1: +; CHECK-NOT: %z = load i32, i32* %p +; CHECK-NEXT: %cmp = icmp eq i32 %x, %y +; CHECK-NEXT: br i1 %cmp, label %block2, label %block3 +; CHECK: block2: +; CHECK-NEXT: %DEAD.pre = load i32, i32* %p +; CHECK-NEXT: br label %block4 +; CHECK: block3: +; CHECK-NEXT: store i32 0, i32* %p +; CHECK-NEXT: br label %block4 +; CHECK: block4: +; CHECK-NEXT: %DEAD = phi i32 [ 0, %block3 ], [ %DEAD.pre, %block2 ] +; CHECK-NEXT: ret i32 %DEAD +; CHECK-NEXT: }