public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: kenner@vlsi1.ultra.nyu.edu (Richard Kenner)
To: roger@eyesopen.com
Cc: gcc@gcc.gnu.org
Subject: Re: fold_convert question
Date: Sat, 16 Oct 2004 12:34:00 -0000	[thread overview]
Message-ID: <10410160314.AA24908@vlsi1.ultra.nyu.edu> (raw)

    But "fold" itself calls "fold_convert" to ensure/force a tree to a
    specified type.  i.e. fold_convert is called for both generic, gimple
    and potentially even by front-ends that don't use tree-ssa.

Hmm ...

    I agree completely that the problem is one of consistency, but I would
    argue that the bug is in (this use of) STRIP_USELESS_TYPE_CONVERSIONS.
    It's not that fold_convert is broken, but that the VIEW_CONVERT_EXPR
    shouldn't have been stripped off in the first place.   I probably wouldn't
    consider the conversion of an ARRAY_TYPE to a scalar to be useless?

It's not a conversion between arrays and scalars, but between two
ARRAY_TYPEs.  Otherwise, they wouldn't have been compartible!
(Ada says that two ARRAY_TYPEs are compatible if the component types
are compatible and the bounds are the same.)

    Indeed the fact that VIEW_CONVERT_EXPR is only used by Ada probably
    helps explain why S_U_T_C is overly aggressive in removing it.  For
    the majority of front-ends (and Ada uses) fold_convert does the right
    thing.

I added the removal of the VIEW_CONVERT_EXPR to S_U_T_C and I still believe
it should be there.

    tree_ssa_useless_type_conversion is an unfortunate hack to work around
    the fact that tree-ssa doesn't yet have a combiner pass.  Without a
    combiner, the optimization passes can only see one statement and its
    operands at a time, so the "necessary" type conversions required to
    keep operands consistent often create a "horizon affect" where
    optimization opportunities are missed due to the local nature of SSA
    form.

Perhaps, but I don't see it that way.  It's always better to keep code at any
level of representation as simple as possible.  If we have conversions that
we know aren't going to generate any code, the earlier we remove them the
better.

    If there's anything I can do to help you investigate/fix c61008a
    that avoids further degenerating the middle-end's type system, I'd
    be happy to help.  Ultimately, this might be a loosing crusade,
    but I couldn't forgive myself if I didn't try.  Worst case scenario
    of tweaking useless_type_conversions is that we miss some optimizations
    (until we get a tree-ssa combiner), but of perverting fold_convert
    is that we regress many difficult to diagnose code generation bugs.

The investigation of that failure is, to a large extent, secondary.

We have the larger problem of being careful to define what "type correctness"
means at tree level.  I previously thought it was uniformly agreed that it
means "strictly correct" in GENERIC and "compatible" (as defined by the lang
hook) in GIMPLE.  So the first question we need to answer is if that's
correct or not.

If it is, then we need to understand which of the tests fold_convert ought to
use based on when it's called.  It may well be that the bug here is in the
caller, which shouldn't be calling it if the types are already compatible.

             reply	other threads:[~2004-10-16  3:10 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-16 12:34 Richard Kenner [this message]
2004-10-16 13:12 ` Andrew Pinski
  -- strict thread matches above, loose matches on Subject: below --
2004-10-19  8:16 Richard Kenner
2004-10-18 21:15 Richard Kenner
2004-10-19  7:16 ` Eric Botcazou
2004-10-16 14:36 Richard Kenner
2004-10-16  3:16 Richard Kenner
2004-10-16  5:23 ` Roger Sayle
2004-10-16 20:24   ` Eric Botcazou
2004-10-18 20:57     ` Jeffrey A Law
2004-10-19  7:06   ` Jeffrey A Law
2004-10-15 20:56 Richard Kenner
2004-10-16  3:10 ` Roger Sayle

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=10410160314.AA24908@vlsi1.ultra.nyu.edu \
    --to=kenner@vlsi1.ultra.nyu.edu \
    --cc=gcc@gcc.gnu.org \
    --cc=roger@eyesopen.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).