I made a bubble sort implementation in C, and was testing its performance when I noticed that the -O3 flag made it run even slower than no flags at all! Meanwhile -O2 was making it run a lot faster as expected. Without optimisations: time ./sort 30000 ./sort 30000 1.82s user 0.00s system 99% cpu 1.816 total -O2: time ./sort 30000 ./sort 30000 1.00s user 0.00s system 99% cpu 1.005 total -O3: time .
![Bubble sort slower with -O3 than -O2 with GCC](https://cdn-ak-scissors.b.st-hatena.com/image/square/98d6f053a97a87156775f60757c60865d0f2c47d/height=288;version=1;width=512/https%3A%2F%2Fcdn.sstatic.net%2FSites%2Fstackoverflow%2FImg%2Fapple-touch-icon%402.png%3Fv%3D73d79a89bded)