Skip to content

Commit ef87da0

Browse files
authored
[mlir][spirv] Remove invalid canon pattern for GL.Length (#164301)
This rewrite does not preserve numerics: for example, we'd expect the maximum fp value to yield Inf instead of identity. `GL.Length` does not allow for fast math flags, so we need to remove this. Special cases (constants) can be handled via a folder if someone wants to implement one.
1 parent 6284041 commit ef87da0

File tree

3 files changed

+2
-32
lines changed

3 files changed

+2
-32
lines changed

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,3 @@ def ConvertComparisonIntoClamp2_#CmpClampPair[0] : Pat<
7575
)),
7676
(CmpClampPair[1] $input, $min, $max)>;
7777
}
78-
79-
//===----------------------------------------------------------------------===//
80-
// spirv.GL.Length -> spirv.GL.FAbs
81-
//===----------------------------------------------------------------------===//
82-
83-
def ConvertGLLengthToGLFAbs : Pat<
84-
(SPIRV_GLLengthOp SPIRV_Float:$operand),
85-
(SPIRV_GLFAbsOp $operand)>;

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-
ConvertGLLengthToGLFAbs>(results.getContext());
37+
ConvertComparisonIntoClamp2_SPIRV_ULessThanEqualOp>(
38+
results.getContext());
3939
}
4040
} // namespace spirv
4141
} // namespace mlir

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

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -177,25 +177,3 @@ 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)