[llvm] [VectorCombine] Generalize foldBitOpOfBitcasts to support more cast operations (PR #148350)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 20 04:14: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)) {
----------------
RKSimon wrote:
@dtcxzyw We're already using the Builder::Create* + flags merge approach in a lot of other places in VectorCombine - do you recommend changing those as well? (In a separate patch to this one of course).
https://github.com/llvm/llvm-project/pull/148350
More information about the llvm-commits
mailing list