Skip to content

Commit a4d05e0

Browse files
committed
Move into GL canonicalizer
1 parent eaf00ee commit a4d05e0

File tree

5 files changed

+24
-34
lines changed

5 files changed

+24
-34
lines changed

mlir/include/mlir/Dialect/SPIRV/IR/SPIRVGLOps.td

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1196,7 +1196,6 @@ def SPIRV_GLLengthOp : SPIRV_GLOp<"Length", 66, [
11961196
}];
11971197

11981198
let hasVerifier = 0;
1199-
let hasCanonicalizer = 1;
12001199
}
12011200

12021201
// -----

mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,12 +1403,3 @@ void spirv::SelectionOp::getCanonicalizationPatterns(RewritePatternSet &results,
14031403
MLIRContext *context) {
14041404
results.add<ConvertSelectionOpToSelect>(context);
14051405
}
1406-
1407-
//===----------------------------------------------------------------------===//
1408-
// spirv.GL.Length
1409-
//===----------------------------------------------------------------------===//
1410-
1411-
void spirv::GLLengthOp::getCanonicalizationPatterns(RewritePatternSet &results,
1412-
MLIRContext *context) {
1413-
results.add<ConvertGLLengthToGLFAbs>(context);
1414-
}

mlir/lib/Dialect/SPIRV/IR/SPIRVGLCanonicalization.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ void populateSPIRVGLCanonicalizationPatterns(RewritePatternSet &results) {
3434
ConvertComparisonIntoClamp2_SPIRV_SLessThanOp,
3535
ConvertComparisonIntoClamp2_SPIRV_SLessThanEqualOp,
3636
ConvertComparisonIntoClamp2_SPIRV_ULessThanOp,
37-
ConvertComparisonIntoClamp2_SPIRV_ULessThanEqualOp>(
38-
results.getContext());
37+
ConvertComparisonIntoClamp2_SPIRV_ULessThanEqualOp,
38+
ConvertGLLengthToGLFAbs>(results.getContext());
3939
}
4040
} // namespace spirv
4141
} // namespace mlir

mlir/test/Dialect/SPIRV/Transforms/canonicalize.mlir

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2490,25 +2490,3 @@ func.func @cannot_canonicalize_selection_op_4(%cond: i1) -> () {
24902490
}
24912491
spirv.Return
24922492
}
2493-
2494-
// -----
2495-
2496-
//===----------------------------------------------------------------------===//
2497-
// spirv.GL.Length
2498-
//===----------------------------------------------------------------------===//
2499-
2500-
// CHECK-LABEL: @convert_length_into_fabs_scalar
2501-
func.func @convert_length_into_fabs_scalar(%arg0 : f32) -> f32 {
2502-
//CHECK: spirv.GL.FAbs {{%.*}} : f32
2503-
//CHECK-NOT: spirv.GL.Length
2504-
%0 = spirv.GL.Length %arg0 : f32 -> f32
2505-
spirv.ReturnValue %0 : f32
2506-
}
2507-
2508-
// CHECK-LABEL: @dont_convert_length_into_fabs_vec
2509-
func.func @dont_convert_length_into_fabs_vec(%arg0 : vector<3xf32>) -> f32 {
2510-
//CHECK: spirv.GL.Length {{%.*}} : vector<3xf32> -> f32
2511-
//CHECK-NOT: spirv.GL.FAbs
2512-
%0 = spirv.GL.Length %arg0 : vector<3xf32> -> f32
2513-
spirv.ReturnValue %0 : f32
2514-
}

mlir/test/Dialect/SPIRV/Transforms/gl-canonicalize.mlir

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,25 @@ func.func @clamp_ulessthanequal(%input: i32, %min: i32, %max: i32) -> i32 {
177177
// CHECK-NEXT: spirv.ReturnValue [[RES]]
178178
spirv.ReturnValue %2 : i32
179179
}
180+
181+
// -----
182+
183+
//===----------------------------------------------------------------------===//
184+
// spirv.GL.Length
185+
//===----------------------------------------------------------------------===//
186+
187+
// CHECK-LABEL: @convert_length_into_fabs_scalar
188+
func.func @convert_length_into_fabs_scalar(%arg0 : f32) -> f32 {
189+
//CHECK: spirv.GL.FAbs {{%.*}} : f32
190+
//CHECK-NOT: spirv.GL.Length
191+
%0 = spirv.GL.Length %arg0 : f32 -> f32
192+
spirv.ReturnValue %0 : f32
193+
}
194+
195+
// CHECK-LABEL: @dont_convert_length_into_fabs_vec
196+
func.func @dont_convert_length_into_fabs_vec(%arg0 : vector<3xf32>) -> f32 {
197+
//CHECK: spirv.GL.Length {{%.*}} : vector<3xf32> -> f32
198+
//CHECK-NOT: spirv.GL.FAbs
199+
%0 = spirv.GL.Length %arg0 : vector<3xf32> -> f32
200+
spirv.ReturnValue %0 : f32
201+
}

0 commit comments

Comments
 (0)