[JumpThreading] Simplify FindMostPopularDest (NFC)
Summary: This patch simplifies FindMostPopularDest without changing the functionality. Given a list of jump threading destinations, the function finds the most popular destination. To ensure determinism when there are multiple destinations with the highest popularity, the function picks the first one in the successor list with the highest popularity. Without this patch: - The function populates DestPopularity -- a histogram mapping destinations to their respective occurrence counts. - Then we iterate over DestPopularity, looking for the highest popularity while building a vector of destinations with the highest popularity. - Finally, we iterate the successor list, looking for the destination with the highest popularity. With this patch: - We implement DestPopularity with MapVector instead of DenseMap. We populate the map with popularity 0 for all successors in the order they appear in the successor list. - We build the histogram in the same way as before. - We simply use std::max_element on DestPopularity to find the most popular destination. The use of MapVector ensures determinism. Reviewers: wmi, efriedma Reviewed By: wmi Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D81030
Loading
Please sign in to comment