[llvm] [InstCombine] Simplify select using KnownBits of condition (PR #95923)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 27 09:17:59 PDT 2024


nikic wrote:

> Top 5 regressions: eastl/TestBitset.cpp.ll 7448097780 8128445212 +9.13%

I looked at the first one of these. This is a case where the computeKnownBits() calls dominate. There are a lot of selects with expensive operands.

This additional patch improves the situation for this kind of pathological case: https://github.com/llvm/llvm-project/compare/254fd43272429eac4cdd98924fab8cf5be9019c2...00597f09633e929d7ecf9affcea1c48944f48cbb This is what @goldsteinn suggested about first checking whether there are any affected values in the select arms.

It doesn't fully avoid the regression on that test case, as many selects do have potentially affected values, but at least cuts it in half.

Do you want me to include that?

(My initial attempt was a huge regression instead: http://llvm-compile-time-tracker.com/compare.php?from=254fd43272429eac4cdd98924fab8cf5be9019c2&to=54d67e7df109e020398f7027c8df0a715c20a6cc&stat=instructions:u Turns out that having a reduced depth for phi nodes is very, very important!)

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


More information about the llvm-commits mailing list