[Mlir-commits] [mlir] [mlir][spirv] Add folding for IAddCarry/[S|U]MulExtended (PR #73340)
Jakub Kuderski
llvmlistbot at llvm.org
Fri Nov 24 13:41:25 PST 2023
================
@@ -115,6 +115,196 @@ void spirv::AccessChainOp::getCanonicalizationPatterns(
results.add<CombineChainedAccessChain>(context);
}
+//===----------------------------------------------------------------------===//
+// spirv.IAddCarry
+//===----------------------------------------------------------------------===//
+
+// We are required to use CompositeConstructOp to create a constant struct as
+// they are not yet implemented as constant, hence we can not do so in a fold.
+struct IAddCarryFold final : OpRewritePattern<spirv::IAddCarryOp> {
+ using OpRewritePattern::OpRewritePattern;
+
+ LogicalResult matchAndRewrite(spirv::IAddCarryOp op,
+ PatternRewriter &rewriter) const override {
+ Location loc = op.getLoc();
+ auto operands = op.getOperands();
----------------
kuhar wrote:
We can do:
```c++
Value lhs = op.getOperand1();
Value rhs = op.getOperand2();
```
If this is not a very intuitive naming, I can add extra getters `op.getLhs()` and `op.getRhs()` -- WDYT?
https://github.com/llvm/llvm-project/pull/73340
More information about the Mlir-commits
mailing list