This patch adds TruncOp for Math, it returns the operand rounded to the nearest integer not larger in magnitude than the operand. And this patch also adds the correspond llvm intrinsic op.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Comment Actions
arith.truncf would use the default rounding mode and has the similar semantic with fptrunc in llvm ir; math.trunc should always use strict rounding to the nearest integer not larger in magnitude than the operand and has the similar semantic with llvm.trunc in llvm ir or trunc in libm.
Comment Actions
Actually more fundamentally:
- arith.truncf is really a "truncate" in the sense of "reducing bit size", for example "convert from f32 to f16 and round". But it does not produce an integer value.
- llvm.trunc is operating on the same bit-size (f32->f32, f64->f64) and is actually just rounding to the nearest integer. It is coming alongside floor and ceil.
This seems like a repeat of the first sentence