[Mlir-commits] [mlir] 266b5bc - [mlir][spirv] Add a missing pattern to MathToSPIRV Conversion pass

Lei Zhang llvmlistbot at llvm.org
Wed May 24 15:31:22 PDT 2023


Author: Nishant Patel
Date: 2023-05-24T15:30:54-07:00
New Revision: 266b5bc1f61239955eb6eeceecdb78e7929d1abb

URL: https://github.com/llvm/llvm-project/commit/266b5bc1f61239955eb6eeceecdb78e7929d1abb
DIFF: https://github.com/llvm/llvm-project/commit/266b5bc1f61239955eb6eeceecdb78e7929d1abb.diff

LOG: [mlir][spirv] Add a missing pattern to MathToSPIRV Conversion pass

The MathToSPIRV conversion pass missed out a pattern for converting
math::AbsIOP to spirv::CLSAbsOp

Reviewed By: antiagainst

Differential Revision: https://reviews.llvm.org/D151378

Added: 
    

Modified: 
    mlir/lib/Conversion/MathToSPIRV/MathToSPIRV.cpp
    mlir/test/Conversion/MathToSPIRV/math-to-opencl-spirv.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Conversion/MathToSPIRV/MathToSPIRV.cpp b/mlir/lib/Conversion/MathToSPIRV/MathToSPIRV.cpp
index 6630aaf7e3a23..0b29c93e2d890 100644
--- a/mlir/lib/Conversion/MathToSPIRV/MathToSPIRV.cpp
+++ b/mlir/lib/Conversion/MathToSPIRV/MathToSPIRV.cpp
@@ -430,6 +430,7 @@ void populateMathToSPIRVPatterns(SPIRVTypeConverter &typeConverter,
   // OpenCL patterns
   patterns.add<Log1pOpPattern<spirv::CLLogOp>, ExpM1OpPattern<spirv::CLExpOp>,
                CheckedElementwiseOpPattern<math::AbsFOp, spirv::CLFAbsOp>,
+               CheckedElementwiseOpPattern<math::AbsIOp, spirv::CLSAbsOp>,
                CheckedElementwiseOpPattern<math::CeilOp, spirv::CLCeilOp>,
                CheckedElementwiseOpPattern<math::CosOp, spirv::CLCosOp>,
                CheckedElementwiseOpPattern<math::ErfOp, spirv::CLErfOp>,

diff  --git a/mlir/test/Conversion/MathToSPIRV/math-to-opencl-spirv.mlir b/mlir/test/Conversion/MathToSPIRV/math-to-opencl-spirv.mlir
index da02e6287961d..03a5c2f2bc9b1 100644
--- a/mlir/test/Conversion/MathToSPIRV/math-to-opencl-spirv.mlir
+++ b/mlir/test/Conversion/MathToSPIRV/math-to-opencl-spirv.mlir
@@ -99,6 +99,13 @@ func.func @float32_ternary_vector(%a: vector<4xf32>, %b: vector<4xf32>,
   return
 }
 
+// CHECK-LABEL: @int_unary
+func.func @int_unary(%arg0: i32) {
+  // CHECK: spirv.CL.s_abs %{{.*}}
+  %0 = math.absi %arg0 : i32
+  return
+}
+
 } // end module
 
 // -----


        


More information about the Mlir-commits mailing list