mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
1112f9ad6f
This is the last JumpThreading patch for getting the performance numbers shown at https://reviews.llvm.org/D84940#2184653 . This patch makes ProcessBlock call ProcessBranchOnPHI when the branch condition is freeze(phi) as well (originally it calls the function when the condition is phi only). Since what ProcessBranchOnPHI does is to duplicate the basic block into predecessors if profitable, it is still valid when the condition is freeze(phi) too. ``` p = phi [a, pred1] [b, pred2] p.fr = freeze p br p.fr, ... => pred1: p.fr = freeze a br p.fr, ... pred2: p.fr2 = freeze b br p.fr2, ... ``` Reviewed By: efriedma Differential Revision: https://reviews.llvm.org/D85029
70 lines
1.7 KiB
LLVM
70 lines
1.7 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
|
; RUN: opt -jump-threading -S < %s | FileCheck %s
|
|
|
|
declare void @f()
|
|
declare void @g()
|
|
declare void @h()
|
|
|
|
define i32 @test(i1 %cond, i1 %a, i1 %b) {
|
|
; CHECK-LABEL: @test(
|
|
; CHECK-NEXT: br i1 [[COND:%.*]], label [[A:%.*]], label [[C:%.*]]
|
|
; CHECK: A:
|
|
; CHECK-NEXT: call void @f()
|
|
; CHECK-NEXT: br i1 [[A:%.*]], label [[EXIT1:%.*]], label [[EXIT2:%.*]]
|
|
; CHECK: C:
|
|
; CHECK-NEXT: call void @g()
|
|
; CHECK-NEXT: br i1 [[B:%.*]], label [[EXIT1]], label [[EXIT2]]
|
|
; CHECK: EXIT1:
|
|
; CHECK-NEXT: ret i32 0
|
|
; CHECK: EXIT2:
|
|
; CHECK-NEXT: ret i32 1
|
|
;
|
|
br i1 %cond, label %A, label %B
|
|
A:
|
|
call void @f()
|
|
br label %C
|
|
B:
|
|
call void @g()
|
|
br label %C
|
|
C:
|
|
%p = phi i1 [%a, %A], [%b, %B] ; Check that this is removed
|
|
br i1 %p, label %EXIT1, label %EXIT2
|
|
EXIT1:
|
|
ret i32 0
|
|
EXIT2:
|
|
ret i32 1
|
|
}
|
|
|
|
define i32 @test2(i1 %cond, i1 %a, i1 %b) {
|
|
; CHECK-LABEL: @test2(
|
|
; CHECK-NEXT: br i1 [[COND:%.*]], label [[A:%.*]], label [[C:%.*]]
|
|
; CHECK: A:
|
|
; CHECK-NEXT: call void @f()
|
|
; CHECK-NEXT: [[P_FR1:%.*]] = freeze i1 [[A:%.*]]
|
|
; CHECK-NEXT: br i1 [[P_FR1]], label [[EXIT1:%.*]], label [[EXIT2:%.*]]
|
|
; CHECK: C:
|
|
; CHECK-NEXT: call void @g()
|
|
; CHECK-NEXT: [[P_FR:%.*]] = freeze i1 [[B:%.*]]
|
|
; CHECK-NEXT: br i1 [[P_FR]], label [[EXIT1]], label [[EXIT2]]
|
|
; CHECK: EXIT1:
|
|
; CHECK-NEXT: ret i32 0
|
|
; CHECK: EXIT2:
|
|
; CHECK-NEXT: ret i32 1
|
|
;
|
|
br i1 %cond, label %A, label %B
|
|
A:
|
|
call void @f()
|
|
br label %C
|
|
B:
|
|
call void @g()
|
|
br label %C
|
|
C:
|
|
%p = phi i1 [%a, %A], [%b, %B] ; Check that this is removed
|
|
%p.fr = freeze i1 %p
|
|
br i1 %p.fr, label %EXIT1, label %EXIT2
|
|
EXIT1:
|
|
ret i32 0
|
|
EXIT2:
|
|
ret i32 1
|
|
}
|