Skip to content

Commit 10282d0

Browse files
committed
Reconcile with upstream merged changes
1 parent 946c4f1 commit 10282d0

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

mlir/include/mlir/Conversion/Passes.td

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,6 @@ def ArithToAMDGPUConversionPass : Pass<"convert-arith-to-amdgpu"> {
139139

140140
def ConvertArithToEmitC : Pass<"convert-arith-to-emitc"> {
141141
let summary = "Convert Arith dialect to EmitC dialect";
142-
let description = [{
143-
This pass converts `arith` dialect operations to `emitc`.
144-
}];
145142
let dependentDialects = ["emitc::EmitCDialect"];
146143
}
147144

mlir/lib/Conversion/ArithToEmitC/ArithToEmitC.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,8 @@ class SelectOpConversion : public OpConversionPattern<arith::SelectOp> {
367367
template <typename CastOp>
368368
class FtoICastOpConversion : public OpConversionPattern<CastOp> {
369369
public:
370-
using OpConversionPattern<CastOp>::OpConversionPattern;
370+
FtoICastOpConversion(const TypeConverter &typeConverter, MLIRContext *context)
371+
: OpConversionPattern<CastOp>(typeConverter, context) {}
371372

372373
LogicalResult
373374
matchAndRewrite(CastOp castOp, typename CastOp::Adaptor adaptor,
@@ -382,7 +383,9 @@ class FtoICastOpConversion : public OpConversionPattern<CastOp> {
382383
if (!dstType)
383384
return rewriter.notifyMatchFailure(castOp, "type conversion failed");
384385

385-
if (!emitc::isSupportedIntegerType(dstType))
386+
// Float-to-i1 casts are not supported: any value with 0 < value < 1 must be
387+
// truncated to 0, whereas a boolean conversion would return true.
388+
if (!emitc::isSupportedIntegerType(dstType) || dstType.isInteger(1))
386389
return rewriter.notifyMatchFailure(castOp,
387390
"unsupported cast destination type");
388391

@@ -411,7 +414,8 @@ class FtoICastOpConversion : public OpConversionPattern<CastOp> {
411414
template <typename CastOp>
412415
class ItoFCastOpConversion : public OpConversionPattern<CastOp> {
413416
public:
414-
using OpConversionPattern<CastOp>::OpConversionPattern;
417+
ItoFCastOpConversion(const TypeConverter &typeConverter, MLIRContext *context)
418+
: OpConversionPattern<CastOp>(typeConverter, context) {}
415419

416420
LogicalResult
417421
matchAndRewrite(CastOp castOp, typename CastOp::Adaptor adaptor,

mlir/test/Conversion/ArithToEmitC/arith-to-emitc-unsupported.mlir

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,20 @@ func.func @arith_cast_to_f16(%arg0: i32) -> f16 {
6262
%t = arith.sitofp %arg0 : i32 to f16
6363
return %t: f16
6464
}
65+
66+
// -----
67+
68+
func.func @arith_cast_fptosi_i1(%arg0: f32) -> i1 {
69+
// expected-error @+1 {{failed to legalize operation 'arith.fptosi'}}
70+
%t = arith.fptosi %arg0 : f32 to i1
71+
return %t: i1
72+
}
73+
74+
// -----
75+
76+
func.func @arith_cast_fptoui_i1(%arg0: f32) -> i1 {
77+
// expected-error @+1 {{failed to legalize operation 'arith.fptoui'}}
78+
%t = arith.fptoui %arg0 : f32 to i1
79+
return %t: i1
80+
}
81+

0 commit comments

Comments
 (0)