[Bug tree-optimization/110176] [11/12/13/14 Regression] wrong code at -Os and above on x86_64-linux-gnu since r11-2446
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110176 --- Comment #10 from GCC Commits --- The master branch has been updated by Richard Biener : https://gcc.gnu.org/g:22dbfbe8767ff4c1d93e39f68ec7c2d5b1358beb commit r14-8658-g22dbfbe8767ff4c1d93e39f68ec7c2d5b1358beb Author: Richard Biener Date: Wed Jan 31 14:40:24 2024 +0100 middle-end/110176 - wrong zext (bool) <= (int) 4294967295u folding The following fixes a wrong pattern that didn't match the behavior of the original fold_widened_comparison in that get_unwidened returned a constant always in the wider type. But here we're using (int) 4294967295u without the conversion applied. Fixed by doing as earlier in the pattern - matching constants only if the conversion was actually applied. PR middle-end/110176 * match.pd (zext (bool) <= (int) 4294967295u): Make sure to match INTEGER_CST only without outstanding conversion. * gcc.dg/torture/pr110176.c: New testcase.
[Bug tree-optimization/110176] [11/12/13/14 Regression] wrong code at -Os and above on x86_64-linux-gnu since r11-2446
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110176 --- Comment #9 from Richard Biener --- With all VARYING we simplify i_19 = (int) _2; _6 = (int) _5; Value numbering stmt = _7 = _6 <= i_19; Applying pattern match.pd:6775, gimple-match-4.cc:1795 Match-and-simplified _6 <= i_19 to 1 where _5 is _Bool and _2 is unsigned int. We match zext <= (int) 4294967295u note that I see Value numbering stmt = _2 = f$0_25; Setting value number of _2 to 4294967295 (changed) Value numbering stmt = i_19 = (int) _2; Match-and-simplified (int) _2 to -1 RHS (int) _2 simplified to -1 Not changing value number of i_19 from VARYING to -1 Making available beyond BB6 i_19 for value i_19 so it's odd we see the constant here, but ... we go (if (TREE_CODE (@10) == INTEGER_CST && INTEGRAL_TYPE_P (TREE_TYPE (@00)) && !int_fits_type_p (@10, TREE_TYPE (@00))) (with { tree min = lower_bound_in_type (TREE_TYPE (@10), TREE_TYPE (@00)); tree max = upper_bound_in_type (TREE_TYPE (@10), TREE_TYPE (@00)); bool above = integer_nonzerop (const_binop (LT_EXPR, type, max, @10)); bool below = integer_nonzerop (const_binop (LT_EXPR, type, @10, min)); } (if (above || below) failing to see that we deal with a relational compare and a sign-change. The original code from fold-const.cc had only INTEGER_TYPE support, r6-4300-gf6c1575958f7bf made it cover all integral types (it half-way supported BOOLEAN_TYPE already). But the issue was latent I think. One notable difference was that I think get_unwidened made sure to convert a constant to the wider type while here we have @10 != @1 and the conversion not applied. We're doing it correct in earlier code: /* ??? The special-casing of INTEGER_CST conversion was in the original code and here to avoid a spurious overflow flag on the resulting constant which fold_convert produces. */ (if (TREE_CODE (@1) == INTEGER_CST) using @1 instead of @10. Correcting that avoids the pattern from triggering in this wrong way.
[Bug tree-optimization/110176] [11/12/13/14 Regression] wrong code at -Os and above on x86_64-linux-gnu since r11-2446
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110176 Richard Biener changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org --- Comment #8 from Richard Biener --- comment#4 suggests the iteration order change just exposes the issue highlighted in comment#1? I will eventually investigate.
[Bug tree-optimization/110176] [11/12/13/14 Regression] wrong code at -Os and above on x86_64-linux-gnu since r11-2446
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110176 --- Comment #7 from Andrew Pinski --- (In reply to Jakub Jelinek from comment #6) > Started with r11-2446-g3e61a2056335ca7d4e2009823efae4ee2dc950ee Note r10-9757-gec97d2e842022a3f112e27d6d8 is the backported to the GCC 10 branch.
[Bug tree-optimization/110176] [11/12/13/14 Regression] wrong code at -Os and above on x86_64-linux-gnu since r11-2446
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110176 Jakub Jelinek changed: What|Removed |Added CC||jakub at gcc dot gnu.org Summary|[11/12/13/14 Regression]|[11/12/13/14 Regression] |wrong code at -Os and above |wrong code at -Os and above |on x86_64-linux-gnu |on x86_64-linux-gnu since ||r11-2446 Keywords|needs-bisection | --- Comment #6 from Jakub Jelinek --- Started with r11-2446-g3e61a2056335ca7d4e2009823efae4ee2dc950ee
[Bug tree-optimization/110176] [11/12/13/14 Regression] wrong code at -Os and above on x86_64-linux-gnu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110176 Richard Biener changed: What|Removed |Added Target Milestone|10.5|11.5 --- Comment #5 from Richard Biener --- GCC 10 branch is being closed.