[Bug middle-end/94103] Wrong optimization: reading value of a variable changes its representation for optimizer

2020-03-09 Thread ch3root at openwall dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94103

--- Comment #3 from Alexander Cherepanov  ---
*** Bug 92824 has been marked as a duplicate of this bug. ***

[Bug middle-end/94103] Wrong optimization: reading value of a variable changes its representation for optimizer

2020-03-09 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94103

--- Comment #2 from Andrew Pinski  ---
long double has padding bits on x86_64 so that is not shocking there.

_Decimal3 is a different issue all together.

[Bug middle-end/94103] Wrong optimization: reading value of a variable changes its representation for optimizer

2020-03-09 Thread ch3root at openwall dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94103

--- Comment #1 from Alexander Cherepanov  ---
Example with decimal floating-point:

--
#include 
#include 

int main()
{
_Decimal32 x = 999; // maximum significand
unsigned u;

memcpy(, , sizeof u);
printf("%#08x\n", u);

++*(unsigned char *) // create non-canonical representation of 0
(void)-x;

memcpy(, , sizeof u);
printf("%#08x\n", u);
}
--
$ gcc -std=c2x -pedantic -Wall -Wextra test.c && ./a.out
0x6cb8967f
0x6cb89680
$ gcc -std=c2x -pedantic -Wall -Wextra -O3 test.c && ./a.out
0x6cb8967f
0x3280
--
gcc x86-64 version: gcc (GCC) 10.0.1 20200305 (experimental)
--

Unoptimized results are right, optimized -- wrong.