News for hackers. Stuff that matters.
Re:Branch prediction: fundamentals every programmer need not... by lostmsu on Sunday February 02, 2020 @03:57PM (#22219363)
I love the explanation, but why did the guy suggest a complicated bit work instead of just doing sum += arr[i] > 128 ? arr[i] : 0 is beyond me.
Re:Branch prediction: fundamentals every programmer need not... by ncmncm on Sunday February 02, 2020 @04:14PM (#22219468)
That would not evoke the behavior he wanted to call attention to.
Re:Branch prediction: fundamentals every programmer need not... by rabryan35 on Sunday February 02, 2020 @08:45PM (#22220793)
Theres still a conditional branch in that statement
Re:Branch prediction: fundamentals every programmer need not... by lostmsu on Monday February 03, 2020 @03:05AM (#22222318)
That depends on the compiler, and I'd expect most to optimize this into a cmov