frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Pop Goes the Population Count?

https://xania.org/202512/11-pop-goes-the-weasel-er-count
59•hasheddan•1d ago

Comments

bombcar•1d ago
Isn't this the instruction that apparently the NSA asked for?
adgjlsfhk1•1d ago
yeah. They understood how useful computing on bits can be before anyone else.
pklausler•1d ago
It goes back to the CDC 6600 at least, and is most often seen as part of Hamming distance computation (pop(xor(x,y))). But it turns out to be really useful for other things (trailing zero count), and worth having in hardware since the software sequence is a ~dozen instructions for 64 bits.
kens•1d ago
I did a lot of research on this [1]. I got confirmation from Robert Garner (architect of the SPARC processor) that the NSA did indeed ask for the population count instruction. His story of meeting with the NSA is pretty amusing [2].

[1] https://retrocomputing.stackexchange.com/a/8666/4158

[2] https://archive.computerhistory.org/resources/access/text/20...

majke•1d ago
Hey! Popcount used to be my favorite instruction. Now I think I prefer LOP3 though :)
azinman2•16h ago
Could you explain more please?
wat10000•1d ago
There's a fun approach where do the computation as a tree in parallel. You do a little masking and shifting to add all the even-numbered bits to all the odd-numbered bits, and come up with a set of (assuming we're working on a 64-bit value) 32 partial sums of 2 bits each. Then you add pairs of those to get 16 partial sums of 4 bits each, and so forth until you get to the top. This requires six sums, plus shifts and masks for each one.

I don't know if compilers are able to detect this and compile it down to a single instruction, though.

mattgodbolt•1d ago
All that and more: https://graphics.stanford.edu/~seander/bithacks.html#CountBi... :)
taeric•1d ago
Somewhat related, "Gosper's hack" is a fun way to loop through all of the values that have the same number of 1s.
dhosek•1d ago
I still find it wild that Godbolt is his actual name and not some cool term used for the tool to see what compiler output looks like.
silisili•1d ago
Same! I always assumed it was the name of the tool until I found out it was a person not long ago.

Maybe a bit of a stretch, but I could see it fitting - https://en.wikipedia.org/wiki/Aptronym

burnt-resistor•1d ago
I <3 [AT]BM and BMI[12], and functional-equivalency matching with cost minimization optimization compiler passes.

I wish GCC and LLVM had compiler passes to semi/automagically "vectorize" hot sections using SIMD, i.e., magic transformation of UTF-8 conversion, regex matching, and string functions.

thefaux•1d ago
As impressive as this analysis is by the compiler, I shudder to think how much time the compiler spends doing these kinds of optimizations. In my opinion, a better architecture would be for the compiler to provide a separate analysis tool that suggests source level changes for these kinds of optimizations. It could alert you that the loop could be replaced with a popcount (and optionally make the textual replacement in the source code for you). Then you pay the cost of the optimization once and have the benefit of clarity about what your code _actually_ runs at runtime instead of the compiler transparently pulling the rug out from underneath you when run with optimizations.

Side note: many years ago I wrote the backend for a private global surveillance system that has almost surely tracked the physical location of anyone reading this. We could efficiently track how often a device had been seen at a location in the prior 64 (days|weeks|months) in just 192 bytes and use popcount to compute the value. I am not proud that I built this.

adgjlsfhk1•1d ago
Especially in languages that allow generic programming, the right thing to do will be context dependent.
Quekid5•1d ago
The issue is that many optimization opportunities only appear after monomorphization, inlining, de-virtualization, etc. etc.

Not that you couldn't do source level analysis as you suggest... it just wouldn't be effective in many cases.

It would also be 'unstable' in the sense that it might depend on architecture, etc.

OpenAI are quietly adopting skills, now available in ChatGPT and Codex CLI

https://simonwillison.net/2025/Dec/12/openai-skills/
380•simonw•10h ago•214 comments

macOS 26.2 enables fast AI clusters with RDMA over Thunderbolt

https://developer.apple.com/documentation/macos-release-notes/macos-26_2-release-notes#RDMA-over-...
399•guiand•13h ago•212 comments

Photographer Built a Medium-Format Rangefinder, and So Can You

https://petapixel.com/2025/12/06/this-photographer-built-an-awesome-medium-format-rangefinder-and...
26•shinryuu•6d ago•2 comments

1300 Still Images from the Animated Films of Hayao Miyazaki's Studio Ghibli (2023)

