[llvm] [VectorCombine] Add intrinsics handling to shuffleToIdentity (PR #91000)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Wed May 8 14:23:16 PDT 2024


================
@@ -1770,6 +1772,20 @@ bool VectorCombine::foldShuffleToIdentity(Instruction &I) {
       Worklist.push_back(GenerateInstLaneVectorFromOperand(Item, 1));
     } else if (isa<UnaryOperator>(Item[0].first)) {
       Worklist.push_back(GenerateInstLaneVectorFromOperand(Item, 0));
+    } else if (auto *II = dyn_cast<IntrinsicInst>(Item[0].first);
+               II && isTriviallyVectorizable(II->getIntrinsicID())) {
+      for (unsigned O = 0; O < II->getNumOperands() - 1; O++) {
----------------
RKSimon wrote:

`for (unsigned O = 0, E = II->getNumOperands() - 1; O < E; O++) {`
Also, why O? I've always avoided it due to O/0/o confusion, but that's me :) 

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


More information about the llvm-commits mailing list