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

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 28 14:50:03 PDT 2023


nikic added a comment.

In D149419#4306616 <https://reviews.llvm.org/D149419#4306616>, @goldstein.w.n wrote:

> 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.

Oh yeah, you're right. Ignore what I said there. I was thinking of the `&&` case, not the `||` case.


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