[llvm] [SimplifyCFG] Fix hoisting problem in SimplifyCFG (PR #78615)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 23 13:20:41 PST 2024
================
@@ -1742,15 +1767,6 @@ bool SimplifyCFGOpt::hoistCommonCodeFromSuccessors(BasicBlock *BB,
continue;
}
- SmallVector<Instruction *, 8> OtherInsts;
- if (SameLevelHoist) {
----------------
RouzbehPaktinat wrote:
I'm still doing same level hoisting but those instructions are in the hash map as well. If I want to avoid putting same level instructions in the hash map, the logic for filling the map will become more complicated and needs iterating BBs more than once which brings overhead. Take this case for example:
```
BB1 BB2
I0 I2
I1 I1
I2 I3
```
Let's say instructions with same numbers are identical.
While checking `I0` from `BB1`, if I want to check the same level instruction of `BB2` (which is `I2` here), after finding that `I0` and `I2` are not identical I need to put `I2` in the map (hoping that I will find an identical instruction from BB1 later) but that would also increase map size if no identical instruction is found. The other option is not putting `I2` in the map at this point, but wait until we are done iterating BB1, then re-iterate BB2. In this way when we reach `I2` in BB2, we have already added its identical instruction from BB1 so it can be added to the map. But this is not desirable as we want to iterate each BB only once.
https://github.com/llvm/llvm-project/pull/78615
More information about the llvm-commits
mailing list