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  <ja...@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 <rguent...@suse.de>
SUSE / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746
GF: Jeff Hawn, Jennifer Guild, Felix Imend

Reply via email to