1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

regenerate checks

llvm-svn: 264677
This commit is contained in:
Sanjay Patel 2016-03-28 22:12:21 +00:00
parent c5fd22c12a
commit f19d2c18af
3 changed files with 107 additions and 74 deletions

View File

@ -1,81 +1,104 @@
; NOTE: Assertions have been autogenerated by update_test_checks.py
; RUN: opt < %s -simplifycfg -S | FileCheck %s ; RUN: opt < %s -simplifycfg -S | FileCheck %s
; CHECK-NOT: switch
; Test normal folding ; Test normal folding
define i32 @test1() { define i32 @test1() {
switch i32 5, label %Default [ ; CHECK-LABEL: @test1(
i32 0, label %Foo ; CHECK-NEXT: TheDest:
i32 1, label %Bar ; CHECK-NEXT: ret i32 1234
i32 2, label %Baz ;
i32 5, label %TheDest switch i32 5, label %Default [
] i32 0, label %Foo
Default: ; preds = %0 i32 1, label %Bar
ret i32 -1 i32 2, label %Baz
Foo: ; preds = %0 i32 5, label %TheDest
ret i32 -2 ]
Bar: ; preds = %0 Default:
ret i32 -3 ret i32 -1
Baz: ; preds = %0 Foo:
ret i32 -4 ret i32 -2
TheDest: ; preds = %0 Bar:
ret i32 1234 ret i32 -3
Baz:
ret i32 -4
TheDest:
ret i32 1234
} }
; Test folding to default dest ; Test folding to default dest
define i32 @test2() { define i32 @test2() {
switch i32 3, label %Default [ ; CHECK-LABEL: @test2(
i32 0, label %Foo ; CHECK-NEXT: Default:
i32 1, label %Bar ; CHECK-NEXT: ret i32 1234
i32 2, label %Baz ;
i32 5, label %TheDest switch i32 3, label %Default [
] i32 0, label %Foo
Default: ; preds = %0 i32 1, label %Bar
ret i32 1234 i32 2, label %Baz
Foo: ; preds = %0 i32 5, label %TheDest
ret i32 -2 ]
Bar: ; preds = %0 Default:
ret i32 -5 ret i32 1234
Baz: ; preds = %0 Foo:
ret i32 -6 ret i32 -2
TheDest: ; preds = %0 Bar:
ret i32 -8 ret i32 -5
Baz:
ret i32 -6
TheDest:
ret i32 -8
} }
; Test folding all to same dest ; Test folding all to same dest
define i32 @test3(i1 %C) { define i32 @test3(i1 %C) {
br i1 %C, label %Start, label %TheDest ; CHECK-LABEL: @test3(
; CHECK-NEXT: TheDest:
; CHECK-NEXT: ret i32 1234
;
br i1 %C, label %Start, label %TheDest
Start: ; preds = %0 Start: ; preds = %0
switch i32 3, label %TheDest [ switch i32 3, label %TheDest [
i32 0, label %TheDest i32 0, label %TheDest
i32 1, label %TheDest i32 1, label %TheDest
i32 2, label %TheDest i32 2, label %TheDest
i32 5, label %TheDest i32 5, label %TheDest
] ]
TheDest: ; preds = %Start, %Start, %Start, %Start, %Start, %0 TheDest:
ret i32 1234 ret i32 1234
} }
; Test folding switch -> branch ; Test folding switch -> branch
define i32 @test4(i32 %C) { define i32 @test4(i32 %C) {
switch i32 %C, label %L1 [ ; CHECK-LABEL: @test4(
i32 0, label %L2 ; CHECK-NEXT: L1:
] ; CHECK-NEXT: [[COND:%.*]] = icmp eq i32 %C, 0
L1: ; preds = %0 ; CHECK-NEXT: [[DOT:%.*]] = select i1 [[COND]], i32 1, i32 0
ret i32 0 ; CHECK-NEXT: ret i32 [[DOT]]
L2: ; preds = %0 ;
ret i32 1 switch i32 %C, label %L1 [
i32 0, label %L2
]
L1:
ret i32 0
L2:
ret i32 1
} }
; Can fold into a cond branch! ; Can fold into a cond branch!
define i32 @test5(i32 %C) { define i32 @test5(i32 %C) {
switch i32 %C, label %L1 [ ; CHECK-LABEL: @test5(
i32 0, label %L2 ; CHECK-NEXT: L1:
i32 123, label %L1 ; CHECK-NEXT: [[COND:%.*]] = icmp eq i32 %C, 0
] ; CHECK-NEXT: [[DOT:%.*]] = select i1 [[COND]], i32 1, i32 0
L1: ; preds = %0, %0 ; CHECK-NEXT: ret i32 [[DOT]]
ret i32 0 ;
L2: ; preds = %0 switch i32 %C, label %L1 [
ret i32 1 i32 0, label %L2
i32 123, label %L1
]
L1:
ret i32 0
L2:
ret i32 1
} }

View File

@ -1,9 +1,13 @@
; NOTE: Assertions have been autogenerated by update_test_checks.py
; RUN: opt < %s -simplifycfg -S | FileCheck %s ; RUN: opt < %s -simplifycfg -S | FileCheck %s
@b = extern_weak global i32 @b = extern_weak global i32
define i32 @foo(i1 %y) { define i32 @foo(i1 %y) {
; CHECK: define i32 @foo(i1 %y) { ; CHECK-LABEL: @foo(
; CHECK: [[COND_I:%.*]] = phi i32 [ srem (i32 1, i32 zext (i1 icmp eq (i32* @b, i32* null) to i32)), %bb2 ], [ 0, %0 ]
; CHECK-NEXT: ret i32 [[COND_I]]
;
br i1 %y, label %bb1, label %bb2 br i1 %y, label %bb1, label %bb2
bb1: bb1:
br label %bb3 br label %bb3
@ -11,18 +15,19 @@ bb2:
br label %bb3 br label %bb3
bb3: bb3:
%cond.i = phi i32 [ 0, %bb1 ], [ srem (i32 1, i32 zext (i1 icmp eq (i32* @b, i32* null) to i32)), %bb2 ] %cond.i = phi i32 [ 0, %bb1 ], [ srem (i32 1, i32 zext (i1 icmp eq (i32* @b, i32* null) to i32)), %bb2 ]
; CHECK: phi i32 {{.*}} srem (i32 1, i32 zext (i1 icmp eq (i32* @b, i32* null) to i32)), %bb2
ret i32 %cond.i ret i32 %cond.i
} }
define i32 @foo2(i1 %x) { define i32 @foo2(i1 %x) {
; CHECK: define i32 @foo2(i1 %x) { ; CHECK-LABEL: @foo2(
; CHECK: [[COND:%.*]] = phi i32 [ 0, %bb1 ], [ srem (i32 1, i32 zext (i1 icmp eq (i32* @b, i32* null) to i32)), %bb0 ]
; CHECK-NEXT: ret i32 [[COND]]
;
bb0: bb0:
br i1 %x, label %bb1, label %bb2 br i1 %x, label %bb1, label %bb2
bb1: bb1:
br label %bb2 br label %bb2
bb2: bb2:
%cond = phi i32 [ 0, %bb1 ], [ srem (i32 1, i32 zext (i1 icmp eq (i32* @b, i32* null) to i32)), %bb0 ] %cond = phi i32 [ 0, %bb1 ], [ srem (i32 1, i32 zext (i1 icmp eq (i32* @b, i32* null) to i32)), %bb0 ]
; CHECK: %cond = phi i32 [ 0, %bb1 ], [ srem (i32 1, i32 zext (i1 icmp eq (i32* @b, i32* null) to i32)), %bb0 ]
ret i32 %cond ret i32 %cond
} }

View File

@ -1,24 +1,29 @@
; NOTE: Assertions have been autogenerated by update_test_checks.py
; Test merging of blocks that only have PHI nodes in them ; Test merging of blocks that only have PHI nodes in them
; ;
; RUN: opt < %s -simplifycfg -S | FileCheck %s ; RUN: opt < %s -simplifycfg -S | FileCheck %s
; ;
define i32 @test(i1 %a, i1 %b) { define i32 @test(i1 %a, i1 %b) {
br i1 %a, label %M, label %O ; CHECK-LABEL: @test(
; CHECK: M:
; CHECK-NEXT: [[DOT:%.*]] = select i1 %b, i32 0, i32 1
; CHECK-NEXT: [[W:%.*]] = select i1 %a, i32 2, i32 [[DOT]]
; CHECK-NEXT: [[R:%.*]] = add i32 [[W]], 1
; CHECK-NEXT: ret i32 [[R]]
;
br i1 %a, label %M, label %O
O: ; preds = %0 O: ; preds = %0
; CHECK: select i1 %b, i32 0, i32 1 br i1 %b, label %N, label %Q
; CHECK-NOT: phi
br i1 %b, label %N, label %Q
Q: ; preds = %O Q: ; preds = %O
br label %N br label %N
N: ; preds = %Q, %O N: ; preds = %Q, %O
; This block should be foldable into M ; This block should be foldable into M
%Wp = phi i32 [ 0, %O ], [ 1, %Q ] ; <i32> [#uses=1] %Wp = phi i32 [ 0, %O ], [ 1, %Q ] ; <i32> [#uses=1]
br label %M br label %M
M: ; preds = %N, %0 M: ; preds = %N, %0
%W = phi i32 [ %Wp, %N ], [ 2, %0 ] ; <i32> [#uses=1] %W = phi i32 [ %Wp, %N ], [ 2, %0 ] ; <i32> [#uses=1]
%R = add i32 %W, 1 ; <i32> [#uses=1] %R = add i32 %W, 1 ; <i32> [#uses=1]
ret i32 %R ret i32 %R
; CHECK: ret
} }