News for hackers. Stuff that matters.
Re:Impact of Undefined Behavior on Performance by hairtuq on Friday July 09, 2021 @02:12PM (#27786686)
You don't necessarily need a wider type (which might be slower to work with), you can just calculate (n|1) * ((n+1)/2). Clang does something much more complicated, probably because for it is just a special case of some much more general optimization.
Re:Impact of Undefined Behavior on Performance by CJefferson on Saturday July 10, 2021 @09:54AM (#27793367)
That's a neat trick! -- I was trying to figure out how to handle the fact I didn't know which of n and n+1 was even.