[Mlir-commits] [mlir] [mlir][SPIR-V] Add SPIRVToLLVM conversions for FMod and SMod (PR #206933)
Igor Wodiany
llvmlistbot at llvm.org
Thu Jul 30 01:31:12 PDT 2026
================
@@ -1032,6 +1032,83 @@ class ClampPattern : public SPIRVToLLVMConversion<SPIRVOp> {
}
};
+/// Converts `spirv.FMod` to `x - y * floor(x / y)`. The SPIR-V op requires the
+/// result to take the sign of the divisor, whereas `llvm.frem` keeps the sign
+/// of the dividend, so `frem` cannot be used directly.
+class FModPattern : public SPIRVToLLVMConversion<spirv::FModOp> {
+public:
+ using SPIRVToLLVMConversion<spirv::FModOp>::SPIRVToLLVMConversion;
+
+ LogicalResult
+ matchAndRewrite(spirv::FModOp op, OpAdaptor adaptor,
+ ConversionPatternRewriter &rewriter) const override {
+ auto dstType = getTypeConverter()->convertType(op.getType());
----------------
IgWod wrote:
```suggestion
Type dstType = getTypeConverter()->convertType(op.getType());
```
https://github.com/llvm/llvm-project/pull/206933
More information about the Mlir-commits
mailing list