[llvm] [InstCombine] foldVecExtTruncToExtElt - extend to handle trunc(lshr(extractelement(x,c1),c2)) -> extractelement(bitcast(x),c3) patterns. (PR #109689)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 28 00:21:26 PDT 2024


================
@@ -469,10 +473,23 @@ static Instruction *foldVecExtTruncToExtElt(TruncInst &Trunc,
   uint64_t BitCastNumElts = VecElts.getKnownMinValue() * TruncRatio;
   uint64_t VecOpIdx = Cst->getZExtValue();
   uint64_t NewIdx = IC.getDataLayout().isBigEndian()
-                        ? (VecOpIdx + 1) * TruncRatio - 1
+                        ? (VecOpIdx * TruncRatio) + (TruncRatio - 1)
----------------
dtcxzyw wrote:

Isn't it equivalent to the original code?


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


More information about the llvm-commits mailing list