[PATCH] D146810: [CodeGen] Compile-time improvement for Machine Late Instructions Cleanup Pass.

Jonas Paulsson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 4 06:24:47 PDT 2023


jonpa added a comment.

In D146810#4236313 <https://reviews.llvm.org/D146810#4236313>, @vpykhtin wrote:

>> If the map lookup time really matters, maybe it could be worth trying a vector of DefMI/KillMI pairs, so lookup time would be O(n) into the vector..?
>
> I don't think it's that critical
>
>> BTW, I really hope we don't have to use first/second accesses, something like RegInstrs[Reg].DefMI seems more readable...
>
> RegInstrs[Reg] is a lookup in the map, I don't know if compilers are good enough to optimize several identical map lookups.
>
>> If it's not possible to speed it up further, I think the simple version I tried is acceptable: it avoids the slowdowns in huge functions and is just barely slower on SPEC, which is then probably preferrable...
>
> I agree, I'll abandon this review then. Maybe it worth to use SmallDenseMap in your version instead of std::map.

I tried this patch again a final time, this time passing the RegInfo pointer to removeRedundantDef() and further into clearKillsForDef(). My idea here is that this would only mean a single lookup for both the def and the kill. This was however also not any faster at all.

I also tried having a vector of RegInfo:s for each MBB - instead of a map. The idea was to make the lookup time linear, but this was much slower in small functions (while perhaps good idea in huge ones).

I have tried different map types before, so I don't think there is anything to gain from that.

I will post my patch as a separate review...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146810/new/

https://reviews.llvm.org/D146810



More information about the llvm-commits mailing list