[GVN] Use FileCheck instead of grep for tests.

llvm-svn: 275739
This commit is contained in:
Davide Italiano 2016-07-17 23:21:26 +00:00
parent e1f863012f
commit ce9fd6c549
18 changed files with 135 additions and 19 deletions

View File

@ -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
}

View File

@ -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: }

View File

@ -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 ; <i32*> [#uses=0]
@ -214,6 +214,7 @@ bb18: ; preds = %bb49
%tmp46 = load i32, i32* %i ; <i32> [#uses=1]
call void @fix_operands( i32 %tmp46 )
%tmp47 = load i32, i32* %i ; <i32> [#uses=1]
; CHECK: %tmp47 = phi i32 [ %tmp48, %bb18 ], [ 0, %bb17 ]
%tmp48 = add i32 %tmp47, 1 ; <i32> [#uses=1]
store i32 %tmp48, i32* %i
br label %bb49

View File

@ -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 ; <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 ; <i16> [#uses=0]
; CHECK-NOT: %tmp701 =
ret i32 0
}

View File

@ -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 ; <i32*> [#uses=1]
%tmp1 = getelementptr i32, i32* %tmp, i32 1 ; <i32*> [#uses=2]
%tmp2 = load i32, i32* %tmp1, align 4 ; <i32> [#uses=1]
; CHECK-NOT: load
%tmp3 = or i32 %tmp2, 11 ; <i32> [#uses=1]
%tmp4 = and i32 %tmp3, -21 ; <i32> [#uses=1]
store i32 %tmp4, i32* %tmp1, align 4

View File

@ -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 ; <i8*> [#uses=2]
@ -29,6 +29,7 @@ forinc: ; preds = %forbody
afterfor: ; preds = %forcond, %forcond.thread
%tmp10 = load i8, i8* @g_3 ; <i8> [#uses=0]
ret i8 %tmp10
; CHECK: ret i8 %tmp3
ifend: ; preds = %afterfor, %ifthen
ret i8 0

View File

@ -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: }

View File

@ -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'

View File

@ -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: }

View File

@ -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 ) ; <i8*> [#uses=2]
%tmp1 = bitcast i8* %tmp to i32* ; <i32*> [#uses=0]
%tmp2 = bitcast i8* %tmp to i32* ; <i32*> [#uses=0]
; CHECK-NOT: %tmp2
ret i32* %tmp2
}

View File

@ -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

View File

@ -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

View File

@ -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: }

View File

@ -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
}

View File

@ -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

View File

@ -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 ; <i32*> [#uses=2]
@G = common global i32 0 ; <i32*> [#uses=1]
@ -12,6 +12,7 @@ entry:
bb: ; preds = %entry
%3 = add i32 %0, 42 ; <i32> [#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
}

View File

@ -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 ; <i32*> [#uses=1]
%DEAD = load i32, i32* %9, align 4 ; <i32> [#uses=1]
; CHECK: %DEAD = phi i32 [ 0, %bb1 ], [ %4, %bb ]
ret i32 %DEAD
bb4: ; preds = %bb1

View File

@ -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: }