[llvm] [VectorCombine] Fold bitcast(bitreverse(bitcast(x))) to fshl+bitreverse (PR #214362)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 10 02:16:26 PDT 2026


================
@@ -6146,9 +6159,12 @@ bool VectorCombine::foldBitOrderReverseAndSwap(Instruction &I) {
                                 TTI.getInstructionCost(InnerCall, CostKind) +
                                 TTI.getInstructionCost(&I, CostKind);
       IntrinsicCostAttributes ICABSwap(Intrinsic::bswap, Ty, {Ty});
+      IntrinsicCostAttributes ICABFshl(Intrinsic::fshl, Ty, {Ty, Ty, Ty});
----------------
RKSimon wrote:

You might get more accurate costs if you can hint its a rotate:
```suggestion
      IntrinsicCostAttributes ICABFshl(Intrinsic::fshl, Ty, {X,X,nullptr}, {Ty, Ty, Ty});
```
The problem is I don't know how well other targets getIntrinsicInstrCost calls handle null args (x86 should be OK, but not sure generally).

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


More information about the llvm-commits mailing list