From 4be8707e6450fafceaad2fc2ea86dc4b5d4bdd4f Mon Sep 17 00:00:00 2001 From: Roman Lebedev Date: Sat, 19 Dec 2020 12:48:32 +0300 Subject: [PATCH] [SimplifyCFG] Teach FoldTwoEntryPHINode() to preserve DomTree Still boring, simply drop all edges to successors of DomBlock, and add an edge to to BB instead. --- llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 15 +++++++++++++-- llvm/test/Transforms/IndVarSimplify/loop_evaluate_1.ll | 2 +- llvm/test/Transforms/IndVarSimplify/loop_evaluate_2.ll | 2 +- .../PhaseOrdering/unsigned-multiply-overflow-check.ll | 10 +++++----- llvm/test/Transforms/SimplifyCFG/ARM/phi-eliminate.ll | 12 ++++++------ llvm/test/Transforms/SimplifyCFG/ARM/select-trunc-i64.ll | 2 +- llvm/test/Transforms/SimplifyCFG/ARM/speculate-math.ll | 6 +++--- .../Transforms/SimplifyCFG/ARM/speculate-vector-ops.ll | 4 ++-- .../SimplifyCFG/ConditionalTrappingConstantExpr.ll | 2 +- llvm/test/Transforms/SimplifyCFG/PR9946.ll | 2 +- llvm/test/Transforms/SimplifyCFG/PhiBlockMerge.ll | 2 +- llvm/test/Transforms/SimplifyCFG/PhiEliminate2.ll | 2 +- llvm/test/Transforms/SimplifyCFG/PhiEliminate3.ll | 6 +++--- .../test/Transforms/SimplifyCFG/RISCV/select-trunc-i64.ll | 2 +- llvm/test/Transforms/SimplifyCFG/UnreachableEliminate.ll | 2 +- llvm/test/Transforms/SimplifyCFG/X86/PR29163.ll | 2 +- llvm/test/Transforms/SimplifyCFG/X86/SpeculativeExec.ll | 2 +- .../Transforms/SimplifyCFG/X86/safe-low-bit-extract.ll | 2 +- .../Transforms/SimplifyCFG/X86/speculate-cttz-ctlz.ll | 6 +++--- llvm/test/Transforms/SimplifyCFG/bbi-23595.ll | 2 +- llvm/test/Transforms/SimplifyCFG/clamp.ll | 2 +- .../test/Transforms/SimplifyCFG/hoist-dbgvalue-inlined.ll | 2 +- llvm/test/Transforms/SimplifyCFG/no-md-sink.ll | 2 +- llvm/test/Transforms/SimplifyCFG/opt-for-fuzzing.ll | 2 +- llvm/test/Transforms/SimplifyCFG/safe-abs.ll | 2 +- .../SimplifyCFG/signbit-like-value-extension.ll | 2 +- llvm/test/Transforms/SimplifyCFG/speculate-math.ll | 4 ++-- llvm/test/Transforms/SimplifyCFG/speculate-vector-ops.ll | 2 +- llvm/test/Transforms/SimplifyCFG/speculate-with-offset.ll | 2 +- .../SimplifyCFG/unsigned-multiplication-will-overflow.ll | 6 +++--- 30 files changed, 61 insertions(+), 50 deletions(-) diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 4bac35e..1e4ad30 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -2437,7 +2437,7 @@ static bool FoldCondBranchOnPHI(BranchInst *BI, const DataLayout &DL, /// Given a BB that starts with the specified two-entry PHI node, /// see if we can eliminate it. static bool FoldTwoEntryPHINode(PHINode *PN, const TargetTransformInfo &TTI, - const DataLayout &DL) { + DomTreeUpdater *DTU, const DataLayout &DL) { // Ok, this is a two entry PHI node. Check to see if this is a simple "if // statement", which has a very simple dominance structure. Basically, we // are trying to find the condition that is being branched on, which @@ -2587,7 +2587,18 @@ static bool FoldTwoEntryPHINode(PHINode *PN, const TargetTransformInfo &TTI, Instruction *OldTI = DomBlock->getTerminator(); Builder.SetInsertPoint(OldTI); Builder.CreateBr(BB); + + SmallVector Updates; + if (DTU) { + for (auto *Successor : successors(DomBlock)) + Updates.push_back({DominatorTree::Delete, DomBlock, Successor}); + Updates.push_back({DominatorTree::Insert, DomBlock, BB}); + } + OldTI->eraseFromParent(); + if (DTU) + DTU->applyUpdatesPermissive(Updates); + return true; } @@ -6381,7 +6392,7 @@ bool SimplifyCFGOpt::simplifyOnceImpl(BasicBlock *BB) { // eliminate it, do so now. if (auto *PN = dyn_cast(BB->begin())) if (PN->getNumIncomingValues() == 2) - Changed |= FoldTwoEntryPHINode(PN, TTI, DL); + Changed |= FoldTwoEntryPHINode(PN, TTI, DTU, DL); } Instruction *Terminator = BB->getTerminator(); diff --git a/llvm/test/Transforms/IndVarSimplify/loop_evaluate_1.ll b/llvm/test/Transforms/IndVarSimplify/loop_evaluate_1.ll index 6edacc1..4dceec4 100644 --- a/llvm/test/Transforms/IndVarSimplify/loop_evaluate_1.ll +++ b/llvm/test/Transforms/IndVarSimplify/loop_evaluate_1.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt < %s -indvars -loop-deletion -simplifycfg -S | FileCheck %s +; RUN: opt < %s -indvars -loop-deletion -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s ; Testcase distilled from 256.bzip2 define i32 @test1() { diff --git a/llvm/test/Transforms/IndVarSimplify/loop_evaluate_2.ll b/llvm/test/Transforms/IndVarSimplify/loop_evaluate_2.ll index 3d416d3..9dbb69f 100644 --- a/llvm/test/Transforms/IndVarSimplify/loop_evaluate_2.ll +++ b/llvm/test/Transforms/IndVarSimplify/loop_evaluate_2.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -indvars -loop-deletion -simplifycfg | opt -analyze -loops -enable-new-pm=0 | FileCheck %s +; RUN: opt < %s -indvars -loop-deletion -simplifycfg -simplifycfg-require-and-preserve-domtree=1 | opt -analyze -loops -enable-new-pm=0 | FileCheck %s ; PR1179 ; CHECK-NOT: Loop Containing diff --git a/llvm/test/Transforms/PhaseOrdering/unsigned-multiply-overflow-check.ll b/llvm/test/Transforms/PhaseOrdering/unsigned-multiply-overflow-check.ll index efa99c0..b0efba3 100644 --- a/llvm/test/Transforms/PhaseOrdering/unsigned-multiply-overflow-check.ll +++ b/llvm/test/Transforms/PhaseOrdering/unsigned-multiply-overflow-check.ll @@ -1,10 +1,10 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt -simplifycfg -S < %s | FileCheck %s --check-prefix=SIMPLIFYCFG +; RUN: opt -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S < %s | FileCheck %s --check-prefix=SIMPLIFYCFG ; RUN: opt -instcombine -S < %s | FileCheck %s --check-prefix=INSTCOMBINEONLY -; RUN: opt -instcombine -simplifycfg -S < %s | FileCheck %s --check-prefix=INSTCOMBINESIMPLIFYCFGONLY -; RUN: opt -instcombine -simplifycfg -instcombine -S < %s | FileCheck %s --check-prefix=INSTCOMBINESIMPLIFYCFGINSTCOMBINE -; RUN: opt -instcombine -simplifycfg -phi-node-folding-threshold=3 -S < %s | FileCheck %s --check-prefix=INSTCOMBINESIMPLIFYCFGONLY -; RUN: opt -instcombine -simplifycfg -instcombine -phi-node-folding-threshold=3 -S < %s | FileCheck %s --check-prefix=INSTCOMBINESIMPLIFYCFGINSTCOMBINE +; RUN: opt -instcombine -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S < %s | FileCheck %s --check-prefix=INSTCOMBINESIMPLIFYCFGONLY +; RUN: opt -instcombine -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -instcombine -S < %s | FileCheck %s --check-prefix=INSTCOMBINESIMPLIFYCFGINSTCOMBINE +; RUN: opt -instcombine -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -phi-node-folding-threshold=3 -S < %s | FileCheck %s --check-prefix=INSTCOMBINESIMPLIFYCFGONLY +; RUN: opt -instcombine -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -instcombine -phi-node-folding-threshold=3 -S < %s | FileCheck %s --check-prefix=INSTCOMBINESIMPLIFYCFGINSTCOMBINE target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-pc-linux-gnu" diff --git a/llvm/test/Transforms/SimplifyCFG/ARM/phi-eliminate.ll b/llvm/test/Transforms/SimplifyCFG/ARM/phi-eliminate.ll index 87d9f6f..533f198 100644 --- a/llvm/test/Transforms/SimplifyCFG/ARM/phi-eliminate.ll +++ b/llvm/test/Transforms/SimplifyCFG/ARM/phi-eliminate.ll @@ -1,10 +1,10 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt -mtriple=thumbv8m.main < %s -simplifycfg -S -two-entry-phi-node-folding-threshold=4 | FileCheck %s --check-prefixes=CHECK-TWO-FOLD-4,CHECK-V8M-TWO-FOLD-4 -; RUN: opt -mtriple=armv8a < %s -simplifycfg -S -two-entry-phi-node-folding-threshold=4 | FileCheck %s --check-prefixes=CHECK-TWO-FOLD-4,CHECK-V8A-TWO-FOLD-4 -; RUN: opt -mtriple=thumbv8m.main < %s -simplifycfg -S -two-entry-phi-node-folding-threshold=5 | FileCheck %s --check-prefixes=CHECK-TWO-FOLD-5,CHECK-V8M-TWO-FOLD-5 -; RUN: opt -mtriple=armv8a < %s -simplifycfg -S -two-entry-phi-node-folding-threshold=5 | FileCheck %s --check-prefixes=CHECK-TWO-FOLD-5,CHECK-V8A-TWO-FOLD-5 -; RUN: opt -mtriple=thumbv8m.main < %s -simplifycfg -S -two-entry-phi-node-folding-threshold=6 | FileCheck %s --check-prefixes=CHECK-TWO-FOLD-6,CHECK-V8M-TWO-FOLD-6 -; RUN: opt -mtriple=armv8a < %s -simplifycfg -S -two-entry-phi-node-folding-threshold=6 | FileCheck %s --check-prefixes=CHECK-TWO-FOLD-6,CHECK-V8A-TWO-FOLD-6 +; RUN: opt -mtriple=thumbv8m.main < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S -two-entry-phi-node-folding-threshold=4 | FileCheck %s --check-prefixes=CHECK-TWO-FOLD-4,CHECK-V8M-TWO-FOLD-4 +; RUN: opt -mtriple=armv8a < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S -two-entry-phi-node-folding-threshold=4 | FileCheck %s --check-prefixes=CHECK-TWO-FOLD-4,CHECK-V8A-TWO-FOLD-4 +; RUN: opt -mtriple=thumbv8m.main < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S -two-entry-phi-node-folding-threshold=5 | FileCheck %s --check-prefixes=CHECK-TWO-FOLD-5,CHECK-V8M-TWO-FOLD-5 +; RUN: opt -mtriple=armv8a < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S -two-entry-phi-node-folding-threshold=5 | FileCheck %s --check-prefixes=CHECK-TWO-FOLD-5,CHECK-V8A-TWO-FOLD-5 +; RUN: opt -mtriple=thumbv8m.main < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S -two-entry-phi-node-folding-threshold=6 | FileCheck %s --check-prefixes=CHECK-TWO-FOLD-6,CHECK-V8M-TWO-FOLD-6 +; RUN: opt -mtriple=armv8a < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S -two-entry-phi-node-folding-threshold=6 | FileCheck %s --check-prefixes=CHECK-TWO-FOLD-6,CHECK-V8A-TWO-FOLD-6 define i32 @test_i32(i1 %a, i1 %b, i32 %i, i32 %j, i32 %k) { ; CHECK-TWO-FOLD-4-LABEL: @test_i32( diff --git a/llvm/test/Transforms/SimplifyCFG/ARM/select-trunc-i64.ll b/llvm/test/Transforms/SimplifyCFG/ARM/select-trunc-i64.ll index 9218ee1..fa0f31d 100644 --- a/llvm/test/Transforms/SimplifyCFG/ARM/select-trunc-i64.ll +++ b/llvm/test/Transforms/SimplifyCFG/ARM/select-trunc-i64.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -;RUN: opt -S -simplifycfg -mtriple=arm < %s | FileCheck %s +;RUN: opt -S -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -mtriple=arm < %s | FileCheck %s target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" define arm_aapcscc i32 @select_trunc_i64(i32 %a, i32 %b) { diff --git a/llvm/test/Transforms/SimplifyCFG/ARM/speculate-math.ll b/llvm/test/Transforms/SimplifyCFG/ARM/speculate-math.ll index 229d453..3790195 100644 --- a/llvm/test/Transforms/SimplifyCFG/ARM/speculate-math.ll +++ b/llvm/test/Transforms/SimplifyCFG/ARM/speculate-math.ll @@ -1,7 +1,7 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt -S -simplifycfg -mtriple=thumbv8.1m.main -mattr=+mve < %s | FileCheck %s --check-prefix=CHECK-MVE -; RUN: opt -S -simplifycfg -mtriple=thumbv8m.main < %s | FileCheck %s --check-prefix=CHECK-V8M-MAIN -; RUN: opt -S -simplifycfg -mtriple=thumbv8m.base < %s | FileCheck %s --check-prefix=CHECK-V8M-BASE +; RUN: opt -S -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -mtriple=thumbv8.1m.main -mattr=+mve < %s | FileCheck %s --check-prefix=CHECK-MVE +; RUN: opt -S -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -mtriple=thumbv8m.main < %s | FileCheck %s --check-prefix=CHECK-V8M-MAIN +; RUN: opt -S -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -mtriple=thumbv8m.base < %s | FileCheck %s --check-prefix=CHECK-V8M-BASE declare float @llvm.sqrt.f32(float) nounwind readonly declare float @llvm.fma.f32(float, float, float) nounwind readonly diff --git a/llvm/test/Transforms/SimplifyCFG/ARM/speculate-vector-ops.ll b/llvm/test/Transforms/SimplifyCFG/ARM/speculate-vector-ops.ll index 1f74644..0ae657f 100644 --- a/llvm/test/Transforms/SimplifyCFG/ARM/speculate-vector-ops.ll +++ b/llvm/test/Transforms/SimplifyCFG/ARM/speculate-vector-ops.ll @@ -1,6 +1,6 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt -simplifycfg -mtriple=thumbv8.1m.main -mattr=+mve -S %s -o - | FileCheck %s --check-prefix=CHECK-MVE -; RUN: opt -simplifycfg -mtriple=thumbv8.1m.main -S %s -o - | FileCheck %s --check-prefix=CHECK-NOMVE +; RUN: opt -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -mtriple=thumbv8.1m.main -mattr=+mve -S %s -o - | FileCheck %s --check-prefix=CHECK-MVE +; RUN: opt -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -mtriple=thumbv8.1m.main -S %s -o - | FileCheck %s --check-prefix=CHECK-NOMVE define i32 @speculate_vector_extract(i32 %d, <4 x i32> %v) { ; CHECK-MVE-LABEL: @speculate_vector_extract( diff --git a/llvm/test/Transforms/SimplifyCFG/ConditionalTrappingConstantExpr.ll b/llvm/test/Transforms/SimplifyCFG/ConditionalTrappingConstantExpr.ll index c5b0b3d..95683db 100644 --- a/llvm/test/Transforms/SimplifyCFG/ConditionalTrappingConstantExpr.ll +++ b/llvm/test/Transforms/SimplifyCFG/ConditionalTrappingConstantExpr.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt < %s -simplifycfg -S | FileCheck %s +; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s @G = extern_weak global i32 diff --git a/llvm/test/Transforms/SimplifyCFG/PR9946.ll b/llvm/test/Transforms/SimplifyCFG/PR9946.ll index c355a8f..538d206 100644 --- a/llvm/test/Transforms/SimplifyCFG/PR9946.ll +++ b/llvm/test/Transforms/SimplifyCFG/PR9946.ll @@ -1,4 +1,4 @@ -; RUN: opt -simplifycfg -disable-output < %s +; RUN: opt -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -disable-output < %s @foo = external constant i32 diff --git a/llvm/test/Transforms/SimplifyCFG/PhiBlockMerge.ll b/llvm/test/Transforms/SimplifyCFG/PhiBlockMerge.ll index 85b9870..b4730c2 100644 --- a/llvm/test/Transforms/SimplifyCFG/PhiBlockMerge.ll +++ b/llvm/test/Transforms/SimplifyCFG/PhiBlockMerge.ll @@ -1,7 +1,7 @@ ; NOTE: Assertions have been autogenerated by update_test_checks.py ; Test merging of blocks that only have PHI nodes in them ; -; RUN: opt < %s -simplifycfg -S | FileCheck %s +; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s ; define i32 @test(i1 %a, i1 %b) { diff --git a/llvm/test/Transforms/SimplifyCFG/PhiEliminate2.ll b/llvm/test/Transforms/SimplifyCFG/PhiEliminate2.ll index 0ca6528..c4af022 100644 --- a/llvm/test/Transforms/SimplifyCFG/PhiEliminate2.ll +++ b/llvm/test/Transforms/SimplifyCFG/PhiEliminate2.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -simplifycfg -S | FileCheck %s +; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s ; Use a select to make this a single BB. ; Also, make sure the profile metadata is propagated to the select (PR26636). diff --git a/llvm/test/Transforms/SimplifyCFG/PhiEliminate3.ll b/llvm/test/Transforms/SimplifyCFG/PhiEliminate3.ll index 9bcac88..cf956e0 100644 --- a/llvm/test/Transforms/SimplifyCFG/PhiEliminate3.ll +++ b/llvm/test/Transforms/SimplifyCFG/PhiEliminate3.ll @@ -1,7 +1,7 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt < %s -simplifycfg -S -phi-node-folding-threshold=1 | FileCheck %s -; RUN: opt < %s -simplifycfg -S -phi-node-folding-threshold=2 | FileCheck %s -; RUN: opt < %s -simplifycfg -S -phi-node-folding-threshold=7 | FileCheck %s +; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S -phi-node-folding-threshold=1 | FileCheck %s +; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S -phi-node-folding-threshold=2 | FileCheck %s +; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S -phi-node-folding-threshold=7 | FileCheck %s ; Test merging of blocks containing complex expressions, ; with various folding thresholds diff --git a/llvm/test/Transforms/SimplifyCFG/RISCV/select-trunc-i64.ll b/llvm/test/Transforms/SimplifyCFG/RISCV/select-trunc-i64.ll index e5272b2..28c083a 100644 --- a/llvm/test/Transforms/SimplifyCFG/RISCV/select-trunc-i64.ll +++ b/llvm/test/Transforms/SimplifyCFG/RISCV/select-trunc-i64.ll @@ -1,4 +1,4 @@ -;RUN: opt -S -simplifycfg -mtriple=riscv32 < %s | FileCheck %s +;RUN: opt -S -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -mtriple=riscv32 < %s | FileCheck %s ; Test case taken from test/Transforms/SimplifyCFG/ARM/select-trunc-i64.ll. ; A correct implementation of isTruncateFree allows this test case to be diff --git a/llvm/test/Transforms/SimplifyCFG/UnreachableEliminate.ll b/llvm/test/Transforms/SimplifyCFG/UnreachableEliminate.ll index c8f59d4..b3b7abe 100644 --- a/llvm/test/Transforms/SimplifyCFG/UnreachableEliminate.ll +++ b/llvm/test/Transforms/SimplifyCFG/UnreachableEliminate.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt < %s -simplifycfg -S | FileCheck %s +; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s define void @test1(i1 %C, i1* %BP) { ; CHECK-LABEL: @test1( diff --git a/llvm/test/Transforms/SimplifyCFG/X86/PR29163.ll b/llvm/test/Transforms/SimplifyCFG/X86/PR29163.ll index 65f9090..cc8fdd1 100644 --- a/llvm/test/Transforms/SimplifyCFG/X86/PR29163.ll +++ b/llvm/test/Transforms/SimplifyCFG/X86/PR29163.ll @@ -1,4 +1,4 @@ -; RUN: opt -S -simplifycfg < %s | FileCheck %s +; RUN: opt -S -simplifycfg -simplifycfg-require-and-preserve-domtree=1 < %s | FileCheck %s target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" diff --git a/llvm/test/Transforms/SimplifyCFG/X86/SpeculativeExec.ll b/llvm/test/Transforms/SimplifyCFG/X86/SpeculativeExec.ll index f07a5a4..78b4f45 100644 --- a/llvm/test/Transforms/SimplifyCFG/X86/SpeculativeExec.ll +++ b/llvm/test/Transforms/SimplifyCFG/X86/SpeculativeExec.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt < %s -simplifycfg -phi-node-folding-threshold=2 -S | FileCheck %s +; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -phi-node-folding-threshold=2 -S | FileCheck %s target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" diff --git a/llvm/test/Transforms/SimplifyCFG/X86/safe-low-bit-extract.ll b/llvm/test/Transforms/SimplifyCFG/X86/safe-low-bit-extract.ll index 19a6313..98b96c3 100644 --- a/llvm/test/Transforms/SimplifyCFG/X86/safe-low-bit-extract.ll +++ b/llvm/test/Transforms/SimplifyCFG/X86/safe-low-bit-extract.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt < %s -simplifycfg -S | FileCheck %s +; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s ; This is the naive implementation of x86 BZHI/BEXTR instruction: ; it takes input and bit count, and extracts low nbits up to bit width. diff --git a/llvm/test/Transforms/SimplifyCFG/X86/speculate-cttz-ctlz.ll b/llvm/test/Transforms/SimplifyCFG/X86/speculate-cttz-ctlz.ll index 3a2f067..e7457f9 100644 --- a/llvm/test/Transforms/SimplifyCFG/X86/speculate-cttz-ctlz.ll +++ b/llvm/test/Transforms/SimplifyCFG/X86/speculate-cttz-ctlz.ll @@ -1,7 +1,7 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt -S -simplifycfg -mtriple=x86_64-unknown-unknown -mattr=+bmi < %s | FileCheck %s --check-prefix=ALL --check-prefix=BMI -; RUN: opt -S -simplifycfg -mtriple=x86_64-unknown-unknown -mattr=+lzcnt < %s | FileCheck %s --check-prefix=ALL --check-prefix=LZCNT -; RUN: opt -S -simplifycfg -mtriple=x86_64-unknown-unknown < %s | FileCheck %s --check-prefix=ALL --check-prefix=GENERIC +; RUN: opt -S -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -mtriple=x86_64-unknown-unknown -mattr=+bmi < %s | FileCheck %s --check-prefix=ALL --check-prefix=BMI +; RUN: opt -S -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -mtriple=x86_64-unknown-unknown -mattr=+lzcnt < %s | FileCheck %s --check-prefix=ALL --check-prefix=LZCNT +; RUN: opt -S -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -mtriple=x86_64-unknown-unknown < %s | FileCheck %s --check-prefix=ALL --check-prefix=GENERIC define i64 @test1(i64 %A) { diff --git a/llvm/test/Transforms/SimplifyCFG/bbi-23595.ll b/llvm/test/Transforms/SimplifyCFG/bbi-23595.ll index 676a80b..b09f04d 100644 --- a/llvm/test/Transforms/SimplifyCFG/bbi-23595.ll +++ b/llvm/test/Transforms/SimplifyCFG/bbi-23595.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -S -simplifycfg | FileCheck %s +; RUN: opt < %s -S -simplifycfg -simplifycfg-require-and-preserve-domtree=1 | FileCheck %s ; In 'simplifycfg', during the flattening of a 'br', the instructions for the ; 'true' and 'false' parts, are moved out from their respective basic blocks. diff --git a/llvm/test/Transforms/SimplifyCFG/clamp.ll b/llvm/test/Transforms/SimplifyCFG/clamp.ll index d21894a..3aa836b 100644 --- a/llvm/test/Transforms/SimplifyCFG/clamp.ll +++ b/llvm/test/Transforms/SimplifyCFG/clamp.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -simplifycfg -S | FileCheck %s +; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s define float @clamp(float %a, float %b, float %c) { ; CHECK-LABEL: @clamp diff --git a/llvm/test/Transforms/SimplifyCFG/hoist-dbgvalue-inlined.ll b/llvm/test/Transforms/SimplifyCFG/hoist-dbgvalue-inlined.ll index e6a5315..c32a4aa 100644 --- a/llvm/test/Transforms/SimplifyCFG/hoist-dbgvalue-inlined.ll +++ b/llvm/test/Transforms/SimplifyCFG/hoist-dbgvalue-inlined.ll @@ -1,4 +1,4 @@ -; RUN: opt -simplifycfg -hoist-common-insts=true -S < %s | FileCheck %s +; RUN: opt -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -hoist-common-insts=true -S < %s | FileCheck %s ; Verify that we don't crash due an invalid !dbg location on the hoisted llvm.dbg.value define i64 @caller(i64* %ptr, i64 %flag) !dbg !10 { diff --git a/llvm/test/Transforms/SimplifyCFG/no-md-sink.ll b/llvm/test/Transforms/SimplifyCFG/no-md-sink.ll index 62d8711..8c8e3fd 100644 --- a/llvm/test/Transforms/SimplifyCFG/no-md-sink.ll +++ b/llvm/test/Transforms/SimplifyCFG/no-md-sink.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -simplifycfg -sink-common-insts -S | FileCheck %s +; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -sink-common-insts -S | FileCheck %s ; RUN: opt < %s -passes='simplify-cfg' -S | FileCheck %s define i1 @test1(i1 zeroext %flag, i8* %y) #0 { diff --git a/llvm/test/Transforms/SimplifyCFG/opt-for-fuzzing.ll b/llvm/test/Transforms/SimplifyCFG/opt-for-fuzzing.ll index 4a0d9e8..f1a5820 100644 --- a/llvm/test/Transforms/SimplifyCFG/opt-for-fuzzing.ll +++ b/llvm/test/Transforms/SimplifyCFG/opt-for-fuzzing.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -simplifycfg -S | FileCheck %s +; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s ; RUN: opt < %s -passes=simplifycfg -S | FileCheck %s define i32 @foo(i32 %x) optforfuzzing { diff --git a/llvm/test/Transforms/SimplifyCFG/safe-abs.ll b/llvm/test/Transforms/SimplifyCFG/safe-abs.ll index 6d8028f..466bdca 100644 --- a/llvm/test/Transforms/SimplifyCFG/safe-abs.ll +++ b/llvm/test/Transforms/SimplifyCFG/safe-abs.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt < %s -simplifycfg -S | FileCheck %s +; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s ; Reduced from arm_abs_q31() from CMSIS DSP suite. ; https://reviews.llvm.org/D65148#1629010 diff --git a/llvm/test/Transforms/SimplifyCFG/signbit-like-value-extension.ll b/llvm/test/Transforms/SimplifyCFG/signbit-like-value-extension.ll index e955e06..f4b4b90 100644 --- a/llvm/test/Transforms/SimplifyCFG/signbit-like-value-extension.ll +++ b/llvm/test/Transforms/SimplifyCFG/signbit-like-value-extension.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt < %s -simplifycfg -S | FileCheck %s +; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s ; This looks like a normal sign extension, but it's not. ; This comes up in JPEG decoding. This check is really unpredictable, diff --git a/llvm/test/Transforms/SimplifyCFG/speculate-math.ll b/llvm/test/Transforms/SimplifyCFG/speculate-math.ll index ca1e7d5cea..e7edd40 100644 --- a/llvm/test/Transforms/SimplifyCFG/speculate-math.ll +++ b/llvm/test/Transforms/SimplifyCFG/speculate-math.ll @@ -1,6 +1,6 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt -S -simplifycfg < %s | FileCheck %s -; RUN: opt -S -simplifycfg -speculate-one-expensive-inst=false < %s | FileCheck %s +; RUN: opt -S -simplifycfg -simplifycfg-require-and-preserve-domtree=1 < %s | FileCheck %s +; RUN: opt -S -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -speculate-one-expensive-inst=false < %s | FileCheck %s declare float @llvm.sqrt.f32(float) nounwind readonly declare float @llvm.fma.f32(float, float, float) nounwind readonly diff --git a/llvm/test/Transforms/SimplifyCFG/speculate-vector-ops.ll b/llvm/test/Transforms/SimplifyCFG/speculate-vector-ops.ll index 91972eb..0cda474 100644 --- a/llvm/test/Transforms/SimplifyCFG/speculate-vector-ops.ll +++ b/llvm/test/Transforms/SimplifyCFG/speculate-vector-ops.ll @@ -1,4 +1,4 @@ -; RUN: opt -S -simplifycfg < %s | FileCheck %s +; RUN: opt -S -simplifycfg -simplifycfg-require-and-preserve-domtree=1 < %s | FileCheck %s define i32 @speculate_vector_extract(i32 %d, <4 x i32> %v) #0 { ; CHECK-LABEL: @speculate_vector_extract( diff --git a/llvm/test/Transforms/SimplifyCFG/speculate-with-offset.ll b/llvm/test/Transforms/SimplifyCFG/speculate-with-offset.ll index 65ebb5c..285b1ff 100644 --- a/llvm/test/Transforms/SimplifyCFG/speculate-with-offset.ll +++ b/llvm/test/Transforms/SimplifyCFG/speculate-with-offset.ll @@ -1,4 +1,4 @@ -; RUN: opt -simplifycfg -S < %s | FileCheck %s +; RUN: opt -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S < %s | FileCheck %s ; This load is safe to speculate, as it's from a safe offset ; within an alloca. diff --git a/llvm/test/Transforms/SimplifyCFG/unsigned-multiplication-will-overflow.ll b/llvm/test/Transforms/SimplifyCFG/unsigned-multiplication-will-overflow.ll index 1e87d86..8f99279 100644 --- a/llvm/test/Transforms/SimplifyCFG/unsigned-multiplication-will-overflow.ll +++ b/llvm/test/Transforms/SimplifyCFG/unsigned-multiplication-will-overflow.ll @@ -1,7 +1,7 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt < %s -simplifycfg -S | FileCheck %s -; RUN: opt < %s -simplifycfg -phi-node-folding-threshold=2 -S | FileCheck %s -; RUN: opt < %s -simplifycfg -phi-node-folding-threshold=3 -S | FileCheck %s +; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s +; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -phi-node-folding-threshold=2 -S | FileCheck %s +; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -phi-node-folding-threshold=3 -S | FileCheck %s ; This is checking that the multiplication does overflow, with a leftover ; guard against division-by-zero that was needed before InstCombine -- 2.7.4