Skip to content

scalar.fptrunc

← scalar dialect

Float precision truncation using round-to-nearest, ties-to-even. The result format must be strictly narrower than the input format. Special values follow the destination format: f8E4M3 saturates finite overflow and infinities to its signed maximum finite value while preserving NaNs; IEEE formats preserve infinities and NaNs. Without flags, the conversion preserves subnormal inputs and results. daz permits replacing a subnormal input with its signed zero before conversion; ftz permits replacing a subnormal result with its signed zero.

Operation contract

Property Value
Semantic phase executable
Traits Pure, DistributionTransfer, SafeToSpeculate

Signature

Kind Name Type Cardinality Description
Operand input float required —
Result result float required —
Attribute subnormal flags FloatConversionFlags optional —

Verification constraints

  • ElementWidthLessThan(result, input)

Examples

%result = scalar.fptrunc %input : f32 to f16