https://www.ghibli.jp/info/013772/
125•vinhnx•7h ago•30 comments

Beautiful Abelian Sandpiles

https://eavan.blog/posts/beautiful-sandpiles.html
40•eavan0•3d ago•7 comments

GNU Unifont

https://unifoundry.com/unifont/index.html
219•remywang•13h ago•60 comments

Sick of smart TVs? Here are your best options

https://arstechnica.com/gadgets/2025/12/the-ars-technica-guide-to-dumb-tvs/
298•fleahunter•21h ago•277 comments

Rats Play DOOM

https://ratsplaydoom.com/
291•ano-ther•14h ago•105 comments

Ferrari's Formula 1 Handovers: Handovers from Surgery to Intensive Care 2008;pdf

https://gwern.net/doc/technology/2008-sower.pdf
53•bookofjoe•6d ago•21 comments

Show HN: Tiny VM sandbox in C with apps in Rust, C and Zig

https://github.com/ringtailsoftware/uvm32
133•trj•12h ago•9 comments

A 'toaster with a lens': The story behind the first handheld digital camera

https://www.bbc.com/future/article/20251205-how-the-handheld-digital-camera-was-born
12•selvan•4d ago•3 comments

Gild Just One Lily

https://www.smashingmagazine.com/2025/04/gild-just-one-lily/
21•serialx•4d ago•4 comments

Show HN: I made a spreadsheet where formulas also update backwards

https://victorpoughon.github.io/bidicalc/
136•fouronnes3•1d ago•69 comments

Ensuring a National Policy Framework for Artificial Intelligence

https://www.whitehouse.gov/presidential-actions/2025/12/eliminating-state-law-obstruction-of-nati...
114•andsoitis•1d ago•183 comments

Easel Now Has Stencils

https://easel.games/blog/2025-dec-update
11•BSTRhino•4d ago•2 comments

Go is portable, until it isn't

https://simpleobservability.com/blog/go-portable-until-isnt
83•khazit•5d ago•67 comments

So What Should We Call This – A Grue Jay?

https://cns.utexas.edu/news/research/so-what-should-we-call-grue-jay
50•surprisetalk•5d ago•21 comments

Apple has locked my Apple ID, and I have no recourse. A plea for help

https://hey.paris/posts/appleid/
516•parisidau•5h ago•249 comments

50 years of proof assistants

https://lawrencecpaulson.github.io//2025/12/05/History_of_Proof_Assistants.html
88•baruchel•10h ago•13 comments

Freeing a Xiaomi humidifier from the cloud

https://0l.de/blog/2025/11/xiaomi-humidifier/
89•stv0g•1d ago•41 comments

Koralm Railway

https://infrastruktur.oebb.at/en/projects-for-austria/railway-lines/southern-line-vienna-villach/...
304•fzeindl•23h ago•183 comments

Computer Animator and Amiga fanatic Dick Van Dyke turns 100

15•ggm•2h ago•6 comments

The Coming Need for Formal Specification

https://benjamincongdon.me/blog/2025/12/12/The-Coming-Need-for-Formal-Specification/
29•todsacerdoti•7h ago•20 comments

Google Removes Sci-Hub Domains from U.S. Search Results Due to Dated Court Order

https://torrentfreak.com/google-removes-sci-hub-domains-from-u-s-search-results-due-to-dated-cour...
123•t-3•7h ago•25 comments

Capsudo: Rethinking sudo with object capabilities

https://ariadne.space/2025/12/12/rethinking-sudo-with-object-capabilities.html
64•fanf2•12h ago•35 comments

Slax: Live Pocket Linux

https://www.slax.org/
27•Ulf950•4d ago•4 comments

Doxers Posing as Cops Are Tricking Big Tech Firms into Sharing People's Data

https://www.wired.com/story/doxers-posing-as-cops-are-tricking-big-tech-firms-into-sharing-people...
70•iamnothere•5h ago•21 comments

The Checkerboard

https://99percentinvisible.org/episode/650-the-checkerboard/
48•thread_id•9h ago•15 comments

String theory inspires a brilliant, baffling new math proof

https://www.quantamagazine.org/string-theory-inspires-a-brilliant-baffling-new-math-proof-20251212/
144•ArmageddonIt•18h ago•144 comments

Pg_ClickHouse: A Postgres extension for querying ClickHouse

https://clickhouse.com/blog/introducing-pg_clickhouse
94•spathak•2d ago•34 comments