branch-prediction Questions

4

On a modern Pentium it is no longer possible to give branching hints to the processor it seems. Assuming that a profiling compiler such as gcc with profile-guided optimization gains information abo...
Magnetometer asked 30/5, 2013 at 11:17

1

I'd like to know how to write efficient jump tables for x64 processors, either in C, C++ or assembly. The input is known in advance, but impossible to predict algorithmically. Assuming I can look a...

4

Solved

I recently read the question here Why is it faster to process a sorted array than an unsorted array? and found the answer to be absolutely fascinating and it has completely changed my outlook on pr...

3

Solved

I have a Compare() function that looks like this: inline bool Compare(bool greater, int p1, int p2) { if (greater) return p1>=p2; else return p1<=p2; } I decided to optimize to avoid bra...
Demurrage asked 2/4, 2013 at 17:6

2

Solved

While answering another question I got curious about this. I'm well aware that if( __builtin_expect( !!a, 0 ) ) { // not likely } else { // quite likely } will make the "quite likely" branch f...
Papism asked 18/3, 2013 at 0:33

5

So from my understanding of delay slots, they occur when a branch instruction is called and the next instruction following the branch also gets loaded from memory. What is the point of this? Wouldn...
Hepatitis asked 13/3, 2013 at 0:50

1

Solved

The GCC manual only shows examples where __builtin_expect() is placed around the entire condition of an 'if' statement. I also noticed that GCC does not complain if I use it, for example, with a t...
Pilchard asked 9/2, 2013 at 2:59

2

Solved

I'm trying to get a good understanding of branch prediction by measuring the time to run loops with predictable branches vs. loops with random branches. So I wrote a program that takes large array...
Salta asked 4/1, 2013 at 5:45

3

Solved

I have this C function: double f(int x) { if (x <= 0) return 0.0; else return x * log(x); } which I am calling in a tight loop, and would like to get rid of the branch to see if it improv...
Stigmatism asked 15/11, 2012 at 17:54

4

Solved

X is true nearly 99.9% of the time but I need to handle Y and Z as well. Although the body of the X condition is empty, I'm thinking it should be faster than potentially checking 2 other conditions...
Papule asked 19/1, 2012 at 21:45

1

Solved

This question and its answer, which was recently tagged as an Epic Answer, has prompted me to wonder; Can I measure the performance of a running application in Windows in terms of its CPU branch pr...
Elver asked 11/7, 2012 at 16:50

1

Solved

Years ago I was learning about x86 assembler, CPU pipelining, cache misses, branch prediction, and all that jazz. It was a tale of two halves. I read about all the wonderful advantages of the leng...

© 2022 - 2024 — McMap. All rights reserved.