[PATCH] D125551: [ValueTracking] Handle and/or on RHS of isImpliedCondition()

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 16 07:19:23 PDT 2022


nikic added inline comments.


================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:6675-6679
+    if (!isImpliedCondition(LHS, RHS1, DL, LHSIsTrue, Depth + 1)
+            .getValueOr(true) ||
+        !isImpliedCondition(LHS, RHS2, DL, LHSIsTrue, Depth + 1)
+            .getValueOr(true))
+      return false;
----------------
spatel wrote:
> I had to step through this to convince myself that the logic was correct.
> 
> That is probably the shortest way to write it, but something like this might be easier to read?
>     if (auto ImpR1 = isImpliedCondition(LHS, RHS1, DL, LHSIsTrue, Depth + 1))
>       if (*ImpR1 == false)
>         return false;
>     if (auto ImpR2 = isImpliedCondition(LHS, RHS2, DL, LHSIsTrue, Depth + 1))
>       if (*ImpR2 == false)
>         return false;
> 
Yeah, I agree that the `and` case is a bit hard to understand as written.


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

https://reviews.llvm.org/D125551



More information about the llvm-commits mailing list