From: Richard Biener <richard.guenther@gmail.com>
To: Jan Hubicka <hubicka@ucw.cz>
Cc: Eric Botcazou <ebotcazou@adacore.com>,
GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: Add VIEW_CONVERT_EXPR to operand_equal_p
Date: Mon, 19 Oct 2015 12:31:00 -0000 [thread overview]
Message-ID: <CAFiYyc1-g-gJ1hB2k0045QL+B5fTrgP=EzhPak-7tufdS60brQ@mail.gmail.com> (raw)
In-Reply-To: <20151018171448.GC63497@kam.mff.cuni.cz>
On Sun, Oct 18, 2015 at 7:14 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
>>
>> Adding back the mode check is fine if all types with the same TYPE_CANONICAL have the same mode. Otherwise we'd regress here. I thought we do for
>>
>> Struct x { int i; };
>> Typedef y x __attribute__((packed));
>>
>> And then doing
>>
>> X x;
>> Y y;
>> X = y;
>
> Do you have any idea how to turn this into a testcase? I don't think we could
> add packed attribute to typedef. Even in
> gimple_canonical_types_compatible_p
> /* Can't be the same type if they have different mode. */
> if (TYPE_MODE (t1) != TYPE_MODE (t2))
> return false;
> (which IMO may be wrong WRT -mavx flags where modes of same types may be different
> in different TUs)
Ok, so the following works:
struct x { int i; };
typedef struct x y __attribute__((aligned(1)));
void foo (void)
{
struct x X;
y Y;
X = Y;
}
but we use SImode for y as well even though it's alignment is just one byte ...
Not sure what happens on strict-align targets for this and not sure how this
cannot be _not_ a problem. Consider
void bar (struct x);
and
bar (Y);
or using y *Y and X = *Y or bar (*Y).
> Therefore I would say that TYPE_CANONICAL determine mode modulo the fact that
> incoplete variant of a complete type will have VOIDmode instead of complete
> type's mode (during non-LTO). That is why I allow mode changes for casts from
> complete to incomplete.
Incomplete have VOIDmode, right?
> In longer run I think that every query to useless_type_conversion_p that
> contains incomplete types is a confused query. useless_type_conversion_p is
> about operations on the value and there are no operations for incomplete type
> (and function types). I know that ipa-icf-gimple and the following code in
> gimplify-stmt checks this frequently:
> /* The FEs may end up building ADDR_EXPRs early on a decl with
> an incomplete type. Re-build ADDR_EXPRs in canonical form
> here. */
> if (!types_compatible_p (TREE_TYPE (op0), TREE_TYPE (TREE_TYPE (expr))))
> *expr_p = build_fold_addr_expr (op0);
> Taking address of incomplete type or functions, naturally, makes sense. We may
> want to check something else here, like simply
> TREE_TYPE (op0) != TREE_TYPE (TREE_TYPE (expr))
> and once ipa-icf is cleanded up start sanity checking in usless_type_conversion
> that we use it to force equality only on types that do have values.
>
> We also can trip it when checking TYPE_METHOD_BASETYPE which may be incomplete.
> This is in the code checking useless_type_conversion on functions that I think
> are confused querries anyway - we need the ABI matcher, I am looking into that.
Ok, so given we seem to be fine in practive with TYPE_MODE (type) ==
TYPE_MODE (TYPE_CANONICAL (type))
(whether that's a but or not ...) I'm fine with re-instantiating the
mode check for
aggregate types. Please do that with
Index: gcc/gimple-expr.c
===================================================================
--- gcc/gimple-expr.c (revision 228963)
+++ gcc/gimple-expr.c (working copy)
@@ -89,8 +89,7 @@ useless_type_conversion_p (tree outer_ty
/* Changes in machine mode are never useless conversions unless we
deal with aggregate types in which case we defer to later checks. */
- if (TYPE_MODE (inner_type) != TYPE_MODE (outer_type)
- && !AGGREGATE_TYPE_P (inner_type))
+ if (TYPE_MODE (inner_type) != TYPE_MODE (outer_type))
return false;
/* If both the inner and outer types are integral types, then the
Can we asses equal sizes when modes are non-BLKmode then? Thus
@@ -270,10 +269,9 @@ useless_type_conversion_p (tree outer_ty
use the types in move operations. */
else if (AGGREGATE_TYPE_P (inner_type)
&& TREE_CODE (inner_type) == TREE_CODE (outer_type))
- return (!TYPE_SIZE (outer_type)
- || (TYPE_SIZE (inner_type)
- && operand_equal_p (TYPE_SIZE (inner_type),
- TYPE_SIZE (outer_type), 0)));
+ return (TYPE_MODE (outer_type) != BLKmode
+ || operand_equal_p (TYPE_SIZE (inner_type),
+ TYPE_SIZE (outer_type), 0));
else if (TREE_CODE (inner_type) == OFFSET_TYPE
&& TREE_CODE (outer_type) == OFFSET_TYPE)
? Hoping for VOIDmode incomplete case.
Richard.
> Honza
>>
>> Richard.
>>
>>
>> >Honza
>> >>
>> >> --
>> >> Eric Botcazou
>>
next prev parent reply other threads:[~2015-10-19 12:30 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 [this message]
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
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='CAFiYyc1-g-gJ1hB2k0045QL+B5fTrgP=EzhPak-7tufdS60brQ@mail.gmail.com' \
--to=richard.guenther@gmail.com \
--cc=ebotcazou@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=hubicka@ucw.cz \
/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).