News for hackers. Stuff that matters.
Re:Branch predictor: How many “if”s are too many? by rantwasp on Thursday May 06, 2021 @11:03AM (#27064278)
it’s probably a switch on the index (or in this case you could actually have an array and use the index).

I don’t know my compilers that well but if I had to guess I would say there is a good chance this will be optimized away by the compiler.

Re:Branch predictor: How many “if”s are too many? by azalemeth on Friday May 07, 2021 @04:05AM (#27073535)
As pointed out above, gcc ≥11 optimises it to a switch / lookup table (https://godbolt.org/z/PxvGKqGrd).
Re:Branch predictor: How many “if”s are too many? by rantwasp on Friday May 07, 2021 @12:43PM (#27077879)
oh wow. this is really nice. was expecting some sort if gcc documentation or a blog post. got the real deal. thanks for the link