public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/46027] New: (unsignedtype1)(unsignedtype2)(unsignedtype1_var) not changed into unsignedtype1_var & NNN when sizeof(type1) > sizeof(type2)
@ 2010-10-14 18:55 pinskia at gcc dot gnu.org
  2010-10-14 18:56 ` [Bug tree-optimization/46027] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2010-10-14 18:55 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: (unsignedtype1)(unsignedtype2)(unsignedtype1_var) not
                    changed into unsignedtype1_var & NNN when
                    sizeof(type1) > sizeof(type2)
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: pinskia@gcc.gnu.org


Take:
typedef unsigned type1;
typedef unsigned char type2;
type1 t;
void f(type1 tt)
{
  t = (type2)tt;
}
--- CUT ---
In .optimized we have:
  D.2687_2 = (unsigned char) tt_1(D);
  t.0_3 = (type1) D.2687_2;
  t = t.0_3;

--- CUT ---
This is done on the RTL level, well I think it uses (zero_extend(subreg)) as
the conical form (at least on big endian targets).  Using &0xFF here would be
faster and less memory usage and might be able to optimize more.
Here is a testcase which shows where we can optimize more if we do this:
typedef unsigned type1;
typedef unsigned char type2;


type1 t;

void f(type1 tt)
{
  type2 t1 = t;
  type1 t2 = t1;
  t = t2 & 0xFF;
}

void f1(type1 tt)
{
  type1 t2 = t & 0xff;
  t = t2 & 0xFF;
}


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

end of thread, other threads:[~2011-11-29 23:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-14 18:55 [Bug tree-optimization/46027] New: (unsignedtype1)(unsignedtype2)(unsignedtype1_var) not changed into unsignedtype1_var & NNN when sizeof(type1) > sizeof(type2) pinskia at gcc dot gnu.org
2010-10-14 18:56 ` [Bug tree-optimization/46027] " pinskia at gcc dot gnu.org
2010-10-19  0:29 ` pinskia at gcc dot gnu.org
2011-11-29 23:42 ` pinskia at gcc dot gnu.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).