diff --git a/mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp b/mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp --- a/mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp +++ b/mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp @@ -801,7 +801,8 @@ } namespace { -template struct ComparisonFold { +template +struct ComparisonFold { ComparisonFold() = default; APInt operator()(const APInt &l, const APInt &r) { return APInt(1, Cmp()(l, r)); @@ -1047,6 +1048,11 @@ if (!adaptor.getInput()) return {}; + // Cannot create an ElementsAttr from non-int/float/index types + if (!inputTy.getElementType().isIntOrIndexOrFloat() || + !outputTy.getElementType().isIntOrIndexOrFloat()) + return {}; + auto operand = adaptor.getInput().cast(); if (operand.isSplat() && outputTy.hasStaticShape()) { return SplatElementsAttr::get(outputTy, operand.getSplatValue());