[PATCH] D49242: [Intrinsics] define funnel shift IR intrinsics + DAG builder support

Fabian Giesen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 16 11:44:58 PDT 2018


fabiang added inline comments.


================
Comment at: docs/LangRef.rst:11924
+
+      %r = call i8 @llvm.fshl.i8(i8 %x, i8 %y, i8 %z)  ; %r = i8: extract((concat(%x, %y) << %z), 0, 7)
+      %r = call i8 @llvm.fshl.i8(i8 255, i8 0, i8 15)  ; %r = i8: 128 (0b10000000)
----------------
spatel wrote:
> fabiang wrote:
> > I think this should be extract((contact(%x, %y) << %z), 8, 15) since it grabs the more significant half of the shifted double-width value.
> Do we have any precedence/documentation for bit numbering of LLVM IR values?
> IIUC, you're seeing this:
> MSB:15 -> LSB:0
> 
> but I was referencing this:
> MSB:0 -> LSB 15
> 
> Not sure if this is relevant, but we count vector elements from 0-on-the-left:
> "The elements of the two input vectors are numbered from left to right across both of the vectors."
> 
> Either way, I will add an explanatory comment.
A quick search doesn't turn up anything. What I can find in other parts of the language reference seems to carefully sidestep the issue of bit numbering, which is probably for the best given the holy wars involved.

Just rewrite as the non-ambiguous `(... >> 8) & 0xff` (high extract) and `... & 0xff` (low extract)? It's just an example anyway.


https://reviews.llvm.org/D49242





More information about the llvm-commits mailing list