[llvm] [VectorCombine] fold nested bitreverse and bswap (PR #202236)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 12 03:25:23 PDT 2026
================
@@ -5946,6 +5908,74 @@ 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)))
+bool VectorCombine::foldBitOrderReverseAndSwap(Instruction &I) {
+ auto *II = dyn_cast<IntrinsicInst>(&I);
+ if (!II)
+ return false;
+
+ Intrinsic::ID IntrID = II->getIntrinsicID();
+ if (IntrID != Intrinsic::bitreverse && IntrID != Intrinsic::bswap)
+ return false;
----------------
RKSimon wrote:
isn't this superfluous now yo check with pattern match below?
https://github.com/llvm/llvm-project/pull/202236
More information about the llvm-commits
mailing list