llvm-project/mlir/lib/Dialect/SPIRV/IR/SPIRVGLCanonicalization.cpp
Jakub Kuderski ef87da0632
[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.
2025-10-20 15:41:12 -04:00

42 lines
1.6 KiB
C++

//===- SPIRVGLCanonicalization.cpp - SPIR-V GLSL canonicalization patterns =//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file defines the canonicalization patterns for SPIR-V GLSL-specific ops.
//
//===----------------------------------------------------------------------===//
#include "mlir/Dialect/SPIRV/IR/SPIRVGLCanonicalization.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
using namespace mlir;
namespace {
#include "SPIRVCanonicalization.inc"
} // namespace
namespace mlir {
namespace spirv {
void populateSPIRVGLCanonicalizationPatterns(RewritePatternSet &results) {
results.add<ConvertComparisonIntoClamp1_SPIRV_FOrdLessThanOp,
ConvertComparisonIntoClamp1_SPIRV_FOrdLessThanEqualOp,
ConvertComparisonIntoClamp1_SPIRV_SLessThanOp,
ConvertComparisonIntoClamp1_SPIRV_SLessThanEqualOp,
ConvertComparisonIntoClamp1_SPIRV_ULessThanOp,
ConvertComparisonIntoClamp1_SPIRV_ULessThanEqualOp,
ConvertComparisonIntoClamp2_SPIRV_FOrdLessThanOp,
ConvertComparisonIntoClamp2_SPIRV_FOrdLessThanEqualOp,
ConvertComparisonIntoClamp2_SPIRV_SLessThanOp,
ConvertComparisonIntoClamp2_SPIRV_SLessThanEqualOp,
ConvertComparisonIntoClamp2_SPIRV_ULessThanOp,
ConvertComparisonIntoClamp2_SPIRV_ULessThanEqualOp>(
results.getContext());
}
} // namespace spirv
} // namespace mlir