[llvm] [VectorCombine] Handle widening/narrowing bitcasts in foldShuffleToIdentity (PR #187870)

via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 27 10:50:46 PDT 2026


================
@@ -3544,6 +3544,50 @@ generateNewInstTree(ArrayRef<InstLane> Item, Use *From, FixedVectorType *Ty,
   }
 
   auto *I = cast<Instruction>(FrontV);
+
+  // Handle vector bitcasts that change element count. We cannot use
+  // generateInstLaneVectorFromOperand for these because the lane indices
+  // don't map 1:1 through the bitcast.
+  if (auto *BitCast = dyn_cast<BitCastInst>(I)) {
+    auto *BCDstTy = dyn_cast<FixedVectorType>(BitCast->getDestTy());
+    auto *BCSrcTy = dyn_cast<FixedVectorType>(BitCast->getSrcTy());
----------------
AbdallahRashed wrote:

I am not sure but the function already requires  FixedVectorType at entry, and my understanding is bitcasts can't cross fixed/scalable boundaries, so the src/dst types here are always FixedVectorType, happy to switch if you'd prefer it for consistency though.

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


More information about the llvm-commits mailing list