[Mlir-commits] [mlir] [mlir][vector] VectorLinearize: `ub.poison` support (PR #128612)
Ivan Butygin
llvmlistbot at llvm.org
Sat Mar 1 09:42:03 PST 2025
================
@@ -57,40 +58,67 @@ static bool isLessThanOrEqualTargetBitWidth(Type t, unsigned targetBitWidth) {
}
namespace {
-struct LinearizeConstant final : OpConversionPattern<arith::ConstantOp> {
- using OpConversionPattern::OpConversionPattern;
- LinearizeConstant(
+struct LinearizeConstantLike final
+ : OpTraitConversionPattern<OpTrait::ConstantLike> {
+ using OpTraitConversionPattern::OpTraitConversionPattern;
+
+ LinearizeConstantLike(
const TypeConverter &typeConverter, MLIRContext *context,
unsigned targetVectBitWidth = std::numeric_limits<unsigned>::max(),
PatternBenefit benefit = 1)
- : OpConversionPattern(typeConverter, context, benefit),
+ : OpTraitConversionPattern(typeConverter, context, benefit),
targetVectorBitWidth(targetVectBitWidth) {}
LogicalResult
- matchAndRewrite(arith::ConstantOp constOp, OpAdaptor adaptor,
+ matchAndRewrite(Operation *op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
- Location loc = constOp.getLoc();
+ Location loc = op->getLoc();
+ if (op->getNumResults() != 1)
+ return rewriter.notifyMatchFailure(loc, "expected 1 result");
+
auto resType =
- getTypeConverter()->convertType<VectorType>(constOp.getType());
+ getTypeConverter()->convertType<VectorType>(op->getResult(0).getType());
----------------
Hardcode84 wrote:
done
https://github.com/llvm/llvm-project/pull/128612
More information about the Mlir-commits
mailing list