[PATCH] D149419: [ValueTracking] Slight refactor to avoid unnecessary work; NFC

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 28 14:36:46 PDT 2023


goldstein.w.n added a comment.

In D149419#4304516 <https://reviews.llvm.org/D149419#4304516>, @nikic wrote:

>> In cases of Op0 != 0 || Op1 != 0 its better check Op1 first as its more likely to be a constant due to canonicalization (so faster to get knownbits of).
>
> I'm not sure this is right: If Op1 is constant, then isKnownNonZero will in practice always return true, because the zero cases get folded away. So we do the call on Op0 anyway.

Hmm? In something like the `Or` case if we have `or A, 12`, `isKnownNonZero(Op1) || isKnownOpZero(Op0)` will return true after just finding the constant `12`. If you flip the order
it first need to recursve through the `A` case which can be be alot more expensive.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149419



More information about the llvm-commits mailing list