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



--- Comment #24 from Richard Biener <rguenth at gcc dot gnu.org> 2013-01-15 
14:31:02 UTC ---

We fail to fold



  (short unsigned int) ( X | (signed short) Y )



to



  (short unsigned int ) X | (short unsigned int) Y



and thus end up with needlessly many conversions on the tree level.



Index: gcc/convert.c

===================================================================

--- gcc/convert.c       (revision 195194)

+++ gcc/convert.c       (working copy)

@@ -750,7 +750,7 @@ convert_to_integer (tree type, tree expr

                                || ex_form == MULT_EXPR)))

                      typex = unsigned_type_for (typex);

                    else

-                     typex = signed_type_for (typex);

+                     ;

                    return convert (type,

                                    fold_build2 (ex_form, typex,

                                                 convert (typex, arg0),



"fixes" that (but has no effect on the resulting assembly).



Btw, even generic tuning assembler is bad which is IMHO the important fact.



I don't think combine is the right mechanism to deal with this as

partial register writes are certainly not wanted.  Instead it's necessary

to see that we can store into memory directly which requires us to combine

too much things.



This is rather to be dealt with on the tree level - the bswap pass

infrastructure should provide a starting point for value composition

like this.

Reply via email to