public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Eric Botcazou <ebotcazou@adacore.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: gcc-patches@gcc.gnu.org, Jan Hubicka <hubicka@ucw.cz>
Subject: Re: Add VIEW_CONVERT_EXPR to operand_equal_p
Date: Wed, 04 Nov 2015 08:51:00 -0000	[thread overview]
Message-ID: <2270331.u4G6gq9JGs@polaris> (raw)
In-Reply-To: <CAFiYyc3WuxWAS+s3FjB+BGz1bXhxAxM88S-Fj+Gsn0T6DOS6Mg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2697 bytes --]

> Ah - tree_ssa_useless_type_conversion and callers, during gimplification.
> I'd like to get rid of it but maybe simply delete the VIEW_CONVERT_EXPR
> case from it for now (and return true unconditionally for NON_LVALUE_EXPR).
> 
> Index: gcc/tree-ssa.c
> ===================================================================
> --- gcc/tree-ssa.c      (revision 229517)
> +++ gcc/tree-ssa.c      (working copy)
> @@ -1142,13 +1161,16 @@ delete_tree_ssa (struct function *fn)
>  bool
>  tree_ssa_useless_type_conversion (tree expr)
>  {
> +  /* Not strictly a conversion but this function is used to strip
> +     useless stuff from trees returned from GENERIC folding.  */
> +  if (TREE_CODE (expr) == NON_LVALUE_EXPR)
> +    return true;
> +
>    /* If we have an assignment that merely uses a NOP_EXPR to change
>       the top of the RHS to the type of the LHS and the type conversion
>       is "safe", then strip away the type conversion so that we can
>       enter LHS = RHS into the const_and_copies table.  */
> -  if (CONVERT_EXPR_P (expr)
> -      || TREE_CODE (expr) == VIEW_CONVERT_EXPR
> -      || TREE_CODE (expr) == NON_LVALUE_EXPR)
> +  if (CONVERT_EXPR_P (expr))
>      return useless_type_conversion_p
>        (TREE_TYPE (expr),
>         TREE_TYPE (TREE_OPERAND (expr, 0)));

The patch introduces GIMPLE checking failures:

FAIL:   c52103m
FAIL:   c52103r
FAIL:   c52104m
FAIL:   c52104r

of the form:

slice9.adb: In function 'Slice9':
slice9.adb:1:1: error: conversion of an SSA_NAME on the left hand side
VIEW_CONVERT_EXPR<character[D.4195:iftmp.10]>("ABCDE");

D.4379 = &VIEW_CONVERT_EXPR<character[D.4195:iftmp.10]>("ABCDE")[D.4378 ...]
{lb: D.4195 sz: 1};

      if (TREE_CODE (expr) == VIEW_CONVERT_EXPR)
	{
	  /* For VIEW_CONVERT_EXPRs which are allowed here too, we only check
	     that their operand is not an SSA name or an invariant when
	     requiring an lvalue (this usually means there is a SRA or IPA-SRA
	     bug).  Otherwise there is nothing to verify, gross mismatches at
	     most invoke undefined behavior.  */
	  if (require_lvalue
	      && (TREE_CODE (op) == SSA_NAME
		  || is_gimple_min_invariant (op)))
	    {
	      error ("conversion of an SSA_NAME on the left hand side");
	      debug_generic_stmt (expr);
	      return true;
	    }
	  else if (TREE_CODE (op) == SSA_NAME
		&& TYPE_SIZE (TREE_TYPE (expr)) != TYPE_SIZE (TREE_TYPE (op)))
	    {
	      error ("conversion of register to a different size");
	      debug_generic_stmt (expr);
	      return true;
	    }
	  else if (!handled_component_p (op))
	    return false;
	}

It's related to dynamic slicing (reduced testcase attached).


	* gnat.dg/slice9.adb: New test.

-- 
Eric Botcazou

[-- Attachment #2: slice9.adb --]
[-- Type: text/x-adasrc, Size: 297 bytes --]

-- { dg-do compile }

procedure Slice9 is

  function Ident (I : Integer) return Integer is
  begin
    return I;
  end;

  subtype S is String (Ident(5)..Ident(9));

  Dest : S;

  Src : String (Ident(1)..Ident(5)) := "ABCDE";

begin
  Dest (Ident(5)..Ident(7)) := Src (Ident(1)..Ident(3));
end;

  parent reply	other threads:[~2015-11-04  8:51 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-14 16:29 Jan Hubicka
2015-10-15  8:39 ` Richard Biener
2015-10-15 11:22   ` Eric Botcazou
2015-10-15 19:47     ` Eric Botcazou
2015-10-15 23:24       ` Jan Hubicka
2015-10-16 15:58         ` Eric Botcazou
2015-10-16 21:47           ` Richard Biener
2015-10-17 10:27             ` Eric Botcazou
2015-10-17 15:17               ` Richard Biener
2015-10-17 18:57                 ` Jan Hubicka
2015-10-18 12:57                   ` Eric Botcazou
2015-10-18 16:37                     ` Jan Hubicka
2015-10-18 17:14                       ` Richard Biener
2015-10-18 18:45                         ` Jan Hubicka
2015-10-19 12:31                           ` Richard Biener
2015-10-19 21:01                             ` Jan Hubicka
2015-10-19  8:17                         ` Eric Botcazou
2015-10-19  7:58                       ` Eric Botcazou
2015-10-19 19:46                         ` Jan Hubicka
2015-10-20  7:02                           ` Eric Botcazou
2015-10-21 22:22                             ` Jan Hubicka
2015-10-22  8:52                               ` Andreas Schwab
2015-10-28 22:49                               ` Eric Botcazou
2015-10-29  4:35                                 ` Jan Hubicka
2015-10-29 11:31                                   ` Richard Biener
2015-10-29 11:32                                     ` Richard Biener
2015-10-29 11:32                                       ` Richard Biener
2015-11-04  8:51                                       ` Eric Botcazou [this message]
2015-10-29 15:06                                     ` Jan Hubicka
2015-10-29 15:24                                       ` Richard Biener
2015-10-29 15:53                                         ` Jan Hubicka
2015-10-30  8:57                                           ` Richard Biener
2015-10-30 15:28                                             ` Jan Hubicka
2015-11-02  9:55                                               ` Richard Biener
2015-10-30  9:56                                       ` Eric Botcazou
2015-10-30 15:19                                         ` Jan Hubicka
2015-10-31 17:39                                           ` Eric Botcazou
2015-10-31 17:58                                             ` Richard Biener
2015-11-03 10:26                                               ` Eric Botcazou
2015-11-03 11:39                                                 ` Richard Biener
2015-11-02  9:30                                             ` Andreas Schwab
2015-11-03  8:43                                               ` Eric Botcazou
2015-11-04  7:23                                                 ` Jan Hubicka
2015-11-04  8:20                                                   ` Eric Botcazou
2015-11-04 16:50                                                     ` Jan Hubicka
2015-11-05 13:49                                                       ` Richard Biener
2015-10-21  4:42                           ` Jan Hubicka
2015-10-21  8:54                             ` Richard Biener
2015-10-21 11:24                             ` Eric Botcazou
2015-10-23  5:22                             ` Jan Hubicka
2015-10-23  9:14                               ` Richard Biener
2015-10-15 16:59   ` Jan Hubicka

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=2270331.u4G6gq9JGs@polaris \
    --to=ebotcazou@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    --cc=richard.guenther@gmail.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).