[LLVMdev] fixed point types

me22 me22.ca at gmail.com
Wed Dec 1 10:50:00 PST 2010


On Wed, Dec 1, 2010 at 01:46, Frits van Bommel <fvbommel at gmail.com> wrote:
>
> Wouldn't the result of 8.24 * 8.24 be 16.48, requiring widening to i64
> instead of i56?
>

It could be, but since i32 * i32 in LLVM gives an i32, not an i64, I
thought this was more consistent, as the "i8.24" * "i8.24" would be an
"i8.24".

It also means that if the multiplication saturates, it gives the right
answer -- if you widened to i64, did the saturating multiplication,
and truncated, the fixed-point multiply wouldn't have been saturated.

>
> I think saturating might warrant intrinsics, but above transform would
> be one of the optimizations I suggested -instcombine might do if it's
> provable no saturation can occur.
>

I was thinking of saturating as a flag on the instruction, like the
current nsw and nuw.  Whether they should be that, intrinsics, or new
instructions is a decision for people with far more LLVM experience
than mine, though.



More information about the llvm-dev mailing list