Re: Prioritize Performance over Correctness

Liste des GroupesRevenir à cl c 
Sujet : Re: Prioritize Performance over Correctness
De : cr88192 (at) *nospam* gmail.com (BGB)
Groupes : comp.lang.c
Date : 28. Jul 2026, 22:02:12
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <114b5jd$cdh4$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
User-Agent : Mozilla Thunderbird
On 7/28/2026 8:17 AM, bart wrote:
On 28/07/2026 13:18, Johann 'Myrkraverk' Oskarsson wrote:
On 28/07/2026 8:02 PM, bart wrote:
 
>
In any case, there is no conversion to int involved; it is just has to implement that comparison by whatever means works.
>
 
On the other hand, to the programmer, especially those not who have not
and never will read the C language standard, it does look like the p
pointer is "truncated" to an integer valued 0 or 1, in boolean context.
 It doesn't look like that all. This is just testing for 'truthiness', which in many languages can be applied to data types such as strings or lists.
 'Truncation' doesn't work either: you can have all-bits-zero NULL, and a value for 'p' of 0x123456 - truncating to one bit would give you zero, which is false.
 There is also rarely any result - no value needs to be yielded when the result just affects control-flow.
 
In practice, it is mostly come sort of "compare with 0", of some sort.
In my case, typically a 64-bit compare with 0 is used, as while tagged NULLs could exist in theory, by default they don't, and it is not worth the added cost of dealing with them (either in software or hardware).
I once did experiment with supporting a few 48-bit ALU ops specifically for pointers, but these worked out as "deceptively expensive" for the CPU core. So, this idea was soon dropped (well, along with 48-bit Load/Store with a 16-bit index scale; was overly niche and too expensive to justify that niche).
Eventually noted, the main winning strategy is mostly to just use native 64-bit compare ops for everything. Earlier forms of the ISA had 32-bit compare ops that ignored the high 32 bits, but these are effectively gone in the newer variant.
Even if it does mean that in cases where one wants to ignore the high 16 bits, it is necessary to sign or zero extend from 48 bits. In the default mode, my compiler does not do so, so using tagging bits may interfere with pointer comparison. Most cases where tagging are used though are not places where the pointers are likely to be compared though.
Except well, in the experimental bounds-checked mode, which had more expensive multi-op zero-extending pointer compares (as otherwise the bounds-check tagging would unleash chaos).
Did create another mess:
   Pointer subtract also needs to sign-extend;
   Casting pointers to long needing to truncate the high bits;
   ...
This created a hassle for code that needed to twiddle the tag bits though, so, say:
   x=(long)((__m64)(ptr));
With casting via __m64 as a "just give me the raw bits" thing, where __m64 and __m128 were understood as opaque "bag of bits" types, which lack any operations of their own, but can be used to do raw bit-casts in other cases where the cast would have modified the type.
In this compiler:
   memcpy(&x, &y, sizeof(T));  //not ideal, various drawbacks
   x=*(T*)(&y);      //less bad, still not ideal
   x=(T)((__mXX)y);  //usually the fastest, bare register MOV.
Contrast with MSVC which treated __m64/__m128 as "some sort of unholy hackery masquerading as a struct", personally I think "type whose sole purpose is to be N bits" is a more sensible interpretation.
Then added __m32 and __m16 for other cases where I felt a need for raw-bit casting. No "__m8" though mostly for lack of relevant types to cast between (no useful distinction from "unsigned char" or similar).
They also still have tie-ins with SIMD, though had mostly ended up taking a different approach (from either MSVC or GCC), and instead effectively bolting GLSL style vectors onto C.
Where, the GLSL approach seemed closest to my typical use-cases.
Or, say, vector types:
   __vec2f, __vec3f, __vec4f     //2/3/4 element, float
   __vec2d, __vec3d, __vec4d     //2/3/4 element, double
   __vec2h. __vec3h, __vec4h     //2/3/4 element, half / "short float"
   __vec2sf. __vec3sf, __vec4sf  //2/3/4 element, half, same as above
   __quatf, __quatd              //quaternion
Where, types:
   float        :  32-bit, S.E8.M23
   double       :  64-bit, S.E11.M52
   short float  :  16-bit, S.E5.M10
   long double  : 128-bit, S.E15.M112
Where, vectors have elements: x/y/z/w.
   Multiple or repeated elements gives a new vector or shuffle.
   '_' is a filler spot containing 0.
