[PATCH] D126268: [InstCombine] [NFC] refector foldXorOfICmps

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 24 02:04:33 PDT 2022


nikic added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:3000
+    if (LHS0 == RHS1 && LHS1 == RHS0)
+      std::swap(LHS0, LHS1);
+    if (LHS0 == RHS0 && LHS1 == RHS1) {
----------------
Chenbing.Zheng wrote:
> Chenbing.Zheng wrote:
> > RKSimon wrote:
> > > If the if() below fails - doesn't this leave the LHS0/LHS1 operands in a commuted state further down?
> > (LHS0 == RHS1 && LHS1 == RHS0) is true, means (LHS0 == RHS0 && LHS1 == RHS1) must be true.
> > In other words, if do swap, we must go to the next conditional branch.
> > 
> > I think this is consistent with the original logic.
> Correct
> (LHS0 == RHS1 && LHS1 == RHS0) is true and after swap(LHS0, LHS1), means (LHS0 == RHS0 && LHS1 == RHS1) must be true.
Aren't you missing a `PredL = ICmpInst::getSwappedPredicate(PredL)` here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126268



More information about the llvm-commits mailing list