From: Richard Biener <rguenther@suse.de>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Richard Henderson <rth@redhat.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Fix complex lowering with inline asm (PR tree-optimization/55921)
Date: Thu, 10 Jan 2013 09:19:00 -0000 [thread overview]
Message-ID: <alpine.LNX.2.00.1301101017580.6889@zhemvz.fhfr.qr> (raw)
In-Reply-To: <20130109234707.GS7269@tucnak.redhat.com>
On Thu, 10 Jan 2013, Jakub Jelinek wrote:
> Hi!
>
> We weren't processing GIMPLE_ASMs that set complex SSA_NAMEs, which lead to
> SSA_NAMEs with NULL SSA_NAME_DEF_STMT, either leading to crashes or silent
> wrong code, depending on --enable-checking. Fixed thusly,
> bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
Ok.
Thanks,
Richard.
> 2013-01-09 Jakub Jelinek <jakub@redhat.com>
>
> PR tree-optimization/55921
> * tree-complex.c (expand_complex_asm): New function.
> (expand_complex_operations_1): Call it for GIMPLE_ASM.
>
> * gcc.c-torture/compile/pr55921.c: New test.
>
> --- gcc/tree-complex.c.jj 2013-01-04 13:44:35.000000000 +0100
> +++ gcc/tree-complex.c 2013-01-09 20:34:55.595674683 +0100
> @@ -1391,6 +1391,36 @@ expand_complex_comparison (gimple_stmt_i
> update_stmt (stmt);
> }
>
> +/* Expand inline asm that sets some complex SSA_NAMEs. */
> +
> +static void
> +expand_complex_asm (gimple_stmt_iterator *gsi)
> +{
> + gimple stmt = gsi_stmt (*gsi);
> + unsigned int i;
> +
> + for (i = 0; i < gimple_asm_noutputs (stmt); ++i)
> + {
> + tree link = gimple_asm_output_op (stmt, i);
> + tree op = TREE_VALUE (link);
> + if (TREE_CODE (op) == SSA_NAME
> + && TREE_CODE (TREE_TYPE (op)) == COMPLEX_TYPE)
> + {
> + tree type = TREE_TYPE (op);
> + tree inner_type = TREE_TYPE (type);
> + tree r = build1 (REALPART_EXPR, inner_type, op);
> + tree i = build1 (IMAGPART_EXPR, inner_type, op);
> + gimple_seq list = set_component_ssa_name (op, false, r);
> +
> + if (list)
> + gsi_insert_seq_after (gsi, list, GSI_CONTINUE_LINKING);
> +
> + list = set_component_ssa_name (op, true, i);
> + if (list)
> + gsi_insert_seq_after (gsi, list, GSI_CONTINUE_LINKING);
> + }
> + }
> +}
>
> /* Process one statement. If we identify a complex operation, expand it. */
>
> @@ -1403,6 +1433,12 @@ expand_complex_operations_1 (gimple_stmt
> complex_lattice_t al, bl;
> enum tree_code code;
>
> + if (gimple_code (stmt) == GIMPLE_ASM)
> + {
> + expand_complex_asm (gsi);
> + return;
> + }
> +
> lhs = gimple_get_lhs (stmt);
> if (!lhs && gimple_code (stmt) != GIMPLE_COND)
> return;
> --- gcc/testsuite/gcc.c-torture/compile/pr55921.c.jj 2013-01-09 20:37:33.643755543 +0100
> +++ gcc/testsuite/gcc.c-torture/compile/pr55921.c 2013-01-09 20:37:07.000000000 +0100
> @@ -0,0 +1,21 @@
> +/* PR tree-optimization/55921 */
> +
> +typedef union
> +{
> + _Complex float cf;
> + long long ll;
> +} ucf;
> +
> +void
> +foo (ucf *in, ucf *out, _Complex float r)
> +{
> + int i;
> + ucf ucf1;
> + _Complex float cf;
> +
> + ucf1.ll = in[i].ll;
> + __asm ("" : "=r" (cf) : "0" (ucf1.ll));
> + cf *= r;
> + __asm ("" : "=r" (ucf1.ll) : "0" (cf));
> + out[i].ll = ucf1.ll;
> +}
>
> Jakub
>
>
--
Richard Biener <rguenther@suse.de>
SUSE / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746
GF: Jeff Hawn, Jennifer Guild, Felix Imend
next prev parent reply other threads:[~2013-01-10 9:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-09 23:47 Jakub Jelinek
2013-01-10 9:19 ` Richard Biener [this message]
2013-01-11 13:04 ` Andreas Schwab
2013-01-11 13:05 ` Richard Biener
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=alpine.LNX.2.00.1301101017580.6889@zhemvz.fhfr.qr \
--to=rguenther@suse.de \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=rth@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).