"_Complex float" and "_Complex double" also exists as sub-types of vectors (or quaternions), where complex has i/r members (equiv x/y), and quaternions have i/j/k/r (equiv x/y/z/w). Convention would tend to put 'r' as the first component, but putting 'r' at the end works better for reusing existing SIMD handling. At present, these lack native "short float" or "long double" variants.
Typical SIMD operators being, mostly:
   +, -: Pairwise add/sub
   *: Pairwise mul (vec), complex/quaternion product
   /: Pairwise div (vec), complex/quaternion division
   ^: Dot Product (scalar result)
   %: Cross Product (scalar for vec2, vector otherwise)
Also sorta supports GCC style "__attribute__((vector_size(N)))" style SIMD as well.
Well, I will probably stop here...
...

Date Sujet#  Auteur
22 Jul 26 * Prioritize Performance over Correctness138Janis Papanagnou
22 Jul 26 +* Re: Prioritize Performance over Correctness129Keith Thompson
22 Jul 26 i+* Re: Prioritize Performance over Correctness4Dan Cross
22 Jul 26 ii+* Re: Prioritize Performance over Correctness2Keith Thompson
22 Jul 26 iii`- Re: Prioritize Performance over Correctness1Dan Cross
22 Jul 26 ii`- Re: Prioritize Performance over Correctness1Chris M. Thomasson
22 Jul 26 i`* Re: Prioritize Performance over Correctness124Janis Papanagnou
22 Jul 26 i `* Re: Prioritize Performance over Correctness123David Brown
23 Jul 26 i  +* Re: Prioritize Performance over Correctness121BGB
23 Jul 26 i  i`* Re: Prioritize Performance over Correctness120David Brown
23 Jul 26 i  i +* Re: Prioritize Performance over Correctness118Keith Thompson
23 Jul 26 i  i i+* Re: Prioritize Performance over Correctness98Keith Thompson
23 Jul 26 i  i ii`* Re: Prioritize Performance over Correctness97Keith Thompson
24 Jul 26 i  i ii `* Re: Prioritize Performance over Correctness96David Brown
24 Jul 26 i  i ii  +- Re: Prioritize Performance over Correctness1Keith Thompson
25 Jul 26 i  i ii  `* Re: Prioritize Performance over Correctness94Waldek Hebisch
27 Jul 26 i  i ii   `* Re: Prioritize Performance over Correctness93James Kuyper
27 Jul 26 i  i ii    +* Re: Prioritize Performance over Correctness91Keith Thompson
27 Jul 26 i  i ii    i+* Re: Prioritize Performance over Correctness7BGB
27 Jul 26 i  i ii    ii`* Re: Prioritize Performance over Correctness6James Kuyper
27 Jul 26 i  i ii    ii `* Re: Prioritize Performance over Correctness5Keith Thompson
28 Jul 26 i  i ii    ii  `* Re: Prioritize Performance over Correctness4Dan Cross
28 Jul 26 i  i ii    ii   `* Re: Multics( Re: Prioritize Performance over Correctness)3Dan Cross
28 Jul 26 i  i ii    ii    `* Re: Multics( Re: Prioritize Performance over Correctness)2Dan Cross
30 Jul 26 i  i ii    ii     `- Re: Multics( Re: Prioritize Performance over Correctness)1Dan Cross
28 Jul 26 i  i ii    i+* Re: Prioritize Performance over Correctness82Keith Thompson
28 Jul 26 i  i ii    ii+* Re: Prioritize Performance over Correctness18Keith Thompson
28 Jul 26 i  i ii    iii+* Re: Prioritize Performance over Correctness13bart
28 Jul 26 i  i ii    iiii+* Re: Prioritize Performance over Correctness10bart
28 Jul 26 i  i ii    iiiii+- Re: Prioritize Performance over Correctness1BGB
29 Jul 26 i  i ii    iiiii`* Re: Prioritize Performance over Correctness8bart
29 Jul 26 i  i ii    iiiii +* Re: Prioritize Performance over Correctness2bart
29 Jul 26 i  i ii    iiiii i`- Re: Prioritize Performance over Correctness1bart
29 Jul 26 i  i ii    iiiii +- Re: Prioritize Performance over Correctness1Keith Thompson
31 Jul 26 i  i ii    iiiii `* Re: Prioritize Performance over Correctness4James Kuyper
31 Jul 26 i  i ii    iiiii  `* Re: Prioritize Performance over Correctness3bart
31 Jul 26 i  i ii    iiiii   +- Re: Prioritize Performance over Correctness1Keith Thompson
1 Aug 26 i  i ii    iiiii   `- Re: Prioritize Correctness Over Performance1Lawrence D’Oliveiro
29 Jul 26 i  i ii    iiii`* Re: Prioritize Performance over Correctness2Keith Thompson
29 Jul 26 i  i ii    iiii `- Re: Prioritize Performance over Correctness1Dan Cross
28 Jul 26 i  i ii    iii+- Re: Prioritize Performance over Correctness1Dan Cross
28 Jul 26 i  i ii    iii+- Re: Prioritize Performance over Correctness1Dan Cross
28 Jul 26 i  i ii    iii+- Re: Prioritize Performance over Correctness1Chris M. Thomasson
29 Jul 26 i  i ii    iii`- Re: Prioritize Performance over Correctness1James Kuyper
28 Jul 26 i  i ii    ii`* Re: Prioritize Performance over Correctness63Chris M. Thomasson
29 Jul 26 i  i ii    ii +* Re: Prioritize Performance over Correctness2James Kuyper
29 Jul 26 i  i ii    ii i`- Re: Prioritize Performance over Correctness1Chris M. Thomasson
29 Jul 26 i  i ii    ii +* Re: Prioritize Performance over Correctness59James Kuyper
29 Jul 26 i  i ii    ii i`* Re: Prioritize Performance over Correctness58Keith Thompson
29 Jul 26 i  i ii    ii i `* Re: Prioritize Performance over Correctness57Chris M. Thomasson
29 Jul 26 i  i ii    ii i  `* Re: Prioritize Performance over Correctness56Keith Thompson
30 Jul 26 i  i ii    ii i   +- Re: Prioritize Performance over Correctness1Chris M. Thomasson
30 Jul 26 i  i ii    ii i   `* Re: Prioritize Performance over Correctness54Richard Harnden
30 Jul 26 i  i ii    ii i    +* Re: Prioritize Correctness over Performance6Lawrence D’Oliveiro
30 Jul 26 i  i ii    ii i    i+- Re: Prioritize Correctness over Performance1James Kuyper
30 Jul 26 i  i ii    ii i    i+* Re: Prioritize Correctness over Performance3Keith Thompson
30 Jul 26 i  i ii    ii i    ii`* Re: Prioritize Correctness over Performance2James Kuyper
30 Jul 26 i  i ii    ii i    ii `- Re: Prioritize Correctness over Performance1Keith Thompson
31 Jul 26 i  i ii    ii i    i`- Re: Prioritize Correctness over Performance1Chris M. Thomasson
30 Jul 26 i  i ii    ii i    +* Re: Prioritize Performance over Correctness46James Kuyper
30 Jul 26 i  i ii    ii i    i`* Re: Prioritize Performance over Correctness45Lawrence D’Oliveiro
30 Jul 26 i  i ii    ii i    i +- Re: Prioritize Performance over Correctness1Keith Thompson
30 Jul 26 i  i ii    ii i    i +* Re: Prioritize Performance over Correctness2Lawrence D’Oliveiro
30 Jul 26 i  i ii    ii i    i i`- Re: Prioritize Performance over Correctness1Keith Thompson
31 Jul 26 i  i ii    ii i    i +* Re: Prioritize Performance over Correctness39Chris M. Thomasson
31 Jul 26 i  i ii    ii i    i i`* Re: Prioritize Performance over Correctness38Dan Cross
31 Jul 26 i  i ii    ii i    i i `* Re: Prioritize Performance over Correctness37Chris M. Thomasson
31 Jul 26 i  i ii    ii i    i i  +- Re: Prioritize Performance over Correctness1Chris M. Thomasson
1 Aug 26 i  i ii    ii i    i i  `* Re: Prioritize Performance over Correctness35Chris M. Thomasson
2 Aug 26 i  i ii    ii i    i i   +* Re: Prioritize Performance over Correctness31David Brown
2 Aug 26 i  i ii    ii i    i i   i`* Re: Prioritize Performance over Correctness30Chris M. Thomasson
2 Aug 26 i  i ii    ii i    i i   i +* Re: Prioritize Performance over Correctness5Lawrence D’Oliveiro
3 Aug 26 i  i ii    ii i    i i   i i+- Re: Prioritize Performance over Correctness1Keith Thompson
3 Aug 26 i  i ii    ii i    i i   i i`* Re: Prioritize Performance over Correctness3Chris M. Thomasson
4 Aug 26 i  i ii    ii i    i i   i i `* Re: Prioritize Correctness Over Performance2Lawrence D’Oliveiro
4 Aug 26 i  i ii    ii i    i i   i i  `- Re: Prioritize Correctness Over Performance1Chris M. Thomasson
3 Aug 26 i  i ii    ii i    i i   i `* Re: Prioritize Performance over Correctness24David Brown
3 Aug 26 i  i ii    ii i    i i   i  +* Re: Prioritize Performance over Correctness20Richard Harnden
3 Aug 26 i  i ii    ii i    i i   i  i+* Re: Prioritize Performance over Correctness16David Brown
3 Aug 26 i  i ii    ii i    i i   i  ii+* Re: Malicious Computer Architecture4David Brown
3 Aug 26 i  i ii    ii i    i i   i  iii+* Re: Malicious Computer Architecture2David Brown
3 Aug 26 i  i ii    ii i    i i   i  iiii`- Re: Malicious Computer Architecture1Chris M. Thomasson
3 Aug 26 i  i ii    ii i    i i   i  iii`- Re: Malicious Computer Architecture1Chris M. Thomasson
3 Aug 26 i  i ii    ii i    i i   i  ii+* Johnny Depp prevention [Windows 11 etc...] (Was: Malicious Computer Architecture)5Mild Shock
3 Aug 26 i  i ii    ii i    i i   i  iii`* But how can you deploy. when its ROM? (Was: Johnny Depp prevention [Windows 11 etc...])4Mild Shock
7 Aug13:37 i  i ii    ii i    i i   i  iii `* GPU Elasticity: Collective Communications Libraries (Was: But how can you deploy. when its ROM?)3Mild Shock
7 Aug17:07 i  i ii    ii i    i i   i  iii  `* What are Flits and Phits? [Network on a Chip] (Re: GPU Elasticity: Collective Communications Libraries)2Mild Shock
9 Aug20:22 i  i ii    ii i    i i   i  iii   `- Cristallina: Thank you for the Beam (Re: What are Flits and Phits? [Network on a Chip])1Mild Shock
3 Aug 26 i  i ii    ii i    i i   i  ii+* Re: Malicious Computer Architecture4Aidan Kehoe
4 Aug19:10 i  i ii    ii i    i i   i  iii+- Re: Malicious Computer Architecture1Richard Harnden
6 Aug22:55 i  i ii    ii i    i i   i  iii+- Re: Malicious Computer Architecture1Kaz Kylheku
6 Aug23:01 i  i ii    ii i    i i   i  iii`- Re: Malicious Computer Architecture1Aidan Kehoe
4 Aug13:58 i  i ii    ii i    i i   i  ii`* A Case for Impurity: The Applied Pi Calculus (Re: Malicious Computer Architecture)2Mild Shock
4 Aug14:10 i  i ii    ii i    i i   i  ii `- The Sandcastle of Paul Taraus Interactors (Re: A Case for Impurity: The Applied Pi Calculus)1Mild Shock
3 Aug 26 i  i ii    ii i    i i   i  i+- Re: Prioritize Performance over Correctness1Keith Thompson
3 Aug 26 i  i ii    ii i    i i   i  i`* Re: Prioritize Performance over Correctness2Chris M. Thomasson
4 Aug 26 i  i ii    ii i    i i   i  i `- Re: Prioritize Correctness Over Performance1Lawrence D’Oliveiro
3 Aug 26 i  i ii    ii i    i i   i  `* Re: Prioritize Performance over Correctness3Keith Thompson
3 Aug 26 i  i ii    ii i    i i   i   +- Re: Prioritize Performance over Correctness1David Brown
3 Aug 26 i  i ii    ii i    i i   i   `- Re: Prioritize Performance over Correctness1Chris M. Thomasson
4 Aug 26 i  i ii    ii i    i i   `* Re: Prioritize Performance over Correctness3James Kuyper
3 Aug 26 i  i ii    ii i    i `* Re: Prioritize Performance over Correctness2Keith Thompson
30 Jul 26 i  i ii    ii i    `- Re: Prioritize Performance over Correctness1Keith Thompson
29 Jul 26 i  i ii    ii `- Re: Prioritize Performance over Correctness1Chris M. Thomasson
29 Jul 26 i  i ii    i`- Re: Prioritize Performance over Correctness1James Kuyper
27 Jul 26 i  i ii    `- Re: Prioritize Performance over Correctness1BGB
24 Jul 26 i  i i`* Re: Prioritize Performance over Correctness19Janis Papanagnou
26 Jul 26 i  i `- Re: Prioritize Performance over Correctness1BGB
23 Jul 26 i  `- Re: Prioritize Performance over Correctness1Janis Papanagnou
28 Jul 26 +* Re: Multics( Re: Prioritize Performance over Correctness)7Dan Cross
31 Jul 26 `- Re: Prioritize Performance over Correctness1Steven M. O'Neill

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal