1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 12:43:36 +01:00

[NFC] Update tests

Run the update script on a couple of tests.
This commit is contained in:
Sam Parker 2020-05-05 15:28:40 +01:00
parent d7f05cb34a
commit 7cdff6929c
2 changed files with 391 additions and 256 deletions

View File

@ -1,14 +1,42 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; REQUIRES: aarch64-registered-target
; RUN: opt < %s -licm -S | FileCheck %s
target triple = "aarch64--linux-gnueabi"
; CHECK-LABEL:@test1
; CHECK-LABEL:loopexit1:
; CHECK: %[[PHI:.+]] = phi i8** [ %arrayidx0, %if.end ]
; CHECK: getelementptr inbounds i8*, i8** %[[PHI]], i64 1
define i8** @test1(i32 %j, i8** readonly %P, i8* readnone %Q) {
; CHECK-LABEL: @test1(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[CMP0:%.*]] = icmp slt i32 0, [[J:%.*]]
; CHECK-NEXT: br i1 [[CMP0]], label [[FOR_BODY_LR_PH:%.*]], label [[RETURN:%.*]]
; CHECK: for.body.lr.ph:
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[P_ADDR:%.*]] = phi i8** [ [[P:%.*]], [[FOR_BODY_LR_PH]] ], [ [[ARRAYIDX0:%.*]], [[IF_END:%.*]] ]
; CHECK-NEXT: [[I0:%.*]] = phi i32 [ 0, [[FOR_BODY_LR_PH]] ], [ [[I_ADD:%.*]], [[IF_END]] ]
; CHECK-NEXT: [[I0_EXT:%.*]] = sext i32 [[I0]] to i64
; CHECK-NEXT: [[ARRAYIDX0]] = getelementptr inbounds i8*, i8** [[P_ADDR]], i64 [[I0_EXT]]
; CHECK-NEXT: [[L0:%.*]] = load i8*, i8** [[ARRAYIDX0]], align 8
; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt i8* [[L0]], [[Q:%.*]]
; CHECK-NEXT: br i1 [[CMP1]], label [[LOOPEXIT0:%.*]], label [[IF_END]]
; CHECK: if.end:
; CHECK-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds i8*, i8** [[ARRAYIDX0]], i64 1
; CHECK-NEXT: [[L1:%.*]] = load i8*, i8** [[ARRAYIDX1]], align 8
; CHECK-NEXT: [[CMP4:%.*]] = icmp ugt i8* [[L1]], [[Q]]
; CHECK-NEXT: [[I_ADD]] = add nsw i32 [[I0]], 2
; CHECK-NEXT: br i1 [[CMP4]], label [[LOOPEXIT1:%.*]], label [[FOR_BODY]]
; CHECK: loopexit0:
; CHECK-NEXT: [[P1:%.*]] = phi i8** [ [[ARRAYIDX0]], [[FOR_BODY]] ]
; CHECK-NEXT: br label [[RETURN]]
; CHECK: loopexit1:
; CHECK-NEXT: [[ARRAYIDX0_LCSSA:%.*]] = phi i8** [ [[ARRAYIDX0]], [[IF_END]] ]
; CHECK-NEXT: [[ARRAYIDX1_LE:%.*]] = getelementptr inbounds i8*, i8** [[ARRAYIDX0_LCSSA]], i64 1
; CHECK-NEXT: br label [[RETURN]]
; CHECK: return:
; CHECK-NEXT: [[RETVAL_0:%.*]] = phi i8** [ [[P1]], [[LOOPEXIT0]] ], [ [[ARRAYIDX1_LE]], [[LOOPEXIT1]] ], [ null, [[ENTRY:%.*]] ]
; CHECK-NEXT: ret i8** [[RETVAL_0]]
;
entry:
%cmp0 = icmp slt i32 0, %j
br i1 %cmp0, label %for.body.lr.ph, label %return
@ -46,12 +74,46 @@ return:
ret i8** %retval.0
}
; CHECK-LABEL: @test2
; CHECK-LABEL: loopexit2:
; CHECK: %[[PHI:.*]] = phi i8** [ %add.ptr, %if.end ]
; CHECK: getelementptr inbounds i8*, i8** %[[PHI]]
define i8** @test2(i32 %j, i8** readonly %P, i8* readnone %Q) {
; CHECK-LABEL: @test2(
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.cond:
; CHECK-NEXT: [[I_ADDR_0:%.*]] = phi i32 [ [[ADD:%.*]], [[IF_END:%.*]] ]
; CHECK-NEXT: [[P_ADDR_0:%.*]] = phi i8** [ [[ADD_PTR:%.*]], [[IF_END]] ]
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[I_ADDR_0]], [[J:%.*]]
; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[LOOPEXIT0:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[P_ADDR:%.*]] = phi i8** [ [[P:%.*]], [[ENTRY:%.*]] ], [ [[P_ADDR_0]], [[FOR_COND:%.*]] ]
; CHECK-NEXT: [[I_ADDR:%.*]] = phi i32 [ 0, [[ENTRY]] ], [ [[I_ADDR_0]], [[FOR_COND]] ]
; CHECK-NEXT: [[IDX_EXT:%.*]] = sext i32 [[I_ADDR]] to i64
; CHECK-NEXT: [[ADD_PTR]] = getelementptr inbounds i8*, i8** [[P_ADDR]], i64 [[IDX_EXT]]
; CHECK-NEXT: [[L0:%.*]] = load i8*, i8** [[ADD_PTR]], align 8
; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt i8* [[L0]], [[Q:%.*]]
; CHECK-NEXT: br i1 [[CMP1]], label [[LOOPEXIT1:%.*]], label [[IF_END]]
; CHECK: if.end:
; CHECK-NEXT: [[ADD_I:%.*]] = add i32 [[I_ADDR]], 1
; CHECK-NEXT: [[IDX2_EXT:%.*]] = sext i32 [[ADD_I]] to i64
; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds i8*, i8** [[ADD_PTR]], i64 [[IDX2_EXT]]
; CHECK-NEXT: [[L1:%.*]] = load i8*, i8** [[ARRAYIDX2]], align 8
; CHECK-NEXT: [[CMP2:%.*]] = icmp ugt i8* [[L1]], [[Q]]
; CHECK-NEXT: [[ADD]] = add nsw i32 [[ADD_I]], 1
; CHECK-NEXT: br i1 [[CMP2]], label [[LOOPEXIT2:%.*]], label [[FOR_COND]]
; CHECK: loopexit0:
; CHECK-NEXT: [[P0:%.*]] = phi i8** [ null, [[FOR_COND]] ]
; CHECK-NEXT: br label [[RETURN:%.*]]
; CHECK: loopexit1:
; CHECK-NEXT: [[P1:%.*]] = phi i8** [ [[ADD_PTR]], [[FOR_BODY]] ]
; CHECK-NEXT: br label [[RETURN]]
; CHECK: loopexit2:
; CHECK-NEXT: [[IDX2_EXT_LCSSA:%.*]] = phi i64 [ [[IDX2_EXT]], [[IF_END]] ]
; CHECK-NEXT: [[ADD_PTR_LCSSA:%.*]] = phi i8** [ [[ADD_PTR]], [[IF_END]] ]
; CHECK-NEXT: [[ARRAYIDX2_LE:%.*]] = getelementptr inbounds i8*, i8** [[ADD_PTR_LCSSA]], i64 [[IDX2_EXT_LCSSA]]
; CHECK-NEXT: br label [[RETURN]]
; CHECK: return:
; CHECK-NEXT: [[RETVAL_0:%.*]] = phi i8** [ [[P1]], [[LOOPEXIT1]] ], [ [[ARRAYIDX2_LE]], [[LOOPEXIT2]] ], [ [[P0]], [[LOOPEXIT0]] ]
; CHECK-NEXT: ret i8** [[RETVAL_0]]
;
entry:
br label %for.body
@ -99,14 +161,43 @@ return:
}
; CHECK-LABEL: @test3
; CHECK-LABEL: loopexit1:
; CHECK: %[[ADD:.*]] = phi i64 [ %add, %if.end ]
; CHECK: %[[ADDR:.*]] = phi i8** [ %P.addr, %if.end ]
; CHECK: %[[TRUNC:.*]] = trunc i64 %[[ADD]] to i32
; CHECK: getelementptr inbounds i8*, i8** %[[ADDR]], i32 %[[TRUNC]]
; CHECK: call void @dummy(i32 %[[TRUNC]])
define i8** @test3(i64 %j, i8** readonly %P, i8* readnone %Q) {
; CHECK-LABEL: @test3(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[CMP0:%.*]] = icmp slt i64 0, [[J:%.*]]
; CHECK-NEXT: br i1 [[CMP0]], label [[FOR_BODY_LR_PH:%.*]], label [[RETURN:%.*]]
; CHECK: for.body.lr.ph:
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[P_ADDR:%.*]] = phi i8** [ [[P:%.*]], [[FOR_BODY_LR_PH]] ], [ [[ARRAYIDX0:%.*]], [[IF_END:%.*]] ]
; CHECK-NEXT: [[I0:%.*]] = phi i32 [ 0, [[FOR_BODY_LR_PH]] ], [ [[I_ADD:%.*]], [[IF_END]] ]
; CHECK-NEXT: [[I0_EXT:%.*]] = sext i32 [[I0]] to i64
; CHECK-NEXT: [[ARRAYIDX0]] = getelementptr inbounds i8*, i8** [[P_ADDR]], i64 [[I0_EXT]]
; CHECK-NEXT: [[L0:%.*]] = load i8*, i8** [[ARRAYIDX0]], align 8
; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt i8* [[L0]], [[Q:%.*]]
; CHECK-NEXT: br i1 [[CMP1]], label [[LOOPEXIT0:%.*]], label [[IF_END]]
; CHECK: if.end:
; CHECK-NEXT: [[ADD:%.*]] = add i64 [[I0_EXT]], 1
; CHECK-NEXT: [[TRUNC:%.*]] = trunc i64 [[ADD]] to i32
; CHECK-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds i8*, i8** [[P_ADDR]], i32 [[TRUNC]]
; CHECK-NEXT: [[L1:%.*]] = load i8*, i8** [[ARRAYIDX1]], align 8
; CHECK-NEXT: [[CMP4:%.*]] = icmp ugt i8* [[L1]], [[Q]]
; CHECK-NEXT: [[I_ADD]] = add nsw i32 [[I0]], 2
; CHECK-NEXT: br i1 [[CMP4]], label [[LOOPEXIT1:%.*]], label [[FOR_BODY]]
; CHECK: loopexit0:
; CHECK-NEXT: [[P1:%.*]] = phi i8** [ [[ARRAYIDX0]], [[FOR_BODY]] ]
; CHECK-NEXT: br label [[RETURN]]
; CHECK: loopexit1:
; CHECK-NEXT: [[ADD_LCSSA:%.*]] = phi i64 [ [[ADD]], [[IF_END]] ]
; CHECK-NEXT: [[P_ADDR_LCSSA:%.*]] = phi i8** [ [[P_ADDR]], [[IF_END]] ]
; CHECK-NEXT: [[TRUNC_LE:%.*]] = trunc i64 [[ADD_LCSSA]] to i32
; CHECK-NEXT: [[ARRAYIDX1_LE:%.*]] = getelementptr inbounds i8*, i8** [[P_ADDR_LCSSA]], i32 [[TRUNC_LE]]
; CHECK-NEXT: call void @dummy(i32 [[TRUNC_LE]])
; CHECK-NEXT: br label [[RETURN]]
; CHECK: return:
; CHECK-NEXT: [[RETVAL_0:%.*]] = phi i8** [ [[P1]], [[LOOPEXIT0]] ], [ [[ARRAYIDX1_LE]], [[LOOPEXIT1]] ], [ null, [[ENTRY:%.*]] ]
; CHECK-NEXT: ret i8** [[RETVAL_0]]
;
entry:
%cmp0 = icmp slt i64 0, %j
br i1 %cmp0, label %for.body.lr.ph, label %return

View File

@ -1,3 +1,4 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; Test the basic functionality of speculating around PHI nodes based on reduced
; cost of the constant operands to the PHI nodes using the x86 cost model.
;
@ -7,185 +8,197 @@
target triple = "x86_64-unknown-unknown"
define i32 @test_basic(i1 %flag, i32 %arg) {
; CHECK-LABEL: define i32 @test_basic(
; CHECK-LABEL: @test_basic(
; CHECK-NEXT: entry:
; CHECK-NEXT: br i1 [[FLAG:%.*]], label [[A:%.*]], label [[B:%.*]]
; CHECK: a:
; CHECK-NEXT: [[SUM_0:%.*]] = add i32 [[ARG:%.*]], 7
; CHECK-NEXT: br label [[EXIT:%.*]]
; CHECK: b:
; CHECK-NEXT: [[SUM_1:%.*]] = add i32 [[ARG]], 11
; CHECK-NEXT: br label [[EXIT]]
; CHECK: exit:
; CHECK-NEXT: [[SUM_PHI:%.*]] = phi i32 [ [[SUM_0]], [[A]] ], [ [[SUM_1]], [[B]] ]
; CHECK-NEXT: ret i32 [[SUM_PHI]]
;
entry:
br i1 %flag, label %a, label %b
; CHECK: br i1 %flag, label %a, label %b
a:
br label %exit
; CHECK: a:
; CHECK-NEXT: %[[SUM_A:.*]] = add i32 %arg, 7
; CHECK-NEXT: br label %exit
b:
br label %exit
; CHECK: b:
; CHECK-NEXT: %[[SUM_B:.*]] = add i32 %arg, 11
; CHECK-NEXT: br label %exit
exit:
%p = phi i32 [ 7, %a ], [ 11, %b ]
%sum = add i32 %arg, %p
ret i32 %sum
; CHECK: exit:
; CHECK-NEXT: %[[PHI:.*]] = phi i32 [ %[[SUM_A]], %a ], [ %[[SUM_B]], %b ]
; CHECK-NEXT: ret i32 %[[PHI]]
}
; Check that we handle commuted operands and get the constant onto the RHS.
define i32 @test_commuted(i1 %flag, i32 %arg) {
; CHECK-LABEL: define i32 @test_commuted(
; CHECK-LABEL: @test_commuted(
; CHECK-NEXT: entry:
; CHECK-NEXT: br i1 [[FLAG:%.*]], label [[A:%.*]], label [[B:%.*]]
; CHECK: a:
; CHECK-NEXT: [[SUM_0:%.*]] = add i32 [[ARG:%.*]], 7
; CHECK-NEXT: br label [[EXIT:%.*]]
; CHECK: b:
; CHECK-NEXT: [[SUM_1:%.*]] = add i32 [[ARG]], 11
; CHECK-NEXT: br label [[EXIT]]
; CHECK: exit:
; CHECK-NEXT: [[SUM_PHI:%.*]] = phi i32 [ [[SUM_0]], [[A]] ], [ [[SUM_1]], [[B]] ]
; CHECK-NEXT: ret i32 [[SUM_PHI]]
;
entry:
br i1 %flag, label %a, label %b
; CHECK: br i1 %flag, label %a, label %b
a:
br label %exit
; CHECK: a:
; CHECK-NEXT: %[[SUM_A:.*]] = add i32 %arg, 7
; CHECK-NEXT: br label %exit
b:
br label %exit
; CHECK: b:
; CHECK-NEXT: %[[SUM_B:.*]] = add i32 %arg, 11
; CHECK-NEXT: br label %exit
exit:
%p = phi i32 [ 7, %a ], [ 11, %b ]
%sum = add i32 %p, %arg
ret i32 %sum
; CHECK: exit:
; CHECK-NEXT: %[[PHI:.*]] = phi i32 [ %[[SUM_A]], %a ], [ %[[SUM_B]], %b ]
; CHECK-NEXT: ret i32 %[[PHI]]
}
define i32 @test_split_crit_edge(i1 %flag, i32 %arg) {
; CHECK-LABEL: define i32 @test_split_crit_edge(
; CHECK-LABEL: @test_split_crit_edge(
; CHECK-NEXT: entry:
; CHECK-NEXT: br i1 [[FLAG:%.*]], label [[ENTRY_EXIT_CRIT_EDGE:%.*]], label [[A:%.*]]
; CHECK: entry.exit_crit_edge:
; CHECK-NEXT: [[SUM_0:%.*]] = add i32 [[ARG:%.*]], 7
; CHECK-NEXT: br label [[EXIT:%.*]]
; CHECK: a:
; CHECK-NEXT: [[SUM_1:%.*]] = add i32 [[ARG]], 11
; CHECK-NEXT: br label [[EXIT]]
; CHECK: exit:
; CHECK-NEXT: [[SUM_PHI:%.*]] = phi i32 [ [[SUM_0]], [[ENTRY_EXIT_CRIT_EDGE]] ], [ [[SUM_1]], [[A]] ]
; CHECK-NEXT: ret i32 [[SUM_PHI]]
;
entry:
br i1 %flag, label %exit, label %a
; CHECK: entry:
; CHECK-NEXT: br i1 %flag, label %[[ENTRY_SPLIT:.*]], label %a
;
; CHECK: [[ENTRY_SPLIT]]:
; CHECK-NEXT: %[[SUM_ENTRY_SPLIT:.*]] = add i32 %arg, 7
; CHECK-NEXT: br label %exit
a:
br label %exit
; CHECK: a:
; CHECK-NEXT: %[[SUM_A:.*]] = add i32 %arg, 11
; CHECK-NEXT: br label %exit
exit:
%p = phi i32 [ 7, %entry ], [ 11, %a ]
%sum = add i32 %arg, %p
ret i32 %sum
; CHECK: exit:
; CHECK-NEXT: %[[PHI:.*]] = phi i32 [ %[[SUM_ENTRY_SPLIT]], %[[ENTRY_SPLIT]] ], [ %[[SUM_A]], %a ]
; CHECK-NEXT: ret i32 %[[PHI]]
}
define i32 @test_no_spec_dominating_inst(i1 %flag, i32* %ptr) {
; CHECK-LABEL: define i32 @test_no_spec_dominating_inst(
; CHECK-LABEL: @test_no_spec_dominating_inst(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[LOAD:%.*]] = load i32, i32* [[PTR:%.*]]
; CHECK-NEXT: br i1 [[FLAG:%.*]], label [[A:%.*]], label [[B:%.*]]
; CHECK: a:
; CHECK-NEXT: [[SUM_0:%.*]] = add i32 [[LOAD]], 7
; CHECK-NEXT: br label [[EXIT:%.*]]
; CHECK: b:
; CHECK-NEXT: [[SUM_1:%.*]] = add i32 [[LOAD]], 11
; CHECK-NEXT: br label [[EXIT]]
; CHECK: exit:
; CHECK-NEXT: [[SUM_PHI:%.*]] = phi i32 [ [[SUM_0]], [[A]] ], [ [[SUM_1]], [[B]] ]
; CHECK-NEXT: ret i32 [[SUM_PHI]]
;
entry:
%load = load i32, i32* %ptr
br i1 %flag, label %a, label %b
; CHECK: %[[LOAD:.*]] = load i32, i32* %ptr
; CHECK-NEXT: br i1 %flag, label %a, label %b
a:
br label %exit
; CHECK: a:
; CHECK-NEXT: %[[SUM_A:.*]] = add i32 %[[LOAD]], 7
; CHECK-NEXT: br label %exit
b:
br label %exit
; CHECK: b:
; CHECK-NEXT: %[[SUM_B:.*]] = add i32 %[[LOAD]], 11
; CHECK-NEXT: br label %exit
exit:
%p = phi i32 [ 7, %a ], [ 11, %b ]
%sum = add i32 %load, %p
ret i32 %sum
; CHECK: exit:
; CHECK-NEXT: %[[PHI:.*]] = phi i32 [ %[[SUM_A]], %a ], [ %[[SUM_B]], %b ]
; CHECK-NEXT: ret i32 %[[PHI]]
}
; We have special logic handling PHI nodes, make sure it doesn't get confused
; by a dominating PHI.
define i32 @test_no_spec_dominating_phi(i1 %flag1, i1 %flag2, i32 %x, i32 %y) {
; CHECK-LABEL: define i32 @test_no_spec_dominating_phi(
; CHECK-LABEL: @test_no_spec_dominating_phi(
; CHECK-NEXT: entry:
; CHECK-NEXT: br i1 [[FLAG1:%.*]], label [[X_BLOCK:%.*]], label [[Y_BLOCK:%.*]]
; CHECK: x.block:
; CHECK-NEXT: br label [[MERGE:%.*]]
; CHECK: y.block:
; CHECK-NEXT: br label [[MERGE]]
; CHECK: merge:
; CHECK-NEXT: [[XY_PHI:%.*]] = phi i32 [ [[X:%.*]], [[X_BLOCK]] ], [ [[Y:%.*]], [[Y_BLOCK]] ]
; CHECK-NEXT: br i1 [[FLAG2:%.*]], label [[A:%.*]], label [[B:%.*]]
; CHECK: a:
; CHECK-NEXT: [[SUM_0:%.*]] = add i32 [[XY_PHI]], 7
; CHECK-NEXT: br label [[EXIT:%.*]]
; CHECK: b:
; CHECK-NEXT: [[SUM_1:%.*]] = add i32 [[XY_PHI]], 11
; CHECK-NEXT: br label [[EXIT]]
; CHECK: exit:
; CHECK-NEXT: [[SUM_PHI:%.*]] = phi i32 [ [[SUM_0]], [[A]] ], [ [[SUM_1]], [[B]] ]
; CHECK-NEXT: ret i32 [[SUM_PHI]]
;
entry:
br i1 %flag1, label %x.block, label %y.block
; CHECK: entry:
; CHECK-NEXT: br i1 %flag1, label %x.block, label %y.block
x.block:
br label %merge
; CHECK: x.block:
; CHECK-NEXT: br label %merge
y.block:
br label %merge
; CHECK: y.block:
; CHECK-NEXT: br label %merge
merge:
%xy.phi = phi i32 [ %x, %x.block ], [ %y, %y.block ]
br i1 %flag2, label %a, label %b
; CHECK: merge:
; CHECK-NEXT: %[[XY_PHI:.*]] = phi i32 [ %x, %x.block ], [ %y, %y.block ]
; CHECK-NEXT: br i1 %flag2, label %a, label %b
a:
br label %exit
; CHECK: a:
; CHECK-NEXT: %[[SUM_A:.*]] = add i32 %[[XY_PHI]], 7
; CHECK-NEXT: br label %exit
b:
br label %exit
; CHECK: b:
; CHECK-NEXT: %[[SUM_B:.*]] = add i32 %[[XY_PHI]], 11
; CHECK-NEXT: br label %exit
exit:
%p = phi i32 [ 7, %a ], [ 11, %b ]
%sum = add i32 %xy.phi, %p
ret i32 %sum
; CHECK: exit:
; CHECK-NEXT: %[[SUM_PHI:.*]] = phi i32 [ %[[SUM_A]], %a ], [ %[[SUM_B]], %b ]
; CHECK-NEXT: ret i32 %[[SUM_PHI]]
}
; Ensure that we will speculate some number of "free" instructions on the given
; architecture even though they are unrelated to the PHI itself.
define i32 @test_speculate_free_insts(i1 %flag, i64 %arg) {
; CHECK-LABEL: define i32 @test_speculate_free_insts(
; CHECK-LABEL: @test_speculate_free_insts(
; CHECK-NEXT: entry:
; CHECK-NEXT: br i1 [[FLAG:%.*]], label [[A:%.*]], label [[B:%.*]]
; CHECK: a:
; CHECK-NEXT: [[T1_0:%.*]] = trunc i64 [[ARG:%.*]] to i48
; CHECK-NEXT: [[T2_0:%.*]] = trunc i48 [[T1_0]] to i32
; CHECK-NEXT: [[SUM_0:%.*]] = add i32 [[T2_0]], 7
; CHECK-NEXT: br label [[EXIT:%.*]]
; CHECK: b:
; CHECK-NEXT: [[T1_1:%.*]] = trunc i64 [[ARG]] to i48
; CHECK-NEXT: [[T2_1:%.*]] = trunc i48 [[T1_1]] to i32
; CHECK-NEXT: [[SUM_1:%.*]] = add i32 [[T2_1]], 11
; CHECK-NEXT: br label [[EXIT]]
; CHECK: exit:
; CHECK-NEXT: [[SUM_PHI:%.*]] = phi i32 [ [[SUM_0]], [[A]] ], [ [[SUM_1]], [[B]] ]
; CHECK-NEXT: ret i32 [[SUM_PHI]]
;
entry:
br i1 %flag, label %a, label %b
; CHECK: br i1 %flag, label %a, label %b
a:
br label %exit
; CHECK: a:
; CHECK-NEXT: %[[T1_A:.*]] = trunc i64 %arg to i48
; CHECK-NEXT: %[[T2_A:.*]] = trunc i48 %[[T1_A]] to i32
; CHECK-NEXT: %[[SUM_A:.*]] = add i32 %[[T2_A]], 7
; CHECK-NEXT: br label %exit
b:
br label %exit
; CHECK: b:
; CHECK-NEXT: %[[T1_B:.*]] = trunc i64 %arg to i48
; CHECK-NEXT: %[[T2_B:.*]] = trunc i48 %[[T1_B]] to i32
; CHECK-NEXT: %[[SUM_B:.*]] = add i32 %[[T2_B]], 11
; CHECK-NEXT: br label %exit
exit:
%p = phi i32 [ 7, %a ], [ 11, %b ]
@ -193,58 +206,67 @@ exit:
%t2 = trunc i48 %t1 to i32
%sum = add i32 %t2, %p
ret i32 %sum
; CHECK: exit:
; CHECK-NEXT: %[[PHI:.*]] = phi i32 [ %[[SUM_A]], %a ], [ %[[SUM_B]], %b ]
; CHECK-NEXT: ret i32 %[[PHI]]
}
define i32 @test_speculate_free_phis(i1 %flag, i32 %arg1, i32 %arg2) {
; CHECK-LABEL: define i32 @test_speculate_free_phis(
; CHECK-LABEL: @test_speculate_free_phis(
; CHECK-NEXT: entry:
; CHECK-NEXT: br i1 [[FLAG:%.*]], label [[A:%.*]], label [[B:%.*]]
; CHECK: a:
; CHECK-NEXT: [[SUM_0:%.*]] = add i32 [[ARG1:%.*]], 7
; CHECK-NEXT: br label [[EXIT:%.*]]
; CHECK: b:
; CHECK-NEXT: [[SUM_1:%.*]] = add i32 [[ARG2:%.*]], 11
; CHECK-NEXT: br label [[EXIT]]
; CHECK: exit:
; CHECK-NEXT: [[SUM_PHI:%.*]] = phi i32 [ [[SUM_0]], [[A]] ], [ [[SUM_1]], [[B]] ]
; CHECK-NEXT: [[P2:%.*]] = phi i32 [ [[ARG1]], [[A]] ], [ [[ARG2]], [[B]] ]
; CHECK-NEXT: ret i32 [[SUM_PHI]]
;
entry:
br i1 %flag, label %a, label %b
; CHECK: br i1 %flag, label %a, label %b
a:
br label %exit
; CHECK: a:
; CHECK-NEXT: %[[SUM_A:.*]] = add i32 %arg1, 7
; CHECK-NEXT: br label %exit
b:
br label %exit
; CHECK: b:
; CHECK-NEXT: %[[SUM_B:.*]] = add i32 %arg2, 11
; CHECK-NEXT: br label %exit
; We don't DCE the now unused PHI node...
exit:
%p1 = phi i32 [ 7, %a ], [ 11, %b ]
%p2 = phi i32 [ %arg1, %a ], [ %arg2, %b ]
%sum = add i32 %p2, %p1
ret i32 %sum
; CHECK: exit:
; CHECK-NEXT: %[[PHI:.*]] = phi i32 [ %[[SUM_A]], %a ], [ %[[SUM_B]], %b ]
; We don't DCE the now unused PHI node...
; CHECK-NEXT: %{{.*}} = phi i32 [ %arg1, %a ], [ %arg2, %b ]
; CHECK-NEXT: ret i32 %[[PHI]]
}
; We shouldn't speculate multiple uses even if each individually looks
; profitable because of the total cost.
define i32 @test_no_spec_multi_uses(i1 %flag, i32 %arg1, i32 %arg2, i32 %arg3) {
; CHECK-LABEL: define i32 @test_no_spec_multi_uses(
; CHECK-LABEL: @test_no_spec_multi_uses(
; CHECK-NEXT: entry:
; CHECK-NEXT: br i1 [[FLAG:%.*]], label [[A:%.*]], label [[B:%.*]]
; CHECK: a:
; CHECK-NEXT: br label [[EXIT:%.*]]
; CHECK: b:
; CHECK-NEXT: br label [[EXIT]]
; CHECK: exit:
; CHECK-NEXT: [[P:%.*]] = phi i32 [ 7, [[A]] ], [ 11, [[B]] ]
; CHECK-NEXT: [[ADD1:%.*]] = add i32 [[ARG1:%.*]], [[P]]
; CHECK-NEXT: [[ADD2:%.*]] = add i32 [[ARG2:%.*]], [[P]]
; CHECK-NEXT: [[ADD3:%.*]] = add i32 [[ARG3:%.*]], [[P]]
; CHECK-NEXT: [[SUM1:%.*]] = add i32 [[ADD1]], [[ADD2]]
; CHECK-NEXT: [[SUM2:%.*]] = add i32 [[SUM1]], [[ADD3]]
; CHECK-NEXT: ret i32 [[SUM2]]
;
entry:
br i1 %flag, label %a, label %b
; CHECK: br i1 %flag, label %a, label %b
a:
br label %exit
; CHECK: a:
; CHECK-NEXT: br label %exit
b:
br label %exit
; CHECK: b:
; CHECK-NEXT: br label %exit
exit:
%p = phi i32 [ 7, %a ], [ 11, %b ]
@ -254,37 +276,34 @@ exit:
%sum1 = add i32 %add1, %add2
%sum2 = add i32 %sum1, %add3
ret i32 %sum2
; CHECK: exit:
; CHECK-NEXT: %[[PHI:.*]] = phi i32 [ 7, %a ], [ 11, %b ]
; CHECK-NEXT: %[[ADD1:.*]] = add i32 %arg1, %[[PHI]]
; CHECK-NEXT: %[[ADD2:.*]] = add i32 %arg2, %[[PHI]]
; CHECK-NEXT: %[[ADD3:.*]] = add i32 %arg3, %[[PHI]]
; CHECK-NEXT: %[[SUM1:.*]] = add i32 %[[ADD1]], %[[ADD2]]
; CHECK-NEXT: %[[SUM2:.*]] = add i32 %[[SUM1]], %[[ADD3]]
; CHECK-NEXT: ret i32 %[[SUM2]]
}
define i32 @test_multi_phis1(i1 %flag, i32 %arg) {
; CHECK-LABEL: define i32 @test_multi_phis1(
; CHECK-LABEL: @test_multi_phis1(
; CHECK-NEXT: entry:
; CHECK-NEXT: br i1 [[FLAG:%.*]], label [[A:%.*]], label [[B:%.*]]
; CHECK: a:
; CHECK-NEXT: [[SUM1_0:%.*]] = add i32 [[ARG:%.*]], 1
; CHECK-NEXT: [[SUM2_0:%.*]] = add i32 [[SUM1_0]], 3
; CHECK-NEXT: [[SUM3_0:%.*]] = add i32 [[SUM2_0]], 5
; CHECK-NEXT: br label [[EXIT:%.*]]
; CHECK: b:
; CHECK-NEXT: [[SUM1_1:%.*]] = add i32 [[ARG]], 2
; CHECK-NEXT: [[SUM2_1:%.*]] = add i32 [[SUM1_1]], 4
; CHECK-NEXT: [[SUM3_1:%.*]] = add i32 [[SUM2_1]], 6
; CHECK-NEXT: br label [[EXIT]]
; CHECK: exit:
; CHECK-NEXT: [[SUM3_PHI:%.*]] = phi i32 [ [[SUM3_0]], [[A]] ], [ [[SUM3_1]], [[B]] ]
; CHECK-NEXT: ret i32 [[SUM3_PHI]]
;
entry:
br i1 %flag, label %a, label %b
; CHECK: br i1 %flag, label %a, label %b
a:
br label %exit
; CHECK: a:
; CHECK-NEXT: %[[SUM_A1:.*]] = add i32 %arg, 1
; CHECK-NEXT: %[[SUM_A2:.*]] = add i32 %[[SUM_A1]], 3
; CHECK-NEXT: %[[SUM_A3:.*]] = add i32 %[[SUM_A2]], 5
; CHECK-NEXT: br label %exit
b:
br label %exit
; CHECK: b:
; CHECK-NEXT: %[[SUM_B1:.*]] = add i32 %arg, 2
; CHECK-NEXT: %[[SUM_B2:.*]] = add i32 %[[SUM_B1]], 4
; CHECK-NEXT: %[[SUM_B3:.*]] = add i32 %[[SUM_B2]], 6
; CHECK-NEXT: br label %exit
exit:
%p1 = phi i32 [ 1, %a ], [ 2, %b ]
@ -294,33 +313,35 @@ exit:
%sum2 = add i32 %sum1, %p2
%sum3 = add i32 %sum2, %p3
ret i32 %sum3
; CHECK: exit:
; CHECK-NEXT: %[[PHI:.*]] = phi i32 [ %[[SUM_A3]], %a ], [ %[[SUM_B3]], %b ]
; CHECK-NEXT: ret i32 %[[PHI]]
}
; Check that the order of the PHIs doesn't impact the behavior.
define i32 @test_multi_phis2(i1 %flag, i32 %arg) {
; CHECK-LABEL: define i32 @test_multi_phis2(
; CHECK-LABEL: @test_multi_phis2(
; CHECK-NEXT: entry:
; CHECK-NEXT: br i1 [[FLAG:%.*]], label [[A:%.*]], label [[B:%.*]]
; CHECK: a:
; CHECK-NEXT: [[SUM1_0:%.*]] = add i32 [[ARG:%.*]], 1
; CHECK-NEXT: [[SUM2_0:%.*]] = add i32 [[SUM1_0]], 3
; CHECK-NEXT: [[SUM3_0:%.*]] = add i32 [[SUM2_0]], 5
; CHECK-NEXT: br label [[EXIT:%.*]]
; CHECK: b:
; CHECK-NEXT: [[SUM1_1:%.*]] = add i32 [[ARG]], 2
; CHECK-NEXT: [[SUM2_1:%.*]] = add i32 [[SUM1_1]], 4
; CHECK-NEXT: [[SUM3_1:%.*]] = add i32 [[SUM2_1]], 6
; CHECK-NEXT: br label [[EXIT]]
; CHECK: exit:
; CHECK-NEXT: [[SUM3_PHI:%.*]] = phi i32 [ [[SUM3_0]], [[A]] ], [ [[SUM3_1]], [[B]] ]
; CHECK-NEXT: ret i32 [[SUM3_PHI]]
;
entry:
br i1 %flag, label %a, label %b
; CHECK: br i1 %flag, label %a, label %b
a:
br label %exit
; CHECK: a:
; CHECK-NEXT: %[[SUM_A1:.*]] = add i32 %arg, 1
; CHECK-NEXT: %[[SUM_A2:.*]] = add i32 %[[SUM_A1]], 3
; CHECK-NEXT: %[[SUM_A3:.*]] = add i32 %[[SUM_A2]], 5
; CHECK-NEXT: br label %exit
b:
br label %exit
; CHECK: b:
; CHECK-NEXT: %[[SUM_B1:.*]] = add i32 %arg, 2
; CHECK-NEXT: %[[SUM_B2:.*]] = add i32 %[[SUM_B1]], 4
; CHECK-NEXT: %[[SUM_B3:.*]] = add i32 %[[SUM_B2]], 6
; CHECK-NEXT: br label %exit
exit:
%p3 = phi i32 [ 5, %a ], [ 6, %b ]
@ -330,36 +351,34 @@ exit:
%sum2 = add i32 %sum1, %p2
%sum3 = add i32 %sum2, %p3
ret i32 %sum3
; CHECK: exit:
; CHECK-NEXT: %[[PHI:.*]] = phi i32 [ %[[SUM_A3]], %a ], [ %[[SUM_B3]], %b ]
; CHECK-NEXT: ret i32 %[[PHI]]
}
define i32 @test_no_spec_indirectbr(i1 %flag, i32 %arg) {
; CHECK-LABEL: define i32 @test_no_spec_indirectbr(
; CHECK-LABEL: @test_no_spec_indirectbr(
; CHECK-NEXT: entry:
; CHECK-NEXT: br i1 [[FLAG:%.*]], label [[A:%.*]], label [[B:%.*]]
; CHECK: a:
; CHECK-NEXT: indirectbr i8* undef, [label %exit]
; CHECK: b:
; CHECK-NEXT: indirectbr i8* undef, [label %exit]
; CHECK: exit:
; CHECK-NEXT: [[P:%.*]] = phi i32 [ 7, [[A]] ], [ 11, [[B]] ]
; CHECK-NEXT: [[SUM:%.*]] = add i32 [[ARG:%.*]], [[P]]
; CHECK-NEXT: ret i32 [[SUM]]
;
entry:
br i1 %flag, label %a, label %b
; CHECK: entry:
; CHECK-NEXT: br i1 %flag, label %a, label %b
a:
indirectbr i8* undef, [label %exit]
; CHECK: a:
; CHECK-NEXT: indirectbr i8* undef, [label %exit]
b:
indirectbr i8* undef, [label %exit]
; CHECK: b:
; CHECK-NEXT: indirectbr i8* undef, [label %exit]
exit:
%p = phi i32 [ 7, %a ], [ 11, %b ]
%sum = add i32 %arg, %p
ret i32 %sum
; CHECK: exit:
; CHECK-NEXT: %[[PHI:.*]] = phi i32 [ 7, %a ], [ 11, %b ]
; CHECK-NEXT: %[[SUM:.*]] = add i32 %arg, %[[PHI]]
; CHECK-NEXT: ret i32 %[[SUM]]
}
declare void @g()
@ -369,66 +388,79 @@ declare i32 @__gxx_personality_v0(...)
; FIXME: We should be able to handle this case -- only the exceptional edge is
; impossible to split.
define i32 @test_no_spec_invoke_continue(i1 %flag, i32 %arg) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
; CHECK-LABEL: define i32 @test_no_spec_invoke_continue(
; CHECK-LABEL: @test_no_spec_invoke_continue(
; CHECK-NEXT: entry:
; CHECK-NEXT: br i1 [[FLAG:%.*]], label [[A:%.*]], label [[B:%.*]]
; CHECK: a:
; CHECK-NEXT: invoke void @g()
; CHECK-NEXT: to label [[EXIT:%.*]] unwind label [[LPAD:%.*]]
; CHECK: b:
; CHECK-NEXT: invoke void @g()
; CHECK-NEXT: to label [[EXIT]] unwind label [[LPAD]]
; CHECK: exit:
; CHECK-NEXT: [[P:%.*]] = phi i32 [ 7, [[A]] ], [ 11, [[B]] ]
; CHECK-NEXT: [[SUM:%.*]] = add i32 [[ARG:%.*]], [[P]]
; CHECK-NEXT: ret i32 [[SUM]]
; CHECK: lpad:
; CHECK-NEXT: [[LP:%.*]] = landingpad { i8*, i32 }
; CHECK-NEXT: cleanup
; CHECK-NEXT: resume { i8*, i32 } undef
;
entry:
br i1 %flag, label %a, label %b
; CHECK: entry:
; CHECK-NEXT: br i1 %flag, label %a, label %b
a:
invoke void @g()
to label %exit unwind label %lpad
; CHECK: a:
; CHECK-NEXT: invoke void @g()
; CHECK-NEXT: to label %exit unwind label %lpad
to label %exit unwind label %lpad
b:
invoke void @g()
to label %exit unwind label %lpad
; CHECK: b:
; CHECK-NEXT: invoke void @g()
; CHECK-NEXT: to label %exit unwind label %lpad
to label %exit unwind label %lpad
exit:
%p = phi i32 [ 7, %a ], [ 11, %b ]
%sum = add i32 %arg, %p
ret i32 %sum
; CHECK: exit:
; CHECK-NEXT: %[[PHI:.*]] = phi i32 [ 7, %a ], [ 11, %b ]
; CHECK-NEXT: %[[SUM:.*]] = add i32 %arg, %[[PHI]]
; CHECK-NEXT: ret i32 %[[SUM]]
lpad:
%lp = landingpad { i8*, i32 }
cleanup
cleanup
resume { i8*, i32 } undef
}
define i32 @test_no_spec_landingpad(i32 %arg, i32* %ptr) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
; CHECK-LABEL: define i32 @test_no_spec_landingpad(
; CHECK-LABEL: @test_no_spec_landingpad(
; CHECK-NEXT: entry:
; CHECK-NEXT: invoke void @g()
; CHECK-NEXT: to label [[INVOKE_CONT:%.*]] unwind label [[LPAD:%.*]]
; CHECK: invoke.cont:
; CHECK-NEXT: invoke void @g()
; CHECK-NEXT: to label [[EXIT:%.*]] unwind label [[LPAD]]
; CHECK: lpad:
; CHECK-NEXT: [[P:%.*]] = phi i32 [ 7, [[ENTRY:%.*]] ], [ 11, [[INVOKE_CONT]] ]
; CHECK-NEXT: [[LP:%.*]] = landingpad { i8*, i32 }
; CHECK-NEXT: cleanup
; CHECK-NEXT: [[SUM:%.*]] = add i32 [[ARG:%.*]], [[P]]
; CHECK-NEXT: store i32 [[SUM]], i32* [[PTR:%.*]]
; CHECK-NEXT: resume { i8*, i32 } undef
; CHECK: exit:
; CHECK-NEXT: ret i32 0
;
entry:
invoke void @g()
to label %invoke.cont unwind label %lpad
; CHECK: entry:
; CHECK-NEXT: invoke void @g()
; CHECK-NEXT: to label %invoke.cont unwind label %lpad
to label %invoke.cont unwind label %lpad
invoke.cont:
invoke void @g()
to label %exit unwind label %lpad
; CHECK: invoke.cont:
; CHECK-NEXT: invoke void @g()
; CHECK-NEXT: to label %exit unwind label %lpad
to label %exit unwind label %lpad
lpad:
%p = phi i32 [ 7, %entry ], [ 11, %invoke.cont ]
%lp = landingpad { i8*, i32 }
cleanup
cleanup
%sum = add i32 %arg, %p
store i32 %sum, i32* %ptr
resume { i8*, i32 } undef
; CHECK: lpad:
; CHECK-NEXT: %[[PHI:.*]] = phi i32 [ 7, %entry ], [ 11, %invoke.cont ]
exit:
ret i32 0
@ -437,20 +469,29 @@ exit:
declare i32 @__CxxFrameHandler3(...)
define i32 @test_no_spec_cleanuppad(i32 %arg, i32* %ptr) personality i32 (...)* @__CxxFrameHandler3 {
; CHECK-LABEL: define i32 @test_no_spec_cleanuppad(
; CHECK-LABEL: @test_no_spec_cleanuppad(
; CHECK-NEXT: entry:
; CHECK-NEXT: invoke void @g()
; CHECK-NEXT: to label [[INVOKE_CONT:%.*]] unwind label [[LPAD:%.*]]
; CHECK: invoke.cont:
; CHECK-NEXT: invoke void @g()
; CHECK-NEXT: to label [[EXIT:%.*]] unwind label [[LPAD]]
; CHECK: lpad:
; CHECK-NEXT: [[P:%.*]] = phi i32 [ 7, [[ENTRY:%.*]] ], [ 11, [[INVOKE_CONT]] ]
; CHECK-NEXT: [[CP:%.*]] = cleanuppad within none []
; CHECK-NEXT: [[SUM:%.*]] = add i32 [[ARG:%.*]], [[P]]
; CHECK-NEXT: store i32 [[SUM]], i32* [[PTR:%.*]]
; CHECK-NEXT: cleanupret from [[CP]] unwind to caller
; CHECK: exit:
; CHECK-NEXT: ret i32 0
;
entry:
invoke void @g()
to label %invoke.cont unwind label %lpad
; CHECK: entry:
; CHECK-NEXT: invoke void @g()
; CHECK-NEXT: to label %invoke.cont unwind label %lpad
to label %invoke.cont unwind label %lpad
invoke.cont:
invoke void @g()
to label %exit unwind label %lpad
; CHECK: invoke.cont:
; CHECK-NEXT: invoke void @g()
; CHECK-NEXT: to label %exit unwind label %lpad
to label %exit unwind label %lpad
lpad:
%p = phi i32 [ 7, %entry ], [ 11, %invoke.cont ]
@ -458,8 +499,6 @@ lpad:
%sum = add i32 %arg, %p
store i32 %sum, i32* %ptr
cleanupret from %cp unwind to caller
; CHECK: lpad:
; CHECK-NEXT: %[[PHI:.*]] = phi i32 [ 7, %entry ], [ 11, %invoke.cont ]
exit:
ret i32 0
@ -469,21 +508,28 @@ exit:
; for us to handle but in an unreachable region and with non-PHI use-def
; cycles.
define i32 @test_unreachable_non_phi_cycles(i1 %flag, i32 %arg) {
; CHECK-LABEL: define i32 @test_unreachable_non_phi_cycles(
; CHECK-LABEL: @test_unreachable_non_phi_cycles(
; CHECK-NEXT: entry:
; CHECK-NEXT: ret i32 42
; CHECK: a:
; CHECK-NEXT: br label [[EXIT:%.*]]
; CHECK: b:
; CHECK-NEXT: br label [[EXIT]]
; CHECK: exit:
; CHECK-NEXT: [[P:%.*]] = phi i32 [ 7, [[A:%.*]] ], [ 11, [[B:%.*]] ]
; CHECK-NEXT: [[ZEXT:%.*]] = zext i32 [[SUM:%.*]] to i64
; CHECK-NEXT: [[TRUNC:%.*]] = trunc i64 [[ZEXT]] to i32
; CHECK-NEXT: [[SUM]] = add i32 [[TRUNC]], [[P]]
; CHECK-NEXT: br i1 [[FLAG:%.*]], label [[A]], label [[B]]
;
entry:
ret i32 42
; CHECK: entry:
; CHECK-NEXT: ret i32 42
a:
br label %exit
; CHECK: a:
; CHECK-NEXT: br label %exit
b:
br label %exit
; CHECK: b:
; CHECK-NEXT: br label %exit
exit:
%p = phi i32 [ 7, %a ], [ 11, %b ]
@ -491,12 +537,6 @@ exit:
%trunc = trunc i64 %zext to i32
%sum = add i32 %trunc, %p
br i1 %flag, label %a, label %b
; CHECK: exit:
; CHECK-NEXT: %[[PHI:.*]] = phi i32 [ 7, %a ], [ 11, %b ]
; CHECK-NEXT: %[[ZEXT:.*]] = zext i32 %[[SUM:.*]] to i64
; CHECK-NEXT: %[[TRUNC:.*]] = trunc i64 %[[ZEXT]] to i32
; CHECK-NEXT: %[[SUM]] = add i32 %[[TRUNC]], %[[PHI]]
; CHECK-NEXT: br i1 %flag, label %a, label %b
}
; Check that we don't speculate in the face of an expensive immediate. There
@ -508,88 +548,92 @@ exit:
; happen to be any way to use free-to-speculate instructions here so that it
; would be the only interesting property.
define i64 @test_expensive_imm(i32 %flag, i64 %arg) {
; CHECK-LABEL: define i64 @test_expensive_imm(
; CHECK-LABEL: @test_expensive_imm(
; CHECK-NEXT: entry:
; CHECK-NEXT: switch i32 [[FLAG:%.*]], label [[A:%.*]] [
; CHECK-NEXT: i32 1, label [[B:%.*]]
; CHECK-NEXT: i32 2, label [[C:%.*]]
; CHECK-NEXT: i32 3, label [[D:%.*]]
; CHECK-NEXT: ]
; CHECK: a:
; CHECK-NEXT: br label [[EXIT:%.*]]
; CHECK: b:
; CHECK-NEXT: br label [[EXIT]]
; CHECK: c:
; CHECK-NEXT: br label [[EXIT]]
; CHECK: d:
; CHECK-NEXT: br label [[EXIT]]
; CHECK: exit:
; CHECK-NEXT: [[P:%.*]] = phi i64 [ 4294967296, [[A]] ], [ 1, [[B]] ], [ 1, [[C]] ], [ 1, [[D]] ]
; CHECK-NEXT: [[SUM1:%.*]] = add i64 [[ARG:%.*]], [[P]]
; CHECK-NEXT: [[SUM2:%.*]] = add i64 [[SUM1]], [[P]]
; CHECK-NEXT: ret i64 [[SUM2]]
;
entry:
switch i32 %flag, label %a [
i32 1, label %b
i32 2, label %c
i32 3, label %d
i32 1, label %b
i32 2, label %c
i32 3, label %d
]
; CHECK: switch i32 %flag, label %a [
; CHECK-NEXT: i32 1, label %b
; CHECK-NEXT: i32 2, label %c
; CHECK-NEXT: i32 3, label %d
; CHECK-NEXT: ]
a:
br label %exit
; CHECK: a:
; CHECK-NEXT: br label %exit
b:
br label %exit
; CHECK: b:
; CHECK-NEXT: br label %exit
c:
br label %exit
; CHECK: c:
; CHECK-NEXT: br label %exit
d:
br label %exit
; CHECK: d:
; CHECK-NEXT: br label %exit
exit:
%p = phi i64 [ 4294967296, %a ], [ 1, %b ], [ 1, %c ], [ 1, %d ]
%sum1 = add i64 %arg, %p
%sum2 = add i64 %sum1, %p
ret i64 %sum2
; CHECK: exit:
; CHECK-NEXT: %[[PHI:.*]] = phi i64 [ {{[0-9]+}}, %a ], [ 1, %b ], [ 1, %c ], [ 1, %d ]
; CHECK-NEXT: %[[SUM1:.*]] = add i64 %arg, %[[PHI]]
; CHECK-NEXT: %[[SUM2:.*]] = add i64 %[[SUM1]], %[[PHI]]
; CHECK-NEXT: ret i64 %[[SUM2]]
}
define i32 @test_no_spec_non_postdominating_uses(i1 %flag1, i1 %flag2, i32 %arg) {
; CHECK-LABEL: define i32 @test_no_spec_non_postdominating_uses(
; CHECK-LABEL: @test_no_spec_non_postdominating_uses(
; CHECK-NEXT: entry:
; CHECK-NEXT: br i1 [[FLAG1:%.*]], label [[A:%.*]], label [[B:%.*]]
; CHECK: a:
; CHECK-NEXT: [[SUM1_0:%.*]] = add i32 [[ARG:%.*]], 7
; CHECK-NEXT: br label [[MERGE:%.*]]
; CHECK: b:
; CHECK-NEXT: [[SUM1_1:%.*]] = add i32 [[ARG]], 11
; CHECK-NEXT: br label [[MERGE]]
; CHECK: merge:
; CHECK-NEXT: [[SUM1_PHI:%.*]] = phi i32 [ [[SUM1_0]], [[A]] ], [ [[SUM1_1]], [[B]] ]
; CHECK-NEXT: [[P2:%.*]] = phi i32 [ 13, [[A]] ], [ 42, [[B]] ]
; CHECK-NEXT: br i1 [[FLAG2:%.*]], label [[EXIT1:%.*]], label [[EXIT2:%.*]]
; CHECK: exit1:
; CHECK-NEXT: ret i32 [[SUM1_PHI]]
; CHECK: exit2:
; CHECK-NEXT: [[SUM2:%.*]] = add i32 [[ARG]], [[P2]]
; CHECK-NEXT: ret i32 [[SUM2]]
;
entry:
br i1 %flag1, label %a, label %b
; CHECK: br i1 %flag1, label %a, label %b
a:
br label %merge
; CHECK: a:
; CHECK-NEXT: %[[SUM_A:.*]] = add i32 %arg, 7
; CHECK-NEXT: br label %merge
b:
br label %merge
; CHECK: b:
; CHECK-NEXT: %[[SUM_B:.*]] = add i32 %arg, 11
; CHECK-NEXT: br label %merge
merge:
%p1 = phi i32 [ 7, %a ], [ 11, %b ]
%p2 = phi i32 [ 13, %a ], [ 42, %b ]
%sum1 = add i32 %arg, %p1
br i1 %flag2, label %exit1, label %exit2
; CHECK: merge:
; CHECK-NEXT: %[[PHI1:.*]] = phi i32 [ %[[SUM_A]], %a ], [ %[[SUM_B]], %b ]
; CHECK-NEXT: %[[PHI2:.*]] = phi i32 [ 13, %a ], [ 42, %b ]
; CHECK-NEXT: br i1 %flag2, label %exit1, label %exit2
exit1:
ret i32 %sum1
; CHECK: exit1:
; CHECK-NEXT: ret i32 %[[PHI1]]
exit2:
%sum2 = add i32 %arg, %p2
ret i32 %sum2
; CHECK: exit2:
; CHECK-NEXT: %[[SUM2:.*]] = add i32 %arg, %[[PHI2]]
; CHECK-NEXT: ret i32 %[[SUM2]]
}