public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/40060]  New: casts loose alignment info
@ 2009-05-07 12:36 matz at gcc dot gnu dot org
  2010-07-31  9:32 ` [Bug middle-end/40060] [4.5/4.6 Regression] " rguenth at gcc dot gnu dot org
  0 siblings, 1 reply; 16+ messages in thread
From: matz at gcc dot gnu dot org @ 2009-05-07 12:36 UTC (permalink / raw)
  To: gcc-bugs

These testcase on powerpc:
  gcc.target/powerpc/405-dlmzb-strlen-1.c scan-assembler dlmzb\\\\.  (-m32)
  gcc.target/powerpc/440-dlmzb-strlen-1.c scan-assembler dlmzb\\\\.  (-m32)
fail since expand from SSA.  That's because TER can't work around a frontend
deficiency anymore.  The code therein is:

size_t strlen8(const long long *s)
{ return strlen((const char *)s); }

the parameter is "long long *" to make the alignment known to the compiler.
There are of course other ways, but this is not what this report is about.
In any case the target type of *s is aligned(8).
The cast is there to be type-correct for strlen, but the destination type
of that cast simply is "const char *", where "char" of course is aligned(1).

For the middle-end the case to char* is not useless, hence we can't get
rid of it, so the pointer alignment as far as strlen is concerned is 1, which
is why the transformation doesn't happen anymore.  TER could work around this
in some case (single use of that temporary), but not always.  Now it doesn't
do that work-around in any case.

What IMO needs to happen is that the frontend construct a new type as
destination type of the cast, as if the user had written:

typedef char alignedchar __attribute__((aligned(8)));
x = (const alignedchar *)s;

Unfortunately this can't be easily transformed into a testcase using
__alignof__, because __alignof__((*(char*)s)) is already transformed by
the frontend looking through the casts.  That disregards that the same 
can't be done by the middle-end.


-- 
           Summary: casts loose alignment info
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: matz at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40060


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2015-06-26 20:27 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-40060-4@http.gcc.gnu.org/bugzilla/>
2010-12-16 13:14 ` [Bug middle-end/40060] [4.5/4.6 Regression] casts loose alignment info rguenth at gcc dot gnu.org
2010-12-20 19:02 ` gseanmcg at gmail dot com
2011-04-28 15:20 ` [Bug middle-end/40060] [4.5/4.6/4.7 " rguenth at gcc dot gnu.org
2012-01-16 14:03 ` rguenth at gcc dot gnu.org
2012-01-16 14:06 ` rguenth at gcc dot gnu.org
2012-01-22 16:52 ` dominiq at lps dot ens.fr
2012-01-24 10:49 ` vries at gcc dot gnu.org
2012-07-02 11:37 ` [Bug middle-end/40060] [4.5/4.6/4.7/4.8 " rguenth at gcc dot gnu.org
2013-04-12 15:16 ` [Bug middle-end/40060] [4.7/4.8/4.9 " jakub at gcc dot gnu.org
2014-06-12 13:43 ` [Bug middle-end/40060] [4.7/4.8/4.9/4.10 " rguenth at gcc dot gnu.org
2014-12-19 13:26 ` [Bug middle-end/40060] [4.8/4.9/5 " jakub at gcc dot gnu.org
2015-03-11 20:19 ` aldyh at gcc dot gnu.org
2015-06-23  8:18 ` [Bug middle-end/40060] [4.8/4.9 " rguenth at gcc dot gnu.org
2015-06-26 19:54 ` [Bug middle-end/40060] [4.9 " jakub at gcc dot gnu.org
2015-06-26 20:27 ` jakub at gcc dot gnu.org
2009-05-07 12:36 [Bug c/40060] New: " matz at gcc dot gnu dot org
2010-07-31  9:32 ` [Bug middle-end/40060] [4.5/4.6 Regression] " rguenth at gcc dot gnu dot org

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).