[llvm] [InstCombine] Combine or-disjoint (and->mul), (and->mul) to and->mul (PR #136013)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 11 01:08:06 PDT 2025
================
@@ -3593,6 +3593,73 @@ static Value *foldOrOfInversions(BinaryOperator &I,
return nullptr;
}
+// A decomposition of ((X & Mask) ? 0 : Mask * Factor) . The NUW / NSW bools
+// track these properities for preservation. Note that we can decompose
+// equivalent forms of this expression (e.g. ((X & Mask) * Factor))
+struct DecomposedBitMaskMul {
+ Value *X;
+ APInt Factor;
+ APInt Mask;
+ bool NUW;
+ bool NSW;
+};
+
+static std::optional<DecomposedBitMaskMul> matchBitmaskMul(Value *V) {
+ Instruction *Op = dyn_cast<Instruction>(V);
+ if (!Op)
+ return std::nullopt;
+
+ const APInt *MulConst = nullptr;
----------------
nikic wrote:
nit: Move this closer to `const APInt *Mask`.
https://github.com/llvm/llvm-project/pull/136013
More information about the llvm-commits
mailing list