[Mlir-commits] [mlir] [mlir][spirv] Add folding for Bitwise[Or|And|Xor] (PR #74193)
Jakub Kuderski
llvmlistbot at llvm.org
Wed Dec 6 14:50:32 PST 2023
================
@@ -356,6 +356,92 @@ OpFoldResult spirv::LogicalOrOp::fold(FoldAdaptor adaptor) {
return Attribute();
}
+//===----------------------------------------------------------------------===//
+// spirv.BitwiseAndOp
+//===----------------------------------------------------------------------===//
+
+OpFoldResult
+spirv::BitwiseAndOp::fold(spirv::BitwiseAndOp::FoldAdaptor adaptor) {
+ APInt rhsMask;
+ if (matchPattern(adaptor.getOperand2(), m_ConstantInt(&rhsMask))) {
----------------
kuhar wrote:
Should we also fold `x & x => x`? Regardless of `x` being a constant or not, just compare `getOperand1() == getOperand2()`.
https://github.com/llvm/llvm-project/pull/74193
More information about the Mlir-commits
mailing list