Control Flow Merging: A Compiler Transformation to Mitigate Branch Misprediction by Branch Elimination
| dc.contributor.author | Ramachandra Sharma, Srinivasan | en |
| dc.contributor.committeechair | Sundararajah, Kirshanthan | en |
| dc.contributor.committeemember | Gulzar, Muhammad Ali | en |
| dc.contributor.committeemember | Jian, Xun | en |
| dc.contributor.department | Computer Science and#38; Applications | en |
| dc.date.accessioned | 2025-08-01T08:00:43Z | en |
| dc.date.available | 2025-08-01T08:00:43Z | en |
| dc.date.issued | 2025-07-31 | en |
| dc.description.abstract | Modern superscalar processors have a high theoretical throughput, being capable of executing multiple instructions per clock cycle. In practice, however, this peak is rarely reached because data, structural, and control flow hazards can stall the pipeline and interrupt execution. Branch prediction is widely adopted in modern architectures to mitigate control flow hazards, yet even sophisticated predictors struggle to handle branches driven by random data. Each misprediction flushes speculative instructions and restarts execution on the correct path, making branch mispredictions a major performance bottleneck. Existing compiler solutions, such as outcome pre-computation and simple predication, are effective only for loop-invariant conditions or small side-effect-free branches. This work introduces Control Flow Merging (CFM), a compiler transformation that eliminates branches by converting control dependencies into data dependencies. CFM systematically replaces if and if-then-else regions with semantically equivalent, predicated instruction sequences, even when handling operations with side effects. Our work targets branch elimination at the compiler level by converting control flow dependencies into dataflow. We introduce the Control Flow Merging (CFM) pass for branch removal which replaces if and if-then-else regions with predicated instructions, while maintaining semantics and safety, even in the presence of instructions with side effects and implement it in LLVM 14. We also evaluate its impact on real-world benchmarks. Our experiments show that CFM can reduce branch mispredictions by up to 99 % and improve performance. Across the entire benchmark set, the pass delivers up to 53x speedup in the best case, and a geometric-mean speedup of 1.57×. | en |
| dc.description.abstractgeneral | Modern computer processors are built to perform many tasks at once to run programs faster. However, these processors often run into delays caused by having to guess the path a program will take next—especially when decisions depend on unpredictable data, like user input or random values. When the prediction is incorrect, the processor must discard the speculative work and restart from the correct path, leading to delays. While hardware improvements have tried to make these guesses more accurate, they still fall short in many real-world situations. Some programming tools also try to help, but they only work in very limited cases. This research introduces a new tool called Control Flow Merging (CFM), which helps the computer avoid making these guesses in the first place. Instead of guessing, CFM rewrites programs so that both possible paths can be handled safely without making a decision at all. This technique is added into a compiler commonly used for building programs and is tested on many common software workloads. The results show that CFM can significantly reduce delays and make programs run faster by up to 53 times faster in the best case. Overall, this work shows that smart programming tools can help computers make fewer mistakes and work more efficiently, even when working with unpredictable data | en |
| dc.description.degree | Master of Science | en |
| dc.format.medium | ETD | en |
| dc.identifier.other | vt_gsexam:44400 | en |
| dc.identifier.uri | https://hdl.handle.net/10919/136935 | en |
| dc.language.iso | en | en |
| dc.publisher | Virginia Tech | en |
| dc.rights | Creative Commons Attribution 4.0 International | en |
| dc.rights.uri | http://creativecommons.org/licenses/by/4.0/ | en |
| dc.subject | Control Flow Merging | en |
| dc.subject | Compiler Optimization | en |
| dc.title | Control Flow Merging: A Compiler Transformation to Mitigate Branch Misprediction by Branch Elimination | en |
| dc.type | Thesis | en |
| thesis.degree.discipline | Computer Science & Applications | en |
| thesis.degree.grantor | Virginia Polytechnic Institute and State University | en |
| thesis.degree.level | masters | en |
| thesis.degree.name | Master of Science | en |
Files
Original bundle
1 - 1 of 1
Loading...
- Name:
- Ramachandra_Sharma_S_T_2025.pdf
- Size:
- 1.11 MB
- Format:
- Adobe Portable Document Format