[Bug tree-optimization/108540] [13 Regression] Frange miscompilation of ruby since r13-3261
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Jan 26 11:27:49 GMT 2023
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108540
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
This goes wrong during thread1 pass I think.
Before that we have in the IL early exits for x != 42, d NAN or d +-INF, and
then:
<bb 6> [local count: 96926676]:
if (d_16(D) == 0.0)
goto <bb 7>; [50.00%]
else
goto <bb 8>; [50.00%]
<bb 7> [local count: 48463338]:
_2 = __builtin_signbit (d_16(D));
if (_2 != 0)
goto <bb 9>; [50.00%]
else
goto <bb 8>; [50.00%]
<bb 8> [local count: 72695007]:
<bb 9> [local count: 164282501]:
# RANGE [frange] double [-0.0 (-0x0.0p+0),
1.79769313486231570814527423731704356798070567525844996599e+308
(0x0.fffffffffffff8p+1024)]
# d_7 = PHI <d_17(5), -0.0(7), d_16(D)(8)>
# RANGE [irange] char [0, 0][45, 45] NONZERO 0x2d
# sign_10 = PHI <45(5), 45(7), 0(8)>
_3 = ch_18(D) == 97;
_4 = ch_18(D) == 65;
_5 = _3 | _4;
if (_5 != 0)
goto <bb 10>; [50.00%]
else
goto <bb 13>; [50.00%]
<bb 10> [local count: 82141250]:
_13 = VIEW_CONVERT_EXPR<long long int>(d_7);
_24 = _13 < 0;
# RANGE [irange] int [0, 1] NONZERO 0x1
_25 = (int) _24;
if (d_7 == 0.0)
goto <bb 12>; [50.00%]
else
goto <bb 11>; [50.00%]
<bb 11> [local count: 41070625]:
<bb 12> [local count: 82141250]:
# PT =
# cp_8 = PHI <"WRONG"(11), "ZERO"(10)>
(#c1 testcase at -O2 on x86_64-linux in sra dump). The path through the IL on
arguments the function is called with is
d_16(D) == 0.0, __builtin_signbit (d_16(D)) is non-zero and so d_7 is -0.0,
sign_10 45, then _5 is non-zero, d_7 == 0.0 is
again true and so cp_8 is "ZERO".
But in thread1 this changes:
<bb 6> [local count: 96926676]:
if (d_16(D) == 0.0)
goto <bb 7>; [50.00%]
else
goto <bb 10>; [50.00%]
<bb 7> [local count: 48463338]:
_2 = __builtin_signbit (d_16(D));
if (_2 != 0)
goto <bb 8>; [50.00%]
else
goto <bb 10>; [50.00%]
<bb 8> [local count: 24231669]:
# RANGE [frange] double [-0.0 (-0x0.0p+0),
1.79769313486231570814527423731704356798070567525844996599e+308
(0x0.fffffffffffff8p+1024)]
# d_11 = PHI <-0.0(7)>
# RANGE [irange] char [0, 0][45, 45] NONZERO 0x2d
# sign_26 = PHI <45(7)>
_27 = ch_18(D) == 97;
_28 = ch_18(D) == 65;
_29 = _27 | _28;
if (_29 != 0)
goto <bb 9>; [50.00%]
else
goto <bb 14>; [50.00%]
<bb 9> [local count: 12115835]:
_30 = VIEW_CONVERT_EXPR<long long int>(d_11);
_31 = _30 < 0;
# RANGE [irange] int [0, 1] NONZERO 0x1
_32 = (int) _31;
goto <bb 12>; [100.00%]
...
<bb 12> [local count: 41070625]:
# RANGE [irange] char [0, 0][45, 45] NONZERO 0x2d
# sign_33 = PHI <sign_10(11), sign_26(9)>
# RANGE [irange] int [0, 1] NONZERO 0x1
# _35 = PHI <_25(11), _32(9)>
<bb 13> [local count: 82141250]:
# PT =
# cp_8 = PHI <"WRONG"(12), "ZERO"(11)>
Now the path through for the arguments is again d_16(D) == 0.0, signbit
non-zero, d_11 is correctly -0.0 but this is in a threaded block, _29 is
non-zero, but we come into bb 13 from bb 12 and so cp_8 is "WRONG" rather than
"ZERO".
Aldy, can you please have a look?
More information about the Gcc-bugs
mailing list