Skip to main content

Optimizing switch statements: overview and what's new

K.3.201 | Day 1 | 17:20 - 17:40 | Speakers: Filip Kastl

Optimizing switch statements: overview and what's new
A picture of a devroom at FOSDEM 2024

Stream opens at 17:20 (Europe/Brussels)

Get involved in the conversation!Join the chat

Notes

Abstract

During compilation, GCC breaks down switch statements into simpler statements. If a switch has a specific structure, GCC may use techniques that result in faster code. We call these techniques "switch optimizations".

In this talk we'll overview switch optimizations in GCC. Then we'll go into more detail on turning switches into array lookups. In GCC this is called "switch conversion". I'll introduce a new method called "exponential transformation" that I recently contributed to switch conversion. If time permits, we will also discuss potential future work on switch optimizations.

I plan to make this talk beginner-friendly. I myself have started working on GCC just 2 years ago. The talk should however give the audience a good idea about what switch optimizations are available and what they do.

Expected prior knowledge: What is a C switch statement. Very basic understanding of assembly.

Speakers

Filip Kastl

Notice: The placeholder video image is licensed under CC BY-SA 4.0. The original image can be found hereChanges made to the image are: Cropped the image to a new ratio, part of the image was cut off.