From: Richard Guenther <richard.guenther@gmail.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Fix ICE in expand_cse_reciprocals (PR tree-optimization/42078)
Date: Wed, 18 Nov 2009 19:56:00 -0000 [thread overview]
Message-ID: <84fc9c000911181153n671e540dtf2a00080c2d750e9@mail.gmail.com> (raw)
In-Reply-To: <20091118173010.GL3047@sunsite.ms.mff.cuni.cz>
On Wed, Nov 18, 2009 at 6:30 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> The recent changes to execute_cse_reciprocals cause ICE on the attached
> testcase. The problem is that the first loop over the imm uses ignores
> debug stmts (which is correct, whether any debug stmts reference arg1 or not
> shouldn't influence the decision on whether to do the transformation or
> not), but the second loop assumes all imm uses are assignments with
> RDIV_EXPR. The following patch fixes it by creating a debug temp 1 / arg1
> and using it instead of arg1 in the debug stmts. Alternatively we could
> drop the debug stmts, dwarf3/4 isn't able to express floating point
> operations anyway (well, in theory it is, but we'd need to implement
> floating point arithmetics using integer operations, which would be really
> huge).
>
> Ok for trunk if bootstrap/regtest passes?
Ugh. Instead of adding so much code I'd prefer to drop the debug stmt.
Ok with that change.
Thanks,
Richard.
> 2009-11-18 Jakub Jelinek <jakub@redhat.com>
>
> PR tree-optimization/42078
> * tree-ssa-math-opts.c (execute_cse_reciprocals): Handle
> updating of debug stmt immediate uses.
>
> * gcc.dg/pr42078.c: New test.
>
> --- gcc/tree-ssa-math-opts.c.jj 2009-11-18 14:56:33.000000000 +0100
> +++ gcc/tree-ssa-math-opts.c 2009-11-18 14:27:37.000000000 +0100
> @@ -534,6 +534,7 @@ execute_cse_reciprocals (void)
> bool md_code, fail;
> imm_use_iterator ui;
> use_operand_p use_p;
> + tree debug_expr_decl = NULL_TREE;
>
> code = DECL_FUNCTION_CODE (fndecl);
> md_code = DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD;
> @@ -568,6 +569,38 @@ execute_cse_reciprocals (void)
>
> FOR_EACH_IMM_USE_STMT (stmt, ui, arg1)
> {
> + if (is_gimple_debug (stmt))
> + {
> + use_operand_p use_p;
> +
> + if (!debug_expr_decl)
> + {
> + gimple def_temp;
> + tree val;
> + gimple_stmt_iterator ngsi;
> +
> + debug_expr_decl = make_node (DEBUG_EXPR_DECL);
> + val = fold_convert (TREE_TYPE (arg1),
> + integer_one_node);
> + val = build2 (RDIV_EXPR, TREE_TYPE (arg1),
> + val, arg1);
> + def_temp
> + = gimple_build_debug_bind (debug_expr_decl,
> + val, stmt1);
> + DECL_ARTIFICIAL (debug_expr_decl) = 1;
> + TREE_TYPE (debug_expr_decl) = TREE_TYPE (arg1);
> + DECL_MODE (debug_expr_decl)
> + = TYPE_MODE (TREE_TYPE (arg1));
> +
> + ngsi = gsi_for_stmt (stmt1);
> + gsi_insert_after (&ngsi, def_temp,
> + GSI_NEW_STMT);
> + }
> + FOR_EACH_IMM_USE_ON_STMT (use_p, ui)
> + SET_USE (use_p, debug_expr_decl);
> + update_stmt (stmt);
> + continue;
> + }
> gimple_assign_set_rhs_code (stmt, MULT_EXPR);
> fold_stmt_inplace (stmt);
> update_stmt (stmt);
> --- gcc/testsuite/gcc.dg/pr42078.c.jj 2009-11-18 14:58:17.000000000 +0100
> +++ gcc/testsuite/gcc.dg/pr42078.c 2009-11-18 14:55:54.000000000 +0100
> @@ -0,0 +1,22 @@
> +/* PR tree-optimization/42078 */
> +/* { dg-do compile } */
> +/* { dg-options "-g -O -ffast-math" } */
> +
> +double sqrt (double x);
> +
> +float
> +foo (float x)
> +{
> + float y = sqrt (x);
> + return x / y;
> +}
> +
> +float
> +bar (float x)
> +{
> + float y = sqrt (x);
> + float a = y;
> + float b = y;
> + float c = y;
> + return x / y;
> +}
>
> Jakub
>
next prev parent reply other threads:[~2009-11-18 19:54 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-18 17:32 Jakub Jelinek
2009-11-18 19:56 ` Richard Guenther [this message]
2009-11-19 0:33 ` Alexandre Oliva
2009-11-19 3:06 ` Alexandre Oliva
2009-11-19 14:21 ` Richard Guenther
2009-11-20 9:44 ` Alexandre Oliva
2009-11-20 11:31 ` Richard Guenther
2009-11-21 6:31 ` Alexandre Oliva
2009-11-21 12:33 ` Richard Guenther
2009-11-20 11:56 ` Paolo Bonzini
2011-06-03 14:33 ` Alexandre Oliva
2012-04-09 6:37 ` Alexandre Oliva
2012-04-12 14:41 ` Richard Guenther
2012-06-13 21:57 ` Alexandre Oliva
2012-06-14 6:59 ` Alexandre Oliva
2009-11-19 13:44 ` Michael Matz
2009-11-19 14:05 ` Jakub Jelinek
2009-11-19 14:15 ` Michael Matz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=84fc9c000911181153n671e540dtf2a00080c2d750e9@mail.gmail.com \
--to=richard.guenther@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).