[PATCH] D44626: [InstCombine] Fold (A OR B) AND B code sequence over Phi node

Hiroshi Inoue via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 28 09:37:54 PDT 2018


inouehrs marked an inline comment as done.
inouehrs added a comment.

In https://reviews.llvm.org/D44626#1081987, @spatel wrote:

> I think what this patch really wants to ask/do is: "Does this binop simplify with the incoming value of the phi to 1 of the binop operands? If yes, substitute that value into the phi."


Note that this patch intend to optimize only a simple but important case on `std::pair` to help jump threading. Other optimizers are already able to do more generic optimization for this type of code sequence, but it's too late to help jump threading.



================
Comment at: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:1423
+  if (llvm::none_of(Phi->incoming_values(), IsEligible))
+    return nullptr;
+
----------------
efriedma wrote:
> This logic doesn't work if AndVal isn't a constant (e.g. consider the case where the "and" and "or" are in the same basic block).
Thank you for pointing this out. I added check for `AndVal` (prevoiously I checked this only in `if (!Phi->hasOneUse())` block).


https://reviews.llvm.org/D44626





More information about the llvm-commits mailing list