[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


================
@@ -660,6 +660,161 @@ func.func @convert_logical_or_true_false_vector(%arg: vector<3xi1>) -> (vector<3
 
 // -----
 
+//===----------------------------------------------------------------------===//
+// spirv.BitwiseAnd
+//===----------------------------------------------------------------------===//
+
+// CHECK-LABEL: @bitwise_and_x_0
+// CHECK-SAME: (%[[ARG:.*]]: i32)
+func.func @bitwise_and_x_0(%arg0 : i32) -> i32 {
+  // CHECK: %[[C0:.*]] = spirv.Constant 0 : i32
+  %c1 = spirv.Constant 0 : i32
+  %0 = spirv.BitwiseAnd %arg0, %c1 : i32
----------------
kuhar wrote:

Could you add at least one test for each op that shows we can fold things when the constant operand is a vector of splat values? E.g., `%v0 = spirv.Constant dense<0> : vector<4xi32>`.

Based on the code it's not immediately obvious if this case is handled by the top-level `matchPattern` or not. Same for the other ops.

https://github.com/llvm/llvm-project/pull/74193


More information about the Mlir-commits mailing list