https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111522

--- Comment #11 from Mathieu Malaterre <malat at debian dot org> ---
Here is a dead simple reduced version:

```
% cat pr111522.cc
#include <iostream>
#include <cstring>
#pragma GCC push_options
#pragma GCC target "cpu=power10"
float BitCast(int in) {
  float out;
  memcpy(&out, &in, sizeof(out));
  return out;
}
float kNearOneF = BitCast(1065353215);
#pragma GCC pop_options
int main() { std::cout << kNearOneF << std::endl; }
```

You can compare:

g++ -o works -O2 pr111522.cc -Wall -Wextra -Werror -Wfatal-errors

vs

g++ -o fails -flto -O2 pr111522.cc -Wall -Wextra -Werror -Wfatal-errors

For some reason, `-flto` rightfully generates a `xxspltidp` instruction:

(gdb) display/i $pc
1: x/i $pc
=> 0x100000940 <_Z7BitCasti.constprop.0>:       xxspltidp vs1,1065353215

I am not sure I understand the behavior of the non LTO case now...

Reply via email to