[llvm-branch-commits] [llvm] 6a3a8d1 - [SimplifyCFG] FoldValueComparisonIntoPredecessors(): fine-tune/fix DomTree preservation

Roman Lebedev via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sat Jan 2 14:50:35 PST 2021


Author: Roman Lebedev
Date: 2021-01-03T01:45:48+03:00
New Revision: 6a3a8d17ebae0669e797ac22a2b2963b89ee12fa

URL: https://github.com/llvm/llvm-project/commit/6a3a8d17ebae0669e797ac22a2b2963b89ee12fa
DIFF: https://github.com/llvm/llvm-project/commit/6a3a8d17ebae0669e797ac22a2b2963b89ee12fa.diff

LOG: [SimplifyCFG] FoldValueComparisonIntoPredecessors(): fine-tune/fix DomTree preservation

Added: 
    

Modified: 
    llvm/lib/Transforms/Utils/SimplifyCFG.cpp
    llvm/test/Transforms/SimplifyCFG/FoldValueComparisonIntoPredecessors-domtree-preservation-edgecase.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 825de4214c64..738e524fbfd9 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1113,8 +1113,6 @@ bool SimplifyCFGOpt::FoldValueComparisonIntoPredecessors(Instruction *TI,
 
       std::vector<DominatorTree::UpdateType> Updates;
 
-      Updates.push_back({DominatorTree::Delete, Pred, BB});
-
       // Figure out which 'cases' to copy from SI to PSI.
       std::vector<ValueEqualityComparisonCase> BBCases;
       BasicBlock *BBDefault = GetValueEqualityComparisonCases(TI, BBCases);
@@ -1303,10 +1301,10 @@ bool SimplifyCFGOpt::FoldValueComparisonIntoPredecessors(Instruction *TI,
           NewSI->setSuccessor(i, InfLoopBlock);
         }
 
-      if (InfLoopBlock) {
-        Updates.push_back({DominatorTree::Delete, Pred, BB});
+      if (InfLoopBlock)
         Updates.push_back({DominatorTree::Insert, Pred, InfLoopBlock});
-      }
+
+      Updates.push_back({DominatorTree::Delete, Pred, BB});
 
       if (DTU)
         DTU->applyUpdatesPermissive(Updates);

diff  --git a/llvm/test/Transforms/SimplifyCFG/FoldValueComparisonIntoPredecessors-domtree-preservation-edgecase.ll b/llvm/test/Transforms/SimplifyCFG/FoldValueComparisonIntoPredecessors-domtree-preservation-edgecase.ll
index 0d7718b865b2..10c02515e9d1 100644
--- a/llvm/test/Transforms/SimplifyCFG/FoldValueComparisonIntoPredecessors-domtree-preservation-edgecase.ll
+++ b/llvm/test/Transforms/SimplifyCFG/FoldValueComparisonIntoPredecessors-domtree-preservation-edgecase.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt -S -simplifycfg -simplifycfg-require-and-preserve-domtree=0 < %s | FileCheck %s
+; RUN: opt -S -simplifycfg -simplifycfg-require-and-preserve-domtree=1 < %s | FileCheck %s
 
 define dso_local i32 @readCBPandCoeffsFromNAL(i1 %c, i32 %x, i32 %y) local_unnamed_addr {
 ; CHECK-LABEL: @readCBPandCoeffsFromNAL(


        


More information about the llvm-branch-commits mailing list