diff --git a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp --- a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp +++ b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp @@ -567,11 +567,6 @@ return rewriter.create(loc, resultTypes, args, mlir::None); - // All other si-to-fp conversions should be handled by SIToFP. - if (arith::SIToFPOp::areCastCompatible(srcTy, dstTy)) - return rewriter.create(loc, resultTypes, args, - mlir::None); - // Unsigned integers need an unrealized cast so that they can be passed // to UIToFP. if (srcTy.isUnsignedInteger() && dstTy.isa()) { @@ -585,6 +580,11 @@ unrealizedCast); } + // All other si-to-fp conversions should be handled by SIToFP. + if (arith::SIToFPOp::areCastCompatible(srcTy, dstTy)) + return rewriter.create(loc, resultTypes, args, + mlir::None); + // Casting to boolean, floats need to only be checked as not-equal to zero. if (srcTy.isa() && dstTy.isInteger(1)) { Value zero = rewriter.create( diff --git a/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir b/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir --- a/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir +++ b/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir @@ -291,6 +291,15 @@ // ----- +// CHECK-LABEL: @test_simple_ui8 +func @test_simple_ui8(%arg0: tensor<1xui8>) -> () { + // CHECK: arith.uitofp + %0 = "tosa.cast"(%arg0) : (tensor<1xui8>) -> tensor<1xf32> + return +} + +// ----- + // CHECK-LABEL: @test_simple_i32 func @test_simple_i32(%arg0: tensor<1xi32>) -> () { // CHECK: linalg.generic