[Bug tree-optimization/84841] [7/8 Regression] ICE: tree check: expected ssa_name, have real_cst in rewrite_expr_tree_parallel, at tree-ssa-reassoc.c:4624
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84841 --- Comment #7 from Jakub Jelinek --- Author: jakub Date: Fri Mar 16 08:06:41 2018 New Revision: 258586 URL: https://gcc.gnu.org/viewcvs?rev=258586=gcc=rev Log: PR tree-optimization/84841 * tree-ssa-reassoc.c (INTEGER_CONST_TYPE): Change to 1 << 4 from 1 << 3. (FLOAT_ONE_CONST_TYPE): Define. (constant_type): Return FLOAT_ONE_CONST_TYPE for -1.0 and 1.0. (sort_by_operand_rank): Put entries with higher constant_type last rather than first to match comments. * gcc.dg/pr84841.c: New test. Added: trunk/gcc/testsuite/gcc.dg/pr84841.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-ssa-reassoc.c
[Bug tree-optimization/84841] [7/8 Regression] ICE: tree check: expected ssa_name, have real_cst in rewrite_expr_tree_parallel, at tree-ssa-reassoc.c:4624
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84841 Jakub Jelinek changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org --- Comment #6 from Jakub Jelinek --- Created attachment 43670 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43670=edit gcc8-pr84841.patch Untested fix. The problem actually aren't the multiple REAL_CSTs, but the artificial -1.0 added by try_special_add_to_ops which isn't reflected in the original IL. We rely on that one to be merged with other constants. And, const_binop generally fails only for inexact computations, multiplication by -1.0 or 1.0 should never be inexact. So this patch just makes sure we sort -1.0 (and 1.0 which has similar properties) last. Another possibility would be to try harder if some const_binop fails, up to O(n^2) attempts where n is the number of REAL_CSTs at the end of the ops list. Even with -frounding-math or the IBM long double, we can be successful with some foldings and not others. Is that worth it though? And, seems the sorting wasn't matching the comment: /* We want integer ones to end up last no matter what, since they are the ones we can do the most with. */ I must say I fail to see when we'd have constants of different types in the same ops list, but the documentation says sort integers (i.e. the highest constant_type values) last, but sorting function did the opposite.
[Bug tree-optimization/84841] [7/8 Regression] ICE: tree check: expected ssa_name, have real_cst in rewrite_expr_tree_parallel, at tree-ssa-reassoc.c:4624
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84841 --- Comment #5 from Jakub Jelinek --- On the other side, the assumption that +/* of two REAL_CSTs can be always folded isn't false just for -frounding-math, but also e.g. with IBM long double (aka composite mode) and no -funsafe-math-optimizations. So e.g. long double foo (long double x, long double y) { long double a = 10e50; long double b = 10e-50; a = a + b; a = a + x; a = a + y; return a; } with -mlong-double-128 -O2 -fassociative-math -fno-trapping-math -fno-signed-zeros --param tree-reassoc-width=2 also has 2 REAL_CSTs in there that can't be folded together.
[Bug tree-optimization/84841] [7/8 Regression] ICE: tree check: expected ssa_name, have real_cst in rewrite_expr_tree_parallel, at tree-ssa-reassoc.c:4624
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84841 Jakub Jelinek changed: What|Removed |Added CC||jakub at gcc dot gnu.org --- Comment #4 from Jakub Jelinek --- It is indeed a non-sensical combination, but I think last time we've determined it isn't that easy to diagnose and/or silently fix up, the toplev.c diagnostics can be bypassed through optimize attribute. A quick hack out of this would be to add !flag_rounding_math to can_reassociate_p next to flag_associative_math.
[Bug tree-optimization/84841] [7/8 Regression] ICE: tree check: expected ssa_name, have real_cst in rewrite_expr_tree_parallel, at tree-ssa-reassoc.c:4624
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84841 Richard Biener changed: What|Removed |Added Priority|P3 |P2
[Bug tree-optimization/84841] [7/8 Regression] ICE: tree check: expected ssa_name, have real_cst in rewrite_expr_tree_parallel, at tree-ssa-reassoc.c:4624
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84841 --- Comment #3 from Richard Biener --- At least latent on the GCC 7 branch and earlier. /* We start expression rewriting from the top statements. So, in this loop we create a full list of statements we will work with. */ stmts[stmt_num - 1] = stmt; for (i = stmt_num - 2; i >= 0; i--) stmts[i] = SSA_NAME_DEF_STMT (gimple_assign_rhs1 (stmts[i+1])); assumes there are no unfolded CST +* CST ops in the IL. OTOH we shouldn't rewrite any exprs with -frounding-math anyway? That is, -fassociative-math and -frounding-math are (again) seemingly in conflict?
[Bug tree-optimization/84841] [7/8 Regression] ICE: tree check: expected ssa_name, have real_cst in rewrite_expr_tree_parallel, at tree-ssa-reassoc.c:4624
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84841 Marek Polacek changed: What|Removed |Added Target Milestone|--- |7.4 Summary|[8 Regression] ICE: tree|[7/8 Regression] ICE: tree |check: expected ssa_name, |check: expected ssa_name, |have real_cst in|have real_cst in |rewrite_expr_tree_parallel, |rewrite_expr_tree_parallel, |at tree-ssa-reassoc.c:4624 |at tree-ssa-reassoc.c:4624