[llvm] [LSV] Enhance LoadStoreVectorizer to Handle Disjoint Flag in OR Instructions and Restore Vectorization Opportunities (PR #96495)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 27 06:40:15 PDT 2024


================
@@ -5290,6 +5290,15 @@ static std::optional<BinaryOp> MatchBinaryOp(Value *V, const DataLayout &DL,
     return BinaryOp(Op);
 
   case Instruction::Or: {
+    //Determine whether the instruction or is disjoint
+    if (auto *OrInst = dyn_cast<PossiblyDisjointInst>(Op)) {
+      Value *Op0 = OrInst->getOperand(0);
+      Value *Op1 = OrInst->getOperand(1);
+
+      if (haveNoCommonBitsSet(Op0, Op1, DL)) {
+        OrInst->setIsDisjoint(true);
----------------
nikic wrote:

You cannot modify instructions inside SCEV. What you would do is add an `|| haveNoCommonBits` check in the if below.

https://github.com/llvm/llvm-project/pull/96495


More information about the llvm-commits mailing list