[llvm] [VectorCombine] Generalize foldBitOpOfBitcasts to support more cast operations (PR #148350)
Rahul Yadav via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 20 05:09:40 PDT 2025
================
@@ -862,8 +901,15 @@ bool VectorCombine::foldBitOpOfBitcasts(Instruction &I) {
Worklist.pushValue(NewOp);
- // Bitcast the result back
- Value *Result = Builder.CreateBitCast(NewOp, I.getType());
+ // Create the cast operation
+ Value *Result = Builder.CreateCast(CastOpcode, NewOp, I.getType());
+
+ // Preserve cast instruction flags
+ if (auto *NewCast = dyn_cast<CastInst>(Result)) {
----------------
rhyadav wrote:
@dtcxzyw thanks for catching this, i've made the changes, all tests pass, @RKSimon pls have a look, happy to take on the rest of the changes in VectorCombine in a separate issue/patch.
https://github.com/llvm/llvm-project/pull/148350
More information about the llvm-commits
mailing list