Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

As I understand it, the bswap optimization doesn't pattern-match for that specific code (and it works for any equivalent shift/mask code); it analyzes the flow of the bits to figure out the final bit pattern relative to the original, realizes the whole expression had the effect of a bswap, and substitutes a bswap.


Actually, in LLVM's case it really is just explicitly checking for a few specific bswap patterns rather than doing anything fancy:

https://github.com/llvm-mirror/llvm/blob/master/lib/Transfor...


Yes, that's called pattern matching.


Not the kind of pattern matching they were talking about.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: