[PATCH] D54719: [Intrinsic] Signed Fixed Point Multiplication Intrinsic
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 14 08:19:19 PDT 2019
lebedev.ri added inline comments.
Herald added a project: LLVM.
================
Comment at: llvm/trunk/docs/LangRef.rst:12820-12829
+This operation performs fixed point multiplication on the 2 arguments of a
+specified scale. The result will also be returned in the same scale specified
+in the third argument.
+
+If the result value cannot be precisely represented in the given scale, the
+value is rounded up or down to the closest representable value. The rounding
+direction is unspecified.
----------------
To someone unfamiliar with what fixed-point math is, this is somewhat vague.
Would it please be possible to reword this with some more details?
Overview section in https://llvm.org/docs/LangRef.html#llvm-fshl-intrinsic is a nice example of it would look best.
In particular, it isn't all that obvious how scale interacts with lhs/rhs.
My current guess:
```
%r = call i4 @llvm.smul.fix.i4(i4 %a, i4 %b, i32 %c)
=>
%a2 = sext i4 %a to i8
%b2 = sext i4 %b to i8
%mul = mul nsw nuw i8 %a, %b
%c2 = trunc i32 %c to i8
%scale = ashr i8 %mul, i8 %c ; does not convey the randomness of rounding though
%r = trunc i8 %scale to i4
```
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D54719/new/
https://reviews.llvm.org/D54719
More information about the llvm-commits
mailing list