r/cpp • u/Little-Reflection986 • Feb 16 '26
Favorite optimizations ??
I'd love to hear stories about people's best feats of optimization, or something small you are able to use often!
134
Upvotes
View all comments
Show parent comment
1
u/Successful_Yam_9023 Feb 16 '26 edited Feb 16 '26
I've had more success without such "pretend to be scalar" wrappers, YMMV of course, but that approach maps fairly well to purely-vertical SIMD consisting only of the boring operations, and not so well to anything else (shuffles, reinterpretations that change the number of elements, special operations, horizontal operations..)
E: of course, extra operations can be added to the vector type, but then you get an awkward mix of styles where some operations are expressed in the "fake scalar" way and some by thin wrappers around intrinsics and it's not meaningfully generic in the element type or element count.