Stolen from a hellsite user
Conversation
Notices
-
Embed this notice
Soatok Dreamseeker (soatok@furry.engineer)'s status on Thursday, 19-Feb-2026 14:21:32 JST
Soatok Dreamseeker
-
Embed this notice
Soatok Dreamseeker (soatok@furry.engineer)'s status on Thursday, 19-Feb-2026 14:31:03 JST
Soatok Dreamseeker
@RueNahcMohr Compiler optimizations are black magic
-
Embed this notice
Rue Mohr (ruenahcmohr@infosec.exchange)'s status on Thursday, 19-Feb-2026 14:31:04 JST
Rue Mohr
@soatok wtf did you override "3" with?
-
Embed this notice
Soatok Dreamseeker (soatok@furry.engineer)'s status on Thursday, 19-Feb-2026 16:40:50 JST
Soatok Dreamseeker
@autinerd @RueNahcMohr I mean it's basically the barrett reduction trick lol
-
Embed this notice
Sid (谷思谛) 🐺 (autinerd@chaos.social)'s status on Thursday, 19-Feb-2026 16:40:51 JST
Sid (谷思谛) 🐺
@RueNahcMohr @soatok ah sorry, now I see where you wanted to go 🙈 okay, if this is faster is a good question 😅
-
Embed this notice
Rue Mohr (ruenahcmohr@infosec.exchange)'s status on Thursday, 19-Feb-2026 16:40:52 JST
Rue Mohr
Number to divide by? 3
precision? 64
Shift dividend right. Shift#1
Shift dividend right. Shift#2
Add dividend to accumulator (dividend /4.000000)
Shift dividend right. Shift#3
Shift dividend right. Shift#4
Add dividend to accumulator (dividend /16.000000)
Shift dividend right. Shift#5
Shift dividend right. Shift#6
Add dividend to accumulator (dividend /64.000000)
Shift dividend right. Shift#7
Shift dividend right. Shift#8
Add dividend to accumulator (dividend /256.000000)
Shift dividend right. Shift#9
Shift dividend right. Shift#10
Add dividend to accumulator (dividend /1024.000000)
Shift dividend right. Shift#11
Shift dividend right. Shift#12
Add dividend to accumulator (dividend /4096.000000)
Shift dividend right. Shift#13
Shift dividend right. Shift#14
Add dividend to accumulator (dividend /16384.000000)
Shift dividend right. Shift#15
Shift dividend right. Shift#16
Add dividend to accumulator (dividend /65536.000000)
Shift dividend right. Shift#17
Shift dividend right. Shift#18
Add dividend to accumulator (dividend /262144.000000)
Shift dividend right. Shift#19
Shift dividend right. Shift#20
Add dividend to accumulator (dividend /1048576.000000)
Shift dividend right. Shift#21
Shift dividend right. Shift#22
Add dividend to accumulator (dividend /4194304.000000)
Shift dividend right. Shift#23
Shift dividend right. Shift#24
Add dividend to accumulator (dividend /16777216.000000)
Shift dividend right. Shift#25
Add dividend to accumulator (dividend /33554432.000000)well, thats not faster is it!
:P
:] -
Embed this notice
Sid (谷思谛) 🐺 (autinerd@chaos.social)'s status on Thursday, 19-Feb-2026 16:40:53 JST
Sid (谷思谛) 🐺
@RueNahcMohr @soatok A multiplication is always faster than a division. And thanks to the limited number range in a register, you can in many cases represent division via multiplication. But it doesn't always work.
-
Embed this notice
Rue Mohr (ruenahcmohr@infosec.exchange)'s status on Thursday, 19-Feb-2026 16:40:54 JST
Rue Mohr
@soatok can that really be faster than a shift?surely there is an MMX instruction that does the divide and whatever the next instruction in the program is supposed to do too. :]
-
Embed this notice
Orange Lizard Girlthing (naahrathescaled@furry.engineer)'s status on Thursday, 19-Feb-2026 19:56:41 JST
Orange Lizard Girlthing
@soatok Rust devs wish they could have a compiler like this
Soatok Dreamseeker repeated this. -
Embed this notice
Thomas (horaynarea@chaos.social)'s status on Thursday, 19-Feb-2026 23:18:02 JST
Thomas
@NaahraTheScaled @soatok but… it does? (with optimizations enabled/in release mode)
-
Embed this notice
Soatok Dreamseeker (soatok@furry.engineer)'s status on Friday, 20-Feb-2026 00:37:59 JST
Soatok Dreamseeker
@sophieschmieg laughs in constant-time code
-
Embed this notice
Sophie Schmieg (sophieschmieg@infosec.exchange)'s status on Friday, 20-Feb-2026 00:38:00 JST
Sophie Schmieg
@soatok is it bad that I find the assembly completely reasonable? It's just a Barrett reduction.
Soatok Dreamseeker repeated this. -
Embed this notice
Soatok Dreamseeker (soatok@furry.engineer)'s status on Friday, 20-Feb-2026 00:59:13 JST
Soatok Dreamseeker
@pyromuffin Yep. It's Barrett reduction :D
-
Embed this notice
Kelly MacNeill (pyromuffin@mastodon.gamedev.place)'s status on Friday, 20-Feb-2026 00:59:15 JST
Kelly MacNeill
@soatok integer division is very slow, so this is a reasonable thing to do for division by a constant.
-
Embed this notice
Soatok Dreamseeker (soatok@furry.engineer)'s status on Friday, 20-Feb-2026 01:11:11 JST
Soatok Dreamseeker
@autinerd @RueNahcMohr It's also good for avoiding side-channels:
-
Embed this notice
Craig Stuntz (craigstuntz@discuss.systems)'s status on Friday, 20-Feb-2026 02:01:10 JST
Craig Stuntz
-
Embed this notice
Soatok Dreamseeker (soatok@furry.engineer)'s status on Friday, 20-Feb-2026 02:01:26 JST
Soatok Dreamseeker
@HorayNarea @NaahraTheScaled I apprrciate the shitpost fact checking :3
-
Embed this notice
Thomas (horaynarea@chaos.social)'s status on Friday, 20-Feb-2026 02:43:38 JST
Thomas
@soatok @NaahraTheScaled i have even more facts: it's actually LLVM that doesn't do this specific optimization on -O0, so even clang emits a div unless you explicitly choose to optimize! :D
-
Embed this notice
Rich Felker (dalias@hachyderm.io)'s status on Wednesday, 25-Feb-2026 12:47:59 JST
Rich Felker
@RueNahcMohr @autinerd @soatok I mean it looks like a mul one bit at a time. 🙃
-
Embed this notice
Arcanoraptor (arcanoraptor@furry.engineer)'s status on Friday, 27-Mar-2026 02:08:36 JST
Arcanoraptor
@soatok @RueNahcMohr A long time ago in a simpler time, I was responsible for compiling my org’s copy of a common simulation program written in Fortran. I compiled with --02, and the build tests all failed.
Compiled with --O3 (a superset of O2 with unsafe optimizations) and suddenly everything was correct and the build tests all passed. I have a few users test with known-good benchmark values, and they are happy.
To this day I still have no idea what in the world was going on. It wasn’t even a weird compiler either, it was whatever the stable version of gfortran was at that time. Can confirm, compiler optimizations are black magic.
-
Embed this notice