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

* [Bug tree-optimization/46027] (unsignedtype1)(unsignedtype2)(unsignedtype1_var) not changed into unsignedtype1_var & NNN when sizeof(type1) > sizeof(type2)
  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 ` 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
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2010-10-14 18:56 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2010.10.14 18:56:06
         AssignedTo|unassigned at gcc dot       |pinskia at gcc dot gnu.org
                   |gnu.org                     |
     Ever Confirmed|0                           |1

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2010-10-14 18:56:06 UTC ---
I am working on this.  I found this while looking into some 4.3 SRA produced
trees.


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

* [Bug tree-optimization/46027] (unsignedtype1)(unsignedtype2)(unsignedtype1_var) not changed into unsignedtype1_var & NNN when sizeof(type1) > sizeof(type2)
  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
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2010-10-19  0:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> 2010-10-19 00:29:18 UTC ---
Here is a full testcase:
typedef unsigned type1;
typedef unsigned char type2;
type1 t;
void f(type1 tt)
{
  type2 t1 = t;
  type1 t2 = t1;
  t = t2 & 0xFF;
}
void f2(type1 tt)
{
  type1 t2 = (type2)t;
  t = t2 & 0xFF;
}
void f1(type1 tt)
{
  type1 t2 = t & 0xff;
  t = t2 & 0xFF;
}

---- CUT ----
Currently f does not get optimized after my patch. f1 is optimized before my
patch and f2 is optimized afterwards.  f requires some kind of forward
prop/tree combining to do the work.


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

* [Bug tree-optimization/46027] (unsignedtype1)(unsignedtype2)(unsignedtype1_var) not changed into unsignedtype1_var & NNN when sizeof(type1) > sizeof(type2)
  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
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-11-29 23:42 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.7.0

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> 2011-11-29 23:28:40 UTC ---
Fixed on the trunk by:
2011-05-10  Richard Guenther  <rguenther@suse.de>

        * tree-ssa-forwprop.c (combine_conversions): Pattern-match
        a series of conversions and apply foldings similar to what
        fold-const does.
        (tree_ssa_forward_propagate_single_use_vars): Call it.


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