2023-01-22から1日間の記事一覧

分岐を増やすと速くなる不思議な現象

マイクロベンチマークを書いていたのですが、表題のようなことが起こったのでメモです。 環境 g++ (GCC) 12.1.0 問題のソースコード a.cpp↓ #include <cmath> #include <bit> #include <tuple> std::tuple<unsigned long, double, double> f(double w) { unsigned long n = std::bit_cast<unsigned long>(w) & 3; double x = st</unsigned></unsigned></tuple></bit></cmath>…