[PATCH] D154306: [InstCombine] Generalise ((x1 ^ y1) | (x2 ^ y2)) == 0 transform

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 14 00:26:52 PDT 2023


nikic added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:2061
+      CmpValues.clear();
+      break;
+    }
----------------
As this is now a pretty complex fold, I'd suggest moving it into a separate function. That would allow you to use early `return nullptr` here.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:2080
+                                       CmpValues.begin()->second);
+    return BinaryOperator::Create(BOpc, LhsCmp, RhsCmp);
   }
----------------
kitaisreal wrote:
> nikic wrote:
> > Why does this one need to be handled separately?
> To properly support lifetime of allocated operators we must allocate them using `Builder`, and `Builder` methods return `Value *`.
> But this function expects to return `BinaryOperator *` instead of `Value *`, so last one handled separately.
You can do something like `return replaceInstUsesWith(Or, LhsCmp)` to convert the Value into Instruction for the return value.


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

https://reviews.llvm.org/D154306



More information about the llvm-commits mailing list