2.1 __int128 example
#10
Closed
opened 5 years ago by wschmidt-ibm
·
8 comments
Loading…
Reference in New Issue
There is no content yet.
Delete Branch '%!s(<nil>)'
Deleting a branch is permanent. It CANNOT be undone. Continue?
Paul Clarke has requested an example of how to construct a vector __int128 constant, and this seems warranted.
Is this sort-of the preferred way of constructing a (vector of)
__int128
?...maybe an example like above with some words about how "Current C compilers" don't yet support native 128-bit constants. Actually, I now see that you have those words at the end of section 2.1. 👍
(I didn't know if you wanted to handle this issue, or if I should take a stab at it.)
Does that even compile? That requires a 128-bit shift operation to be supported, which isn't there in ISA v3.0.
I believe what Steve has done in pveclib is create a union of an __int128 and two long longs. So you get something like
It compiles and runs. You don't give GCC enough credit! ;-)
My way doesn't require any
#ifdefs
.Do you have a preference?
My example which uses the 128bit shift in the initializer also works on GCC 4.8.5 (RHEL 7.7).
Please have a look at the code generation in the two different ways, compiling it for both LE and BE. Whichever looks better under those circumstances is what I would prefer to suggest to the community.
My guess is that both of them end up just generating a constant and loading it from memory...if that's the case, then I prefer your way.
That would also require changing some text that talks about requiring different code for endianness...
The
objdump -d
of both waysis identical, and as you guessed: generating a constant and loading it from memory (lxv
).