[llvm] [SimplifyCFG] Fix hoisting problem in SimplifyCFG (PR #78615)

Quentin Dian via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 23 22:29:13 PST 2024


================
@@ -1742,15 +1767,6 @@ bool SimplifyCFGOpt::hoistCommonCodeFromSuccessors(BasicBlock *BB,
       continue;
     }
 
-    SmallVector<Instruction *, 8> OtherInsts;
-    if (SameLevelHoist) { 
----------------
DianQK wrote:

I think there is a solution here that splits the hoist common code into three steps (function or class?).

1. The current simple matching method.
2. Use hash map for matching.
3. Hoist the termination instruction.

Also, I think with the hash map, we can simplify the first step of the logic by removing the skip part and going straight to the second step once we encounter a difference.

Could you create a PR first to prepare for this change? Perhaps, we just need to split the current code into two (1 and 3) steps in order to insert the hash map code. :)

https://github.com/llvm/llvm-project/pull/78615


More information about the llvm-commits mailing list