[Bug middle-end/19988] [4.3/4.4/4.5 Regression] pessimizes fp multiply-add/subtract combo
--- Comment #24 from rguenth at gcc dot gnu dot org 2010-01-21 12:15 --- Subject: Bug 19988 Author: rguenth Date: Thu Jan 21 12:15:40 2010 New Revision: 156152 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=156152 Log: 2010-01-21 Richard Guenther PR middle-end/19988 * fold-const.c (negate_expr_p): Pretend only negative real constants are easily negatable. * gcc.dg/pr19988.c: New testcase. Added: trunk/gcc/testsuite/gcc.dg/pr19988.c Modified: trunk/gcc/ChangeLog trunk/gcc/fold-const.c trunk/gcc/testsuite/ChangeLog -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19988
[Bug middle-end/19988] [4.3/4.4/4.5 Regression] pessimizes fp multiply-add/subtract combo
-- rguenth at gcc dot gnu dot org changed: What|Removed |Added BugsThisDependsOn|42802 | AssignedTo|unassigned at gcc dot gnu |rguenth at gcc dot gnu dot |dot org |org Status|NEW |ASSIGNED Last reconfirmed|2005-08-17 12:43:49 |2010-01-19 11:38:04 date|| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19988
[Bug middle-end/19988] [4.3/4.4/4.5 Regression] pessimizes fp multiply-add/subtract combo
--- Comment #23 from rguenth at gcc dot gnu dot org 2010-01-18 15:16 --- And a fix along comment #14 would be (untested, but of course fixes the testcase): Index: gcc/fold-const.c === --- gcc/fold-const.c(revision 156009) +++ gcc/fold-const.c(working copy) @@ -1129,10 +1129,14 @@ negate_expr_p (tree t) && TYPE_OVERFLOW_WRAPS (type)); case FIXED_CST: -case REAL_CST: case NEGATE_EXPR: return true; +case REAL_CST: + /* We want to canonicalize to positive real constants. Pretend + that only negative ones can be easily negated. */ + return REAL_VALUE_NEGATIVE (TREE_REAL_CST (t)); + case COMPLEX_CST: return negate_expr_p (TREE_REALPART (t)) && negate_expr_p (TREE_IMAGPART (t)); looks appealing, but let's check for fallout. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19988
[Bug middle-end/19988] [4.3/4.4/4.5 Regression] pessimizes fp multiply-add/subtract combo
--- Comment #22 from rguenth at gcc dot gnu dot org 2010-01-16 21:42 --- Created an attachment (id=19627) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19627&action=view) fixed patch Fixed patch that actually bootstraps. -- rguenth at gcc dot gnu dot org changed: What|Removed |Added Attachment #19626|0 |1 is obsolete|| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19988
[Bug middle-end/19988] [4.3/4.4/4.5 Regression] pessimizes fp multiply-add/subtract combo
--- Comment #21 from rguenth at gcc dot gnu dot org 2010-01-16 20:30 --- (In reply to comment #20) > It obviously could do the same. It all depends on the answer to this > question: >Do we want to deal with this via canonicalization of expressions, and if >yes, then also on the outcome of our discussion of where that should happen >(fold or special code in VN dealing with just value numbers). > If no, then something like your patch can be done. > > In this case I'm leaning towards Paolo (comment #14), we possibly might want > to canonicalize towards fewer constants (hence towards positive constants), > when otherwise the number of operations remains the same (hence treating > PLUS_EXPR and MINUS_EXPR as equivalent). Yes, that sounds reasonable. Note that most existing foldings only look for PLUS_EXPR once the 2nd operand is a constant, so auditing of them is required. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19988
[Bug middle-end/19988] [4.3/4.4/4.5 Regression] pessimizes fp multiply-add/subtract combo
--- Comment #20 from matz at gcc dot gnu dot org 2010-01-16 20:10 --- It obviously could do the same. It all depends on the answer to this question: Do we want to deal with this via canonicalization of expressions, and if yes, then also on the outcome of our discussion of where that should happen (fold or special code in VN dealing with just value numbers). If no, then something like your patch can be done. In this case I'm leaning towards Paolo (comment #14), we possibly might want to canonicalize towards fewer constants (hence towards positive constants), when otherwise the number of operations remains the same (hence treating PLUS_EXPR and MINUS_EXPR as equivalent). -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19988
[Bug middle-end/19988] [4.3/4.4/4.5 Regression] pessimizes fp multiply-add/subtract combo
--- Comment #19 from rguenth at gcc dot gnu dot org 2010-01-16 19:15 --- What does (can) the new VN do here? -- rguenth at gcc dot gnu dot org changed: What|Removed |Added CC||matz at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19988
[Bug middle-end/19988] [4.3/4.4/4.5 Regression] pessimizes fp multiply-add/subtract combo
--- Comment #18 from rguenth at gcc dot gnu dot org 2010-01-16 19:09 --- Created an attachment (id=19626) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19626&action=view) VN based fix This extends the value-numberers value insertion facility to handle this special case. Well, it needs TLC obviously - it was just a quick hack. We now end up with : D.2649_2 = y_1(D) * 1.23395803356966916908277198672294617e-1; D.2650_4 = D.2649_2 + x_3(D); pretmp.1_9 = -D.2649_2; D.2652_6 = x_3(D) + pretmp.1_9; D.2648_7 = D.2650_4 * D.2652_6; return D.2648_7; probably the same as 3.3. Another interesting bit is that we do not ever merge the negation into the addition on the tree level (we do that only during combine). -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19988
[Bug middle-end/19988] [4.3/4.4/4.5 Regression] pessimizes fp multiply-add/subtract combo
--- Comment #17 from rguenth at gcc dot gnu dot org 2009-08-04 12:26 --- GCC 4.3.4 is being released, adjusting target milestone. -- rguenth at gcc dot gnu dot org changed: What|Removed |Added Target Milestone|4.3.4 |4.3.5 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19988
[Bug middle-end/19988] [4.3/4.4/4.5 Regression] pessimizes fp multiply-add/subtract combo
--- Comment #16 from jsm28 at gcc dot gnu dot org 2009-03-31 16:45 --- Closing 4.2 branch. -- jsm28 at gcc dot gnu dot org changed: What|Removed |Added Summary|[4.2/4.3/4.4/4.5 Regression]|[4.3/4.4/4.5 Regression] |pessimizes fp multiply- |pessimizes fp multiply- |add/subtract combo |add/subtract combo Target Milestone|4.2.5 |4.3.4 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19988