[PATCH] D151421: [KnownBits] Simplify shl. NFCI.

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 25 05:06:08 PDT 2023

nikic added a comment.

In D151421#4371619 <https://reviews.llvm.org/D151421#4371619>, @foad wrote:

> @nikic this was a result of me trying to understand your implementation. I tried to:
> - remove special cases (but perhaps some of these were deliberate early-outs to speed up to the common cases?)

Yes, these are intentional fast paths. In fact, the ones we currently have are insufficient, and we'll need another one for the case where the shift amount is unknown, because the current implementation is too slow. (This path is mostly not exposed right now due to special code in ValueTracking, but it if does get exposed it causes substantial compile-time regressions.)

It's possible that dropping the special handling for constants would be fine, but we need to at least keep the code for handling unknown LHS.

> - work in `unsigned` instead of APInt as much as possible
> - take advantage of APInt::*shl_ov

These changes look good to me and should make the implementation faster.

  rG LLVM Github Monorepo



More information about the llvm-commits mailing list