1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-23 13:02:52 +02:00
llvm-mirror/test/CodeGen/ARM/ifcvt-iter-indbr.ll
Cong Hou 5d51a489ae Replace all weight-based interfaces in MBB with probability-based interfaces, and update all uses of old interfaces.
(This is the second attempt to submit this patch. The first caused two assertion
 failures and was reverted. See https://llvm.org/bugs/show_bug.cgi?id=25687)

The patch in http://reviews.llvm.org/D13745 is broken into four parts:

1. New interfaces without functional changes (http://reviews.llvm.org/D13908).
2. Use new interfaces in SelectionDAG, while in other passes treat probabilities
as weights (http://reviews.llvm.org/D14361).
3. Use new interfaces in all other passes.
4. Remove old interfaces.

This patch is 3+4 above. In this patch, MBB won't provide weight-based
interfaces any more, which are totally replaced by probability-based ones.
The interface addSuccessor() is redesigned so that the default probability is
unknown. We allow unknown probabilities but don't allow using it together
with known probabilities in successor list. That is to say, we either have a
list of successors with all known probabilities, or all unknown
probabilities. In the latter case, we assume each successor has 1/N
probability where N is the number of successors. An assertion checks if the
user is attempting to add a successor with the disallowed mixed use as stated
above. This can help us catch many misuses.

All uses of weight-based interfaces are now updated to use probability-based
ones.


Differential revision: http://reviews.llvm.org/D14973

llvm-svn: 254377
2015-12-01 05:29:22 +00:00

63 lines
1.9 KiB
LLVM

; RUN: llc < %s -mtriple thumbv7s-apple-darwin -asm-verbose=false | FileCheck %s
; RUN: llc < %s -mtriple thumbv7s-apple-darwin -asm-verbose=false -print-machineinstrs=if-converter 2>&1 | FileCheck --check-prefix=CHECK-PROB %s
declare i32 @foo(i32)
declare i8* @bar(i32, i8*, i8*)
; Verify that we don't try to iteratively re-ifconvert a block with a
; (predicated) indirectbr terminator.
; If we do, we would ignore its fallthrough successor.
; CHECK-LABEL: test:
; CHECK: cmp {{.*}}, #21
; CHECK-NEXT: itt eq
; CHECK-NEXT: streq.w
; CHECK-NEXT: moveq pc
; CHECK-NEXT: LBB{{[0-9_]+}}:
; CHECK-NEXT: cmp {{.*}}, #42
; CHECK-NEXT: itt ne
; CHECK-NEXT: strne.w
; CHECK-NEXT: movne pc
; CHECK-NEXT: Ltmp
; CHECK-NEXT: LBB0_2:
; CHECK-NEXT: movw r0, #1234
; CHECK-NEXT: b [[FOOCALL:LBB[0-9_]+]]
; CHECK-NEXT: Ltmp
; CHECK-NEXT: LBB{{[0-9_]+}}:
; CHECK-NEXT: movw r0, #4567
; CHECK-NEXT: [[FOOCALL]]:
; CHECK-NEXT: blx _foo
;
; CHECK-PROB: BB#0:
; CHECK-PROB: Successors according to CFG: BB#1({{[0-9a-fx/= ]+}}50.00%) BB#2({{[0-9a-fx/= ]+}}25.00%) BB#4({{[0-9a-fx/= ]+}}25.00%)
; CHECK-PROB: BB#1:
; CHECK-PROB: Successors according to CFG: BB#2({{[0-9a-fx/= ]+}}75.00%) BB#4({{[0-9a-fx/= ]+}}25.00%)
define i32 @test(i32 %a, i32 %a2, i32* %p, i32* %p2) {
entry:
%dst1 = call i8* @bar(i32 1, i8* blockaddress(@test, %bb1), i8* blockaddress(@test, %bb2))
%dst2 = call i8* @bar(i32 2, i8* blockaddress(@test, %bb1), i8* blockaddress(@test, %bb2))
%dst3 = call i8* @bar(i32 3, i8* blockaddress(@test, %bb1), i8* blockaddress(@test, %bb2))
%cc1 = icmp eq i32 %a, 21
br i1 %cc1, label %cc1t, label %cc1f
cc1t:
store i32 %a, i32* %p
indirectbr i8* %dst3, [label %bb1, label %bb2]
cc1f:
%cc2 = icmp ne i32 %a2, 42
br i1 %cc2, label %cc2t, label %bb1
cc2t:
store i32 %a, i32* %p2
indirectbr i8* %dst1, [label %bb1, label %bb2]
bb1:
%ret_bb1 = call i32 @foo(i32 1234)
ret i32 %ret_bb1
bb2:
%ret_bb2 = call i32 @foo(i32 4567)
ret i32 %ret_bb2
}