[Bug tree-optimization/113756] [14 regression] Wrong code at -O2 on x86_64-linux-gnu since r14-2780-g39f117d6c87
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113756 Jakub Jelinek changed: What|Removed |Added Resolution|--- |FIXED Status|ASSIGNED|RESOLVED --- Comment #5 from Jakub Jelinek --- Fixed.
[Bug tree-optimization/113756] [14 regression] Wrong code at -O2 on x86_64-linux-gnu since r14-2780-g39f117d6c87
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113756 --- Comment #4 from GCC Commits --- The master branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:29998cc8a21b3a52f706275923166cd1f95d0555 commit r14-8837-g29998cc8a21b3a52f706275923166cd1f95d0555 Author: Jakub Jelinek Date: Wed Feb 7 10:59:06 2024 +0100 range-op: Fix up ABSU_EXPR handling [PR113756] ABSU_EXPR unary expr is special because it has a signed integer argument and unsigned integer result (of the same precision). The following testcase is miscompiled since ABSU_EXPR handling has been added to range-op because it uses widest_int::from with the result sign (i.e. UNSIGNED) rather than the operand sign (i.e. SIGNED), so e.g. for the 32-bit int argument mask ends up 0xffc1 or something similar and even when it has most significant bit in the precision set, in widest_int (tree-ssa-ccp.cc really should stop using widest_int, but that is I think stage1 task) it doesn't appear to be negative and so bit_value_unop ABSU_EXPR doesn't set the resulting mask/value from oring of the argument and its negation. Fixed thusly, not doing that for GIMPLE_BINARY_RHS because I don't know about a binary op that would need something similar. 2024-02-06 Jakub Jelinek PR tree-optimization/113756 * range-op.cc (update_known_bitmask): For GIMPLE_UNARY_RHS, use TYPE_SIGN (lh.type ()) instead of sign for widest_int::from of lh_bits value and mask. * gcc.dg/pr113756.c: New test.
[Bug tree-optimization/113756] [14 regression] Wrong code at -O2 on x86_64-linux-gnu since r14-2780-g39f117d6c87
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113756 Jakub Jelinek changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org --- Comment #3 from Jakub Jelinek --- Created attachment 57342 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57342=edit gcc14-pr113756.patch Full untested patch.
[Bug tree-optimization/113756] [14 regression] Wrong code at -O2 on x86_64-linux-gnu since r14-2780-g39f117d6c87
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113756 Jakub Jelinek changed: What|Removed |Added CC||jakub at gcc dot gnu.org --- Comment #2 from Jakub Jelinek --- I think the issue is that ABSU_EXPR is an unary operation with signed operand and unsigned result. And update_known_bitmask was using result rather than operand sign to the operand's value/mask, so I think --- gcc/range-op.cc.jj 2024-01-03 11:51:28.199777434 +0100 +++ gcc/range-op.cc 2024-02-06 16:51:55.549127825 +0100 @@ -435,8 +435,10 @@ update_known_bitmask (irange , tree_co bit_value_unop (code, sign, prec, _value, _mask, TYPE_SIGN (lh.type ()), TYPE_PRECISION (lh.type ()), - widest_int::from (lh_bits.value (), sign), - widest_int::from (lh_bits.mask (), sign)); + widest_int::from (lh_bits.value (), + TYPE_SIGN (lh.type ())), + widest_int::from (lh_bits.mask (), + TYPE_SIGN (lh.type (; break; case GIMPLE_BINARY_RHS: bit_value_binop (code, sign, prec, _value, _mask, ought to fix this. Of course even better would be rewrite tree-ssa-cpp.cc to use wide_int rather than widest_int, but I'm afraid that is stage1 material.
[Bug tree-optimization/113756] [14 regression] Wrong code at -O2 on x86_64-linux-gnu since r14-2780-g39f117d6c87
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113756 Richard Biener changed: What|Removed |Added Priority|P3 |P1