Re: [Regarding GCOV].gcda:stamp mismatch with notes file
Am 25.04.2024 um 08:45 schrieb Gejoe Daniel via Gcc: Hi team, The following is my query posted but would need more inputs : https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114751 The gcov tool which was working so far seems to fail with our latest branch where gcc is 11.4.0 and hence we wanted to sort this out by getting the right help as early as possible. Awaiting prompt reply. Thanks to the GCC team for all the help ! Regards, Gejoe thanks for looking at that subject - i think i also stumbled over this - thought it was something with my configuration i tried: https://github.com/mozilla/grcov as a temporary solution that worked for me - hoping the fix that maybe comes for you also helps im my case
Re: gcc does not reduce the function call to the result if called function is not static when using -O2, only with -O3, clang and msvc do the optimization also with -O2
Am 05.12.2020 um 14:25 schrieb Eric Botcazou: > can someone explain to me why the -O2 optimizer is not able(allowed) to > reduce this small sample the same way as clang/msvc? Change the name of the function to something else than "main". that works, thanks!
Re: gcc does not reduce the function call to the result if called function is not static when using -O2, only with -O3, clang and msvc do the optimization also with -O2
Am 05.12.2020 um 13:04 schrieb Jan Hubicka: > gcc does not reduce to call result if called function is not static in > -O2 (will do with -O2) > clang and msvc does it also in -O2 regardless of the function beeing > static or not > > can someone explain to me why the -O2 optimizer is not able(allowed) to > reduce this small sample the same way as clang/msvc? GCC is optimizing for size here, so it is more careful with inlning. This is because it knows that function main is called once. If you rename main to something else or add a loop around the call, then it will inline for speed and do same work as clang. Clang (and probaby msvc) does not implement the heuristics that certain functions (static constructors, destructors, main and noreturns) are called once so they probably both optimize for speed. Even when optimizing for size it would be good idea to inline. However the inliner heruistics predicts that it is not. This is because at the inlining time compiler does not see that calee will optimize to constant. The reason is that you store the temporary vlues to array and those are not tracked. If you used scalar variables it would be able to constant fold everything early. Handling this would require either recovering early ipa-sra or adding return functions for values passed by reference. Honza If you rename main... main -> test2 -> test test(unsigned int): moveax, edi cmpedi, 127 jbe.L3 moveax, edi ... test2(unsigned int): moveax, 197 ret main: movedi, 1337 jmptest(unsignedint) gives the expected result and that is enough for my benchmarking tests - thanks
gcc does not reduce the function call to the result if called function is not static when using -O2, only with -O3, clang and msvc do the optimization also with -O2
gcc does not reduce to call result if called function is not static in -O2 (will do with -O2) clang and msvc does it also in -O2 regardless of the function beeing static or not can someone explain to me why the -O2 optimizer is not able(allowed) to reduce this small sample the same way as clang/msvc? x86-64 gcc 10.2 and trunk -O2: https://godbolt.org/z/r3GM57 x86-64 clang trunk and 11.0.0 -O2: https://godbolt.org/z/8hqbz5 x64 msvc v19.27 -O2: https://godbolt.org/z/nv3rWq code to reproduce --- #include // part of run length encoding... static void v32(uint32_t v_, uint8_t* b_, int& s_) { if (v_ <= 0x007FU) { s_ = 1; b_[0] = (uint8_t)v_; return; } if (v_ <= 0x3FFFU) { s_ = 2; b_[1] = (uint8_t)(v_ & 0x7F); b_[0] = (uint8_t)((v_ >> 7) | 0x80); return; } s_ = 3; b_[2] = (uint8_t)(v_ & 0x7F); b_[1] = (uint8_t)((v_ >> 7) | 0x80); b_[0] = (uint8_t)((v_ >> 14) | 0x80); return; } int test(uint32_t v_) { uint8_t b[3]{}; int s=0; v32(v_, b, s); return s+b[0]+b[1]+b[2]; } int main(int argc, char** argv) { return test(1337); // results in 197 // clang reduces the call down to 197 regardless of test beeing static or not //main: # @main // mov eax, 197 // ret // gcc reduces the call only if test is static //main: // mov edi, 1337 // jmp test(unsigned int) }