From: Kito Cheng <kito.cheng@gmail.com>
To: Jan Hubicka <hubicka@ucw.cz>
Cc: Jeff Law <law@redhat.com>,
gcc-patches@gcc.gnu.org,
Richard Sandiford <rsandifo@linux.vnet.ibm.com>,
Eric Botcazou <ebotcazou@adacore.com>,
Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
Subject: Re: [PATCH] Pass correct memory attributes for build constant
Date: Mon, 30 Jun 2014 06:17:00 -0000 [thread overview]
Message-ID: <CA+yXCZCYqpORxhakyGkuxK_ouXQvMXhR2RfEed0OiesXRdsqtA@mail.gmail.com> (raw)
In-Reply-To: <20140628001430.GA17229@kam.mff.cuni.cz>
>>test.c:
>>extern bar(unsigned char p[3][2]);
>>void foo(int i)
>>{
>> unsigned char data[3][2] = {{1,1}, {1,0}, {1,1}};
>>
>> bar(data);
>>}
> First, note, I'm not an ARM expert. However, the first question I
> have is are we sure the initializer is always going to be suitably
> aligned? What guarantees this initializer is going to have 32 bit
It's a ARRAY_TYPE for the data and ARM require 32-bit align for that.
(Aligned by DATA_ALIGNMENT as Jan say.)
> I think that needs to be settled first, then we need to verify that
> the trees are correctly carrying that alignment requirement around
> and that the code uses it appropriately (and I have my doubts
> because EXP is a CONSTRUCTOR element and those seem to be largely
> ignored in the code we're looking to change).
The key problem is `exp` don't have right alignment info, but `decl` have,
we can observe this in the code:
varasm.c
3166 /* Construct the VAR_DECL associated with the constant. */
3167 decl = build_decl (UNKNOWN_LOCATION, VAR_DECL, get_identifier (label),
3168 TREE_TYPE (exp));
3169 DECL_ARTIFICIAL (decl) = 1;
3170 DECL_IGNORED_P (decl) = 1;
3171 TREE_READONLY (decl) = 1;
3172 TREE_STATIC (decl) = 1;
3173 TREE_ADDRESSABLE (decl) = 1;
...
3181 if (TREE_CODE (exp) == STRING_CST)
3182 {
3183 #ifdef CONSTANT_ALIGNMENT
3184 DECL_ALIGN (decl) = CONSTANT_ALIGNMENT (exp, DECL_ALIGN (decl));
3185 #endif
3186 }
3187 else
3188 align_variable (decl, 0);
`decl` get alignment info here but `exp` doesn't.
...
3203 rtl = gen_const_mem (TYPE_MODE (TREE_TYPE (exp)), symbol);
3204 set_mem_attributes (rtl, exp, 1);
but here, we use `exp` to set memory attribute for MEM rtl.
> I would also strongly recommend turning your testcase into something
> we can add to the testsuite.
>
> If you look in gcc/testsuite/gcc.target/arm you'll see several
> examples. I think you just want to compile this down to assembly
> code with the optimizer enabled, then verify there is no call to
> memcpy in the resulting output. 20030909-1.c would seem to be a
> reasonable example of a test that does something similar.
Hmmm, it's not target dependent problem, but this problem only can
observe by some target since not every target use MEM_ALIGN info for code gen,
the most common case is movmem pattern, they use alignment info to
decide expand or not.
So I am not sure is does it reasonable to make a testcase for target?
prev parent reply other threads:[~2014-06-30 6:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-25 15:35 Kito Cheng
2014-06-25 21:01 ` Jeff Law
2014-06-26 3:38 ` Kito Cheng
2014-06-27 22:35 ` Jeff Law
2014-06-28 0:14 ` Jan Hubicka
2014-06-30 6:17 ` Kito Cheng [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=CA+yXCZCYqpORxhakyGkuxK_ouXQvMXhR2RfEed0OiesXRdsqtA@mail.gmail.com \
--to=kito.cheng@gmail.com \
--cc=ebotcazou@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=hubicka@ucw.cz \
--cc=law@redhat.com \
--cc=ramana.radhakrishnan@arm.com \
--cc=rsandifo@linux.vnet.ibm.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).