[Mlir-commits] [mlir] [mlir][SPIR-V] Fix swapped GL/CL SAbs ops in arith.remsi lowering (PR #202959)

Arseniy Obolenskiy llvmlistbot at llvm.org
Wed Jun 10 05:53:25 PDT 2026


https://github.com/aobolensk created https://github.com/llvm/llvm-project/pull/202959

The GL/CL template args were confused but in fact it did not affect the actual result, so no test modification is required. The reason is that driver legalizes ops by target env capabilities and rewriter that created the unsupported variant of the op is dropped and another one is picked

>From 26865acb9ce6ed87f83259929d0a4f0a0feff763 Mon Sep 17 00:00:00 2001
From: Arseniy Obolenskiy <arseniy.obolenskiy at amd.com>
Date: Wed, 10 Jun 2026 14:50:09 +0200
Subject: [PATCH] [mlir][SPIR-V] Fix swapped GL/CL SAbs ops in arith.remsi
 lowering

The GL/CL template args were transposed but it did not affect the actual result, so no test modification is required. The reason is that driver legalizes ops by target env capabilities and rewriter that created the unsupported variant of the op is dropped and another one is picked
---
 mlir/lib/Conversion/ArithToSPIRV/ArithToSPIRV.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mlir/lib/Conversion/ArithToSPIRV/ArithToSPIRV.cpp b/mlir/lib/Conversion/ArithToSPIRV/ArithToSPIRV.cpp
index 63f84bc1ceb60..54e9176068b88 100644
--- a/mlir/lib/Conversion/ArithToSPIRV/ArithToSPIRV.cpp
+++ b/mlir/lib/Conversion/ArithToSPIRV/ArithToSPIRV.cpp
@@ -471,7 +471,7 @@ struct RemSIOpGLPattern final : public OpConversionPattern<arith::RemSIOp> {
   LogicalResult
   matchAndRewrite(arith::RemSIOp op, OpAdaptor adaptor,
                   ConversionPatternRewriter &rewriter) const override {
-    Value result = emulateSignedRemainder<spirv::CLSAbsOp>(
+    Value result = emulateSignedRemainder<spirv::GLSAbsOp>(
         op.getLoc(), adaptor.getOperands()[0], adaptor.getOperands()[1],
         adaptor.getOperands()[0], rewriter);
     rewriter.replaceOp(op, result);
@@ -487,7 +487,7 @@ struct RemSIOpCLPattern final : public OpConversionPattern<arith::RemSIOp> {
   LogicalResult
   matchAndRewrite(arith::RemSIOp op, OpAdaptor adaptor,
                   ConversionPatternRewriter &rewriter) const override {
-    Value result = emulateSignedRemainder<spirv::GLSAbsOp>(
+    Value result = emulateSignedRemainder<spirv::CLSAbsOp>(
         op.getLoc(), adaptor.getOperands()[0], adaptor.getOperands()[1],
         adaptor.getOperands()[0], rewriter);
     rewriter.replaceOp(op, result);



More information about the Mlir-commits mailing list