1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00

[NFC][SimplifyCFG] FoldBranchToCommonDest: add one more test with PHI

This is the problematic pattern i didn't think of,
that lead to revert of 2245fb8aaa1c1f85f53f7b19a1ee3ac69b1a1dfe
in f3abd54958ab90ba7c100d3fa936a3ce0dd2ad04.
This commit is contained in:
Roman Lebedev 2020-11-27 11:47:41 +03:00
parent cab34aad85
commit f7fd881137

View File

@ -3,6 +3,7 @@
declare void @sideeffect0()
declare void @sideeffect1()
declare void @sideeffect2()
declare void @use8(i8)
; Basic cases, blocks have nothing other than the comparison itself.
@ -304,6 +305,55 @@ final_right:
ret void
}
define void @one_pred_with_extra_op_liveout_distant_phi(i8 %v0, i8 %v1) {
; CHECK-LABEL: @one_pred_with_extra_op_liveout_distant_phi(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[C0:%.*]] = icmp eq i8 [[V0:%.*]], 0
; CHECK-NEXT: br i1 [[C0]], label [[PRED:%.*]], label [[LEFT_END:%.*]]
; CHECK: pred:
; CHECK-NEXT: [[C1:%.*]] = icmp eq i8 [[V1:%.*]], 0
; CHECK-NEXT: br i1 [[C1]], label [[DISPATCH:%.*]], label [[FINAL_RIGHT:%.*]]
; CHECK: dispatch:
; CHECK-NEXT: [[V2_ADJ:%.*]] = add i8 [[V0]], [[V1]]
; CHECK-NEXT: [[C2:%.*]] = icmp eq i8 [[V2_ADJ]], 0
; CHECK-NEXT: br i1 [[C2]], label [[FINAL_LEFT:%.*]], label [[FINAL_RIGHT]]
; CHECK: final_left:
; CHECK-NEXT: call void @sideeffect0()
; CHECK-NEXT: call void @use8(i8 [[V2_ADJ]])
; CHECK-NEXT: br label [[LEFT_END]]
; CHECK: left_end:
; CHECK-NEXT: [[MERGE_LEFT:%.*]] = phi i8 [ [[V2_ADJ]], [[FINAL_LEFT]] ], [ 0, [[ENTRY:%.*]] ]
; CHECK-NEXT: call void @sideeffect1()
; CHECK-NEXT: call void @use8(i8 [[MERGE_LEFT]])
; CHECK-NEXT: ret void
; CHECK: final_right:
; CHECK-NEXT: call void @sideeffect2()
; CHECK-NEXT: ret void
;
entry:
%c0 = icmp eq i8 %v0, 0
br i1 %c0, label %pred, label %left_end
pred:
%c1 = icmp eq i8 %v1, 0
br i1 %c1, label %dispatch, label %final_right
dispatch:
%v2_adj = add i8 %v0, %v1
%c2 = icmp eq i8 %v2_adj, 0
br i1 %c2, label %final_left, label %final_right
final_left:
call void @sideeffect0()
call void @use8(i8 %v2_adj)
br label %left_end
left_end:
%merge_left = phi i8 [ %v2_adj, %final_left ], [ 0, %entry ]
call void @sideeffect1()
call void @use8(i8 %merge_left)
ret void
final_right:
call void @sideeffect2()
ret void
}
define void @two_preds_with_extra_op_liveout(i8 %v0, i8 %v1, i8 %v2, i8 %v3) {
; CHECK-LABEL: @two_preds_with_extra_op_liveout(
; CHECK-NEXT: entry: