mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-02 16:56:39 +00:00
[MemorySSA] Update for partial unswitch.
Update MSSA for blocks cloned when doing partial unswitching. Enable additional testing with MSSA. Resolves PR43641. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@374850 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c7464a4ca2
commit
caaecec384
@ -2140,6 +2140,13 @@ static void unswitchNontrivialInvariants(
|
||||
// the branch in the split block.
|
||||
buildPartialUnswitchConditionalBranch(*SplitBB, Invariants, Direction,
|
||||
*ClonedPH, *LoopPH);
|
||||
if (MSSAU) {
|
||||
// Perform MSSA cloning updates.
|
||||
for (auto &VMap : VMaps)
|
||||
MSSAU->updateForClonedLoop(LBRPO, ExitBlocks, *VMap,
|
||||
/*IgnoreIncomingWithNoClones=*/true);
|
||||
MSSAU->updateExitBlocksForClonedLoop(ExitBlocks, VMaps, DT);
|
||||
}
|
||||
DTUpdates.push_back({DominatorTree::Insert, SplitBB, ClonedPH});
|
||||
}
|
||||
|
||||
|
22
test/Analysis/MemorySSA/pr43641.ll
Normal file
22
test/Analysis/MemorySSA/pr43641.ll
Normal file
@ -0,0 +1,22 @@
|
||||
; RUN: opt -simple-loop-unswitch -enable-nontrivial-unswitch -enable-mssa-loop-dependency -verify-memoryssa -S < %s | FileCheck %s
|
||||
; REQUIRES: asserts
|
||||
|
||||
; CHECK-LABEL: @c
|
||||
define dso_local void @c(i32 signext %d) local_unnamed_addr {
|
||||
entry:
|
||||
br i1 undef, label %while.end, label %while.body.lr.ph
|
||||
|
||||
while.body.lr.ph: ; preds = %entry
|
||||
%tobool1 = icmp ne i32 %d, 0
|
||||
br label %while.body
|
||||
|
||||
while.body: ; preds = %while.body, %while.body.lr.ph
|
||||
%call = tail call signext i32 bitcast (i32 (...)* @e to i32 ()*)()
|
||||
%0 = and i1 %tobool1, undef
|
||||
br i1 %0, label %while.body, label %while.end
|
||||
|
||||
while.end: ; preds = %while.body, %entry
|
||||
ret void
|
||||
}
|
||||
|
||||
declare signext i32 @e(...) local_unnamed_addr
|
@ -1,5 +1,6 @@
|
||||
; RUN: opt < %s -simple-loop-unswitch -enable-nontrivial-unswitch -S 2>&1 | FileCheck %s
|
||||
; RUN: opt < %s -passes='unswitch<nontrivial>' -S 2>&1 | FileCheck %s
|
||||
; RUN: opt < %s -passes='loop-mssa(unswitch<nontrivial>)' -S 2>&1 | FileCheck %s
|
||||
;
|
||||
; Checking that (dead) blocks from inner loop are deleted after unswitch.
|
||||
;
|
||||
|
@ -10,6 +10,13 @@
|
||||
; RUN: -unswitch-num-initial-unscaled-candidates=0 -unswitch-siblings-toplevel-div=16 \
|
||||
; RUN: -passes='loop(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
|
||||
;
|
||||
; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
|
||||
; RUN: -unswitch-num-initial-unscaled-candidates=0 -unswitch-siblings-toplevel-div=1 \
|
||||
; RUN: -passes='loop-mssa(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
|
||||
;
|
||||
; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
|
||||
; RUN: -unswitch-num-initial-unscaled-candidates=0 -unswitch-siblings-toplevel-div=16 \
|
||||
; RUN: -passes='loop-mssa(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
|
||||
;
|
||||
; When we relax the candidates part of a multiplier formula
|
||||
; (unscaled candidates == 4) we start getting some unswitches,
|
||||
@ -20,6 +27,11 @@
|
||||
; RUN: -passes='loop(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | \
|
||||
; RUN: sort -b -k 1 | FileCheck %s --check-prefixes=LOOP-UNSCALE4-DIV1
|
||||
;
|
||||
; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
|
||||
; RUN: -unswitch-num-initial-unscaled-candidates=4 -unswitch-siblings-toplevel-div=1 \
|
||||
; RUN: -passes='loop-mssa(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | \
|
||||
; RUN: sort -b -k 1 | FileCheck %s --check-prefixes=LOOP-UNSCALE4-DIV1
|
||||
;
|
||||
; NB: sort -b is essential here and below, otherwise blanks might lead to different
|
||||
; order depending on locale.
|
||||
;
|
||||
@ -28,6 +40,10 @@
|
||||
; RUN: -passes='loop(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | \
|
||||
; RUN: sort -b -k 1 | FileCheck %s --check-prefixes=LOOP-UNSCALE4-DIV2
|
||||
;
|
||||
; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
|
||||
; RUN: -unswitch-num-initial-unscaled-candidates=4 -unswitch-siblings-toplevel-div=2 \
|
||||
; RUN: -passes='loop-mssa(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | \
|
||||
; RUN: sort -b -k 1 | FileCheck %s --check-prefixes=LOOP-UNSCALE4-DIV2
|
||||
;
|
||||
; Get
|
||||
; 2^(num conds) == 2^5 = 32
|
||||
@ -37,6 +53,10 @@
|
||||
; RUN: -passes='loop(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | \
|
||||
; RUN: sort -b -k 1 | FileCheck %s --check-prefixes=LOOP32
|
||||
;
|
||||
; RUN: opt < %s -enable-unswitch-cost-multiplier=false \
|
||||
; RUN: -passes='loop-mssa(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | \
|
||||
; RUN: sort -b -k 1 | FileCheck %s --check-prefixes=LOOP32
|
||||
;
|
||||
; Single loop nest, not unswitched
|
||||
; LOOP1: Loop at depth 1 containing:
|
||||
; LOOP1: Loop at depth 2 containing:
|
||||
|
@ -15,7 +15,15 @@
|
||||
; RUN: -unswitch-num-initial-unscaled-candidates=0 -unswitch-siblings-toplevel-div=16 \
|
||||
; RUN: -passes='loop(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
|
||||
;
|
||||
; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
|
||||
; RUN: -unswitch-num-initial-unscaled-candidates=0 -unswitch-siblings-toplevel-div=1 \
|
||||
; RUN: -passes='loop-mssa(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
|
||||
;
|
||||
; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
|
||||
; RUN: -unswitch-num-initial-unscaled-candidates=0 -unswitch-siblings-toplevel-div=16 \
|
||||
; RUN: -passes='loop-mssa(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
|
||||
;
|
||||
; When we relax the candidates part of a multiplier formula
|
||||
; When we relax the candidates part of a multiplier formula
|
||||
; (unscaled candidates == 2) we start getting some unswitches in outer loops,
|
||||
; which leads to siblings multiplier kicking in.
|
||||
@ -25,6 +33,11 @@
|
||||
; RUN: -passes='loop(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | \
|
||||
; RUN: sort -b -k 1 | FileCheck %s --check-prefixes=LOOP-UNSCALE3-DIV1
|
||||
;
|
||||
; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
|
||||
; RUN: -unswitch-num-initial-unscaled-candidates=3 -unswitch-siblings-toplevel-div=1 \
|
||||
; RUN: -passes='loop-mssa(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | \
|
||||
; RUN: sort -b -k 1 | FileCheck %s --check-prefixes=LOOP-UNSCALE3-DIV1
|
||||
;
|
||||
; NB: sort -b is essential here and below, otherwise blanks might lead to different
|
||||
; order depending on locale.
|
||||
;
|
||||
@ -33,12 +46,21 @@
|
||||
; RUN: -passes='loop(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | \
|
||||
; RUN: sort -b -k 1 | FileCheck %s --check-prefixes=LOOP-UNSCALE3-DIV2
|
||||
;
|
||||
; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
|
||||
; RUN: -unswitch-num-initial-unscaled-candidates=3 -unswitch-siblings-toplevel-div=2 \
|
||||
; RUN: -passes='loop-mssa(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | \
|
||||
; RUN: sort -b -k 1 | FileCheck %s --check-prefixes=LOOP-UNSCALE3-DIV2
|
||||
;
|
||||
; With disabled cost-multiplier we get maximal possible amount of unswitches.
|
||||
;
|
||||
; RUN: opt < %s -enable-unswitch-cost-multiplier=false \
|
||||
; RUN: -passes='loop(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | \
|
||||
; RUN: sort -b -k 1 | FileCheck %s --check-prefixes=LOOP-MAX
|
||||
;
|
||||
; RUN: opt < %s -enable-unswitch-cost-multiplier=false \
|
||||
; RUN: -passes='loop-mssa(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | \
|
||||
; RUN: sort -b -k 1 | FileCheck %s --check-prefixes=LOOP-MAX
|
||||
;
|
||||
; Single loop nest, not unswitched
|
||||
; LOOP1: Loop at depth 1 containing:
|
||||
; LOOP1-NOT: Loop at depth 1 containing:
|
||||
|
@ -10,6 +10,16 @@
|
||||
; RUN: -unswitch-num-initial-unscaled-candidates=0 -unswitch-siblings-toplevel-div=8 \
|
||||
; RUN: -passes='loop(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
|
||||
;
|
||||
; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
|
||||
; RUN: -unswitch-num-initial-unscaled-candidates=0 -unswitch-siblings-toplevel-div=1 \
|
||||
; RUN: -passes='loop-mssa(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
|
||||
;
|
||||
; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
|
||||
; RUN: -unswitch-num-initial-unscaled-candidates=0 -unswitch-siblings-toplevel-div=8 \
|
||||
; RUN: -passes='loop-mssa(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
|
||||
;
|
||||
; With relaxed candidates multiplier (unscaled candidates == 8) we should allow
|
||||
; some unswitches to happen until siblings multiplier starts kicking in:
|
||||
; With relaxed candidates multiplier (unscaled candidates == 8) we should allow
|
||||
; some unswitches to happen until siblings multiplier starts kicking in:
|
||||
;
|
||||
@ -17,6 +27,10 @@
|
||||
; RUN: -unswitch-num-initial-unscaled-candidates=8 -unswitch-siblings-toplevel-div=1 \
|
||||
; RUN: -passes='loop(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP5
|
||||
;
|
||||
; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
|
||||
; RUN: -unswitch-num-initial-unscaled-candidates=8 -unswitch-siblings-toplevel-div=1 \
|
||||
; RUN: -passes='loop-mssa(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP5
|
||||
;
|
||||
; With relaxed candidates multiplier (unscaled candidates == 8) and with relaxed
|
||||
; siblings multiplier for top-level loops (toplevel-div == 8) we should get
|
||||
; 2^(num conds) == 2^5 == 32
|
||||
@ -26,6 +40,10 @@
|
||||
; RUN: -unswitch-num-initial-unscaled-candidates=8 -unswitch-siblings-toplevel-div=8 \
|
||||
; RUN: -passes='loop(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP32
|
||||
;
|
||||
; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
|
||||
; RUN: -unswitch-num-initial-unscaled-candidates=8 -unswitch-siblings-toplevel-div=8 \
|
||||
; RUN: -passes='loop-mssa(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP32
|
||||
;
|
||||
; Similarly get
|
||||
; 2^(num conds) == 2^5 == 32
|
||||
; copies of the loop when cost multiplier is disabled:
|
||||
@ -33,6 +51,8 @@
|
||||
; RUN: opt < %s -enable-unswitch-cost-multiplier=false \
|
||||
; RUN: -passes='loop(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP32
|
||||
;
|
||||
; RUN: opt < %s -enable-unswitch-cost-multiplier=false \
|
||||
; RUN: -passes='loop-mssa(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP32
|
||||
;
|
||||
; Single loop, not unswitched
|
||||
; LOOP1: Loop at depth 1 containing:
|
||||
|
@ -24,6 +24,26 @@
|
||||
; RUN: -passes='loop(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
|
||||
;
|
||||
;
|
||||
; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
|
||||
; RUN: -unswitch-num-initial-unscaled-candidates=0 -unswitch-siblings-toplevel-div=1 \
|
||||
; RUN: -passes='loop-mssa(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
|
||||
;
|
||||
; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
|
||||
; RUN: -unswitch-num-initial-unscaled-candidates=0 -unswitch-siblings-toplevel-div=8 \
|
||||
; RUN: -passes='loop-mssa(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
|
||||
;
|
||||
; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
|
||||
; RUN: -unswitch-num-initial-unscaled-candidates=8 -unswitch-siblings-toplevel-div=1 \
|
||||
; RUN: -passes='loop-mssa(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
|
||||
;
|
||||
; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
|
||||
; RUN: -unswitch-num-initial-unscaled-candidates=8 -unswitch-siblings-toplevel-div=8 \
|
||||
; RUN: -passes='loop-mssa(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
|
||||
;
|
||||
; RUN: opt < %s -enable-unswitch-cost-multiplier=false \
|
||||
; RUN: -passes='loop-mssa(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
|
||||
;
|
||||
;
|
||||
; Single loop, not unswitched
|
||||
; LOOP1: Loop at depth 1 containing:
|
||||
; LOOP1-NOT: Loop at depth 1 containing:
|
||||
|
@ -17,6 +17,13 @@
|
||||
; RUN: -unswitch-num-initial-unscaled-candidates=0 -unswitch-siblings-toplevel-div=16 \
|
||||
; RUN: -passes='loop(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
|
||||
;
|
||||
; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
|
||||
; RUN: -unswitch-num-initial-unscaled-candidates=0 -unswitch-siblings-toplevel-div=1 \
|
||||
; RUN: -passes='loop-mssa(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
|
||||
;
|
||||
; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
|
||||
; RUN: -unswitch-num-initial-unscaled-candidates=0 -unswitch-siblings-toplevel-div=16 \
|
||||
; RUN: -passes='loop-mssa(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
|
||||
;
|
||||
; With relaxed candidates multiplier (unscaled candidates == 8) we should allow
|
||||
; some unswitches to happen until siblings multiplier starts kicking in:
|
||||
@ -26,6 +33,11 @@
|
||||
; RUN: -passes='loop(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | \
|
||||
; RUN: sort -b -k 1 | FileCheck %s --check-prefixes=LOOP-RELAX
|
||||
;
|
||||
; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
|
||||
; RUN: -unswitch-num-initial-unscaled-candidates=8 -unswitch-siblings-toplevel-div=1 \
|
||||
; RUN: -passes='loop-mssa(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | \
|
||||
; RUN: sort -b -k 1 | FileCheck %s --check-prefixes=LOOP-RELAX
|
||||
;
|
||||
; With relaxed candidates multiplier (unscaled candidates == 8) and with relaxed
|
||||
; siblings multiplier for top-level loops (toplevel-div == 8) we should get
|
||||
; considerably more copies of the loop (especially top-level ones).
|
||||
@ -35,12 +47,20 @@
|
||||
; RUN: -passes='loop(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | \
|
||||
; RUN: sort -b -k 1 | FileCheck %s --check-prefixes=LOOP-RELAX2
|
||||
;
|
||||
; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
|
||||
; RUN: -unswitch-num-initial-unscaled-candidates=8 -unswitch-siblings-toplevel-div=8 \
|
||||
; RUN: -passes='loop-mssa(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | \
|
||||
; RUN: sort -b -k 1 | FileCheck %s --check-prefixes=LOOP-RELAX2
|
||||
;
|
||||
; We get hundreds of copies of the loop when cost multiplier is disabled:
|
||||
;
|
||||
; RUN: opt < %s -enable-unswitch-cost-multiplier=false \
|
||||
; RUN: -passes='loop(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | \
|
||||
; RUN: sort -b -k 1 | FileCheck %s --check-prefixes=LOOP-MAX
|
||||
;
|
||||
; RUN: opt < %s -enable-unswitch-cost-multiplier=false \
|
||||
; RUN: -passes='loop-mssa(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | \
|
||||
; RUN: sort -b -k 1 | FileCheck %s --check-prefixes=LOOP-MAX
|
||||
|
||||
; Single loop nest, not unswitched
|
||||
; LOOP1: Loop at depth 1 containing:
|
||||
|
@ -1,6 +1,7 @@
|
||||
; Specifically exercise the cost modeling for non-trivial loop unswitching.
|
||||
;
|
||||
; RUN: opt -passes='loop(unswitch<nontrivial>),verify<loops>' -unswitch-threshold=5 -S < %s | FileCheck %s
|
||||
; RUN: opt -passes='loop-mssa(unswitch<nontrivial>),verify<loops>' -unswitch-threshold=5 -S < %s | FileCheck %s
|
||||
; RUN: opt -simple-loop-unswitch -enable-nontrivial-unswitch -unswitch-threshold=5 -S < %s | FileCheck %s
|
||||
; RUN: opt -simple-loop-unswitch -enable-nontrivial-unswitch -unswitch-threshold=5 -enable-mssa-loop-dependency=true -verify-memoryssa -S < %s | FileCheck %s
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
; REQUIRES: asserts
|
||||
; RUN: opt -passes='unswitch<nontrivial>' -disable-output -S < %s
|
||||
; RUN: opt -passes='loop-mssa(unswitch<nontrivial>)' -disable-output -S < %s
|
||||
; RUN: opt -simple-loop-unswitch -enable-nontrivial-unswitch -disable-output -S < %s
|
||||
|
||||
; This loop shouldn't trigger asserts in SimpleLoopUnswitch.
|
||||
|
@ -1,4 +1,5 @@
|
||||
; RUN: opt -passes='loop(unswitch<nontrivial>),verify<loops>' -S < %s | FileCheck %s
|
||||
; RUN: opt -passes='loop-mssa(unswitch<nontrivial>),verify<loops>' -S < %s | FileCheck %s
|
||||
; RUN: opt -simple-loop-unswitch -enable-nontrivial-unswitch -S < %s | FileCheck %s
|
||||
; RUN: opt -simple-loop-unswitch -enable-nontrivial-unswitch -enable-mssa-loop-dependency=true -verify-memoryssa -S < %s | FileCheck %s
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user