[llvm] [VectorCombine] Support pattern `bitop(cast(x), C) -> cast(bitop(x, InvC))` (PR #155216)
Rajveer Singh Bharadwaj via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 25 03:30:37 PDT 2025
================
@@ -929,6 +930,158 @@ bool VectorCombine::foldBitOpOfCastops(Instruction &I) {
return true;
}
+struct PreservedCastFlags {
+ bool NNeg = false;
+ bool NUW = false;
+ bool NSW = false;
+};
+
+// Try to cast C to InvC losslessly, satisfying CastOp(InvC) == C.
+// Will try best to preserve the flags.
+static Constant *getLosslessInvCast(Constant *C, Type *InvCastTo,
----------------
Rajveer100 wrote:
Maybe we could put this in `InstCombineInternal.h` where we have more methods like `getLosslessUnsignedTrunc`, `getLosslessSignedTrunc`, etc. ?
https://github.com/llvm/llvm-project/pull/155216
More information about the llvm-commits
mailing list