[llvm] [VectorCombine] Fold bitcast(bitreverse.v8i8(bitcast(IntTy))) into bswap+bitreverse (PR #209037)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 13 04:23:50 PDT 2026
================
@@ -6112,12 +6112,56 @@ bool VectorCombine::foldBitcastOfVPLoad(Instruction &I) {
return true;
}
-/// Fold the following cases into a single byte-level bit-reverse operation
-/// and accepts bswap and bitreverse intrinsics:
-/// bswap(bitreverse(x)) --> bitcast(bitreverse(bitcast(x)))
-/// bitreverse(bswap(x)) --> bitcast(bitreverse(bitcast(x)))
+// Fold bitcast(bitreverse(<N x i8>)(bitcast(IntTy X))) --> bitreverse(bswap(X))
+// and the forward direction:
+// bswap(bitreverse(x)) --> bitcast(bitreverse(bitcast(x)))
+// bitreverse(bswap(x)) --> bitcast(bitreverse(bitcast(x)))
+// The direction chosen depends on which is cheaper for the target.
----------------
RKSimon wrote:
please rewrite this to better build on the existing comment - I was kind of expecting you to just replace `-->` with `<-->` and add something about costs
https://github.com/llvm/llvm-project/pull/209037
More information about the llvm-commits
mailing list