Skip to content

Commit bd58ab7

Browse files
committed
Add test for contrained (with rounding mode) case.
1 parent c3875c1 commit bd58ab7

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

mlir/test/Dialect/Arith/canonicalize.mlir

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,15 +754,23 @@ func.func @truncExtf3(%arg0: f32) -> f16 {
754754
}
755755

756756
// CHECK-LABEL: @truncSitofp
757-
// CHECK-NOT: truncf
758757
// CHECK: %[[SITOFP:.*]] = arith.sitofp %[[ARG0:.*]] : i32 to f32
758+
// CHECK-NOT: truncf
759759
// CHECK: return %[[SITOFP]]
760760
func.func @truncSitofp(%arg0: i32) -> f32 {
761761
%sitofp = arith.sitofp %arg0 : i32 to f64
762762
%trunc = arith.truncf %sitofp : f64 to f32
763763
return %trunc : f32
764764
}
765765

766+
// CHECK-LABEL: @truncSitofpConstrained
767+
// CHECK: truncf
768+
func.func @truncSitofpConstrained(%arg0: i32) -> f32 {
769+
%sitofp = arith.sitofp %arg0 : i32 to f64
770+
%trunc = arith.truncf %sitofp to_nearest_even : f64 to f32
771+
return %trunc : f32
772+
}
773+
766774
// TODO: We should also add a test for not folding arith.extf on information loss.
767775
// This may happen when extending f8E5M2FNUZ to f16.
768776

0 commit comments

Comments
 (0)