public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jan Hubicka <hubicka@ucw.cz>
To: Richard Biener <richard.guenther@gmail.com>
Cc: Jan Hubicka <hubicka@ucw.cz>,
	Eric Botcazou <ebotcazou@adacore.com>,
	GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: Add VIEW_CONVERT_EXPR to operand_equal_p
Date: Thu, 15 Oct 2015 16:59:00 -0000	[thread overview]
Message-ID: <20151015165900.GA64673@kam.mff.cuni.cz> (raw)
In-Reply-To: <CAFiYyc2-ztRUqjgT69sfPchAmMdkZa2h0x7STQAMb-oo0unsZg@mail.gmail.com>

> >         * fold-const.c (operand_equal_p): Handle VIEW_CONVERT_EXPR.
> > Index: fold-const.c
> > ===================================================================
> > --- fold-const.c        (revision 228735)
> > +++ fold-const.c        (working copy)
> > @@ -2962,6 +2968,12 @@ operand_equal_p (const_tree arg0, const_
> >         case IMAGPART_EXPR:
> >           return OP_SAME (0);
> >
> > +       case VIEW_CONVERT_EXPR:
> > +         if (!(flags & (OEP_ADDRESS_OF | OEP_CONSTANT_ADDRESS_OF))
> > +             && !types_compatible_p (TREE_TYPE (arg0), TREE_TYPE (arg1)))
> 
> Note that mixing the GIMPLE types_compatible_p into operand_equal_p which
> is supposed to handle GENERIC as well looks dangerous.  You short-cutted
> the type checks for OEP_ADDRESS_OF earlier so why do you need to
> preserve them here?
> 
> The test looks bogus anyway, but maybe it's just too early in the morning ;)
> Shouldn't it be && types_compatible_p (...) (instead of && !types_com...)?
> Otherwise it looks really weird.

I think it is as intended: If we do !OEP_ADDRESS_OF we want to know that types
are compatible. 

I am not quite sure this is needed - I wanted to mention that in an email, but
it was too late in night for me :)

In NOP_EXPR we check:

      /* Two conversions are equal only if signedness and modes match.  */
      switch (TREE_CODE (arg0))
        {
        CASE_CONVERT:
        case FIX_TRUNC_EXPR:
          if (TYPE_UNSIGNED (TREE_TYPE (arg0))
              != TYPE_UNSIGNED (TREE_TYPE (arg1)))
            return 0;
          break;
        default:
          break;
        }

And earlier we do:

      /* If both types don't have the same signedness, then we can't consider
         them equal.  We must check this before the STRIP_NOPS calls
         because they may change the signedness of the arguments.  As pointers
         strictly don't have a signedness, require either two pointers or
         two non-pointers as well.  */
      if (TYPE_UNSIGNED (TREE_TYPE (arg0)) != TYPE_UNSIGNED (TREE_TYPE (arg1))
          || POINTER_TYPE_P (TREE_TYPE (arg0))
                             != POINTER_TYPE_P (TREE_TYPE (arg1)))
        return 0;

So except for NOP_EXPR being stripped early this is bit redundant.

I wondered what happens if I match two VCEs of very different type. Say
vector of FLOATs and vector of INTEGERs and then convert them to same type that
would result in differnt value. But this is not terribly special for VCE
and probably would affect other expressions, too.

I noticed now that this probably this can't happen because we also do:

  /* This is needed for conversions and for COMPONENT_REF.
     Might as well play it safe and always test this.  */
  if (TREE_CODE (TREE_TYPE (arg0)) == ERROR_MARK
      || TREE_CODE (TREE_TYPE (arg1)) == ERROR_MARK
      || TYPE_MODE (TREE_TYPE (arg0)) != TYPE_MODE (TREE_TYPE (arg1)))
    return 0;

Which sounds somewhat conservative. At least should be skipped for OEP_ADDRESS_OF.
You earlier mentioned BLKmode vectors. What would happen in this case?

If I remember correctly. the check was not needed to pass testing, I am respawning testing
without the type check.

Honza
> 
> Richard.
> 
> > +           return false;
> > +         return OP_SAME (0);
> > +
> >         case TARGET_MEM_REF:
> >         case MEM_REF:
> >           if (!(flags & (OEP_ADDRESS_OF | OEP_CONSTANT_ADDRESS_OF)))

      parent reply	other threads:[~2015-10-15 16:59 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
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 [this message]

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=20151015165900.GA64673@kam.mff.cuni.cz \
    --to=hubicka@ucw.cz \
    --cc=ebotcazou@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --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).