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
; CHECK-NOT: switch
; Test normal folding
define i32 @test1() {
switch i32 5, label %Default [
i32 0, label %Foo
i32 1, label %Bar
i32 2, label %Baz
i32 5, label %TheDest
]
Default: ; preds = %0
ret i32 -1
Foo: ; preds = %0
ret i32 -2
Bar: ; preds = %0
ret i32 -3
Baz: ; preds = %0
ret i32 -4
TheDest: ; preds = %0
ret i32 1234
; CHECK-LABEL: @test1(
; CHECK-NEXT: TheDest:
; CHECK-NEXT: ret i32 1234
;
switch i32 5, label %Default [
i32 0, label %Foo
i32 1, label %Bar
i32 2, label %Baz
i32 5, label %TheDest
]
Default:
ret i32 -1
Foo:
ret i32 -2
Bar:
ret i32 -3
Baz:
ret i32 -4
TheDest:
ret i32 1234
}
; Test folding to default dest
define i32 @test2() {
switch i32 3, label %Default [
i32 0, label %Foo
i32 1, label %Bar
i32 2, label %Baz
i32 5, label %TheDest
]
Default: ; preds = %0
ret i32 1234
Foo: ; preds = %0
ret i32 -2
Bar: ; preds = %0
ret i32 -5
Baz: ; preds = %0
ret i32 -6
TheDest: ; preds = %0
ret i32 -8
; CHECK-LABEL: @test2(
; CHECK-NEXT: Default:
; CHECK-NEXT: ret i32 1234
;
switch i32 3, label %Default [
i32 0, label %Foo
i32 1, label %Bar
i32 2, label %Baz
i32 5, label %TheDest
]
Default:
ret i32 1234
Foo:
ret i32 -2
Bar:
ret i32 -5
Baz:
ret i32 -6
TheDest:
ret i32 -8
}
; Test folding all to same dest
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
switch i32 3, label %TheDest [
i32 0, label %TheDest
i32 1, label %TheDest
i32 2, label %TheDest
i32 5, label %TheDest
]
TheDest: ; preds = %Start, %Start, %Start, %Start, %Start, %0
ret i32 1234
switch i32 3, label %TheDest [
i32 0, label %TheDest
i32 1, label %TheDest
i32 2, label %TheDest
i32 5, label %TheDest
]
TheDest:
ret i32 1234
}
; Test folding switch -> branch
define i32 @test4(i32 %C) {
switch i32 %C, label %L1 [
i32 0, label %L2
]
L1: ; preds = %0
ret i32 0
L2: ; preds = %0
ret i32 1
; CHECK-LABEL: @test4(
; CHECK-NEXT: L1:
; CHECK-NEXT: [[COND:%.*]] = icmp eq i32 %C, 0
; CHECK-NEXT: [[DOT:%.*]] = select i1 [[COND]], i32 1, i32 0
; CHECK-NEXT: ret i32 [[DOT]]
;
switch i32 %C, label %L1 [
i32 0, label %L2
]
L1:
ret i32 0
L2:
ret i32 1
}
; Can fold into a cond branch!
define i32 @test5(i32 %C) {
switch i32 %C, label %L1 [
i32 0, label %L2
i32 123, label %L1
]
L1: ; preds = %0, %0
ret i32 0
L2: ; preds = %0
ret i32 1
; CHECK-LABEL: @test5(
; CHECK-NEXT: L1:
; CHECK-NEXT: [[COND:%.*]] = icmp eq i32 %C, 0
; CHECK-NEXT: [[DOT:%.*]] = select i1 [[COND]], i32 1, i32 0
; CHECK-NEXT: ret i32 [[DOT]]
;
switch i32 %C, label %L1 [
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
@b = extern_weak global i32
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
bb1:
br label %bb3
@ -11,18 +15,19 @@ bb2:
br label %bb3
bb3:
%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
}
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:
br i1 %x, label %bb1, label %bb2
bb1:
br label %bb2
bb2:
%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
}

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
;
; RUN: opt < %s -simplifycfg -S | FileCheck %s
;
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
; CHECK: select i1 %b, i32 0, i32 1
; CHECK-NOT: phi
br i1 %b, label %N, label %Q
br i1 %b, label %N, label %Q
Q: ; preds = %O
br label %N
br label %N
N: ; preds = %Q, %O
; This block should be foldable into M
%Wp = phi i32 [ 0, %O ], [ 1, %Q ] ; <i32> [#uses=1]
br label %M
; This block should be foldable into M
%Wp = phi i32 [ 0, %O ], [ 1, %Q ] ; <i32> [#uses=1]
br label %M
M: ; preds = %N, %0
%W = phi i32 [ %Wp, %N ], [ 2, %0 ] ; <i32> [#uses=1]
%R = add i32 %W, 1 ; <i32> [#uses=1]
ret i32 %R
; CHECK: ret
%W = phi i32 [ %Wp, %N ], [ 2, %0 ] ; <i32> [#uses=1]
%R = add i32 %W, 1 ; <i32> [#uses=1]
ret i32 %R
}