[llvm] [ValueTracking] Improve `Bitcast` handling to match SDAG (PR #125935)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 13 23:46:32 PDT 2025
================
@@ -1376,10 +1377,32 @@ static void computeKnownBitsFromOperator(const Operator *I,
for (unsigned i = 0; i != SubScale; ++i) {
computeKnownBits(I->getOperand(0), SubDemandedElts.shl(i), KnownSrc, Q,
Depth + 1);
- unsigned ShiftElt = Q.DL.isLittleEndian() ? i : SubScale - 1 - i;
+ unsigned ShiftElt = IsLE ? i : SubScale - 1 - i;
Known.insertBits(KnownSrc, ShiftElt * SubBitWidth);
}
}
+ // Look through a cast from wider vector elements to narrow type.
+ // Examples: v2i64 -> v4i32
+ if (SubBitWidth % BitWidth == 0) {
----------------
dtcxzyw wrote:
I guess the missing case `v2i32 -> i64` can be handled here (as a follow-up): https://github.com/llvm/llvm-project/blob/07fa6d1d90c714fa269529c3e5004a063d814c4a/llvm/lib/Analysis/ValueTracking.cpp#L1295-L1301
https://github.com/llvm/llvm-project/pull/125935
More information about the llvm-commits
mailing list