Skip to content

Commit 7cba618

Browse files
authored
Merge pull request #406 from Xilinx/matthias.emitc_fptoui
arith-to-emitc: Fix lowering of fptoui
2 parents 09f9db8 + da70608 commit 7cba618

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

mlir/lib/Conversion/ArithToEmitC/ArithToEmitC.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ class FtoICastOpConversion : public OpConversionPattern<CastOp> {
674674
Type actualResultType = dstType;
675675
if (isa<arith::FPToUIOp>(castOp)) {
676676
actualResultType =
677-
rewriter.getIntegerType(operandType.getIntOrFloatBitWidth(),
677+
rewriter.getIntegerType(dstType.getIntOrFloatBitWidth(),
678678
/*isSigned=*/false);
679679
}
680680

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,10 @@ func.func @arith_float_to_int_cast_ops(%arg0: f32, %arg1: f64) {
587587
// CHECK: emitc.cast %[[CAST0]] : ui32 to i32
588588
%4 = arith.fptoui %arg0 : f32 to i32
589589

590+
// CHECK: %[[CAST0:.*]] = emitc.cast %arg0 : f32 to ui16
591+
// CHECK: emitc.cast %[[CAST0]] : ui16 to i16
592+
%5 = arith.fptoui %arg0 : f32 to i16
593+
590594
return
591595
}
592596

0 commit comments

Comments
 (0)