[Mlir-commits] [mlir] [mlir][SPIR-V] Add SPIRVToLLVM conversion for SNegate (PR #206950)

Igor Wodiany llvmlistbot at llvm.org
Fri Jul 10 03:05:59 PDT 2026


================
@@ -921,6 +921,35 @@ class InverseSqrtPattern
   }
 };
 
+/// Converts `spirv.SNegate` to `0 - x`.
+class SNegatePattern : public SPIRVToLLVMConversion<spirv::SNegateOp> {
+public:
+  using SPIRVToLLVMConversion<spirv::SNegateOp>::SPIRVToLLVMConversion;
+
+  LogicalResult
+  matchAndRewrite(spirv::SNegateOp op, OpAdaptor adaptor,
+                  ConversionPatternRewriter &rewriter) const override {
+    auto srcType = op.getType();
+    auto dstType = getTypeConverter()->convertType(srcType);
----------------
IgWod wrote:

```suggestion
    Type srcType = op.getType();
    Type dstType = getTypeConverter()->convertType(srcType);
```

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


More information about the Mlir-commits mailing list