This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug rtl-optimization/42589] bswap optimization does not work for 32bit (but for 64bit) on 64bit registers



------- Comment #2 from rguenth at gcc dot gnu dot org  2010-01-03 11:45 -------
With

Index: tree-ssa-math-opts.c
===================================================================
--- tree-ssa-math-opts.c        (revision 155576)
+++ tree-ssa-math-opts.c        (working copy)
@@ -1111,8 +1111,9 @@ execute_optimize_bswap (void)
               && optab_handler (bswap_optab, SImode)->insn_code !=
               CODE_FOR_nothing);
   bswap64_p = (built_in_decls[BUILT_IN_BSWAP64]
-              && optab_handler (bswap_optab, DImode)->insn_code !=
-              CODE_FOR_nothing);
+              && (optab_handler (bswap_optab, DImode)->insn_code !=
+                  CODE_FOR_nothing
+                  || bswap32_p));

   if (!bswap32_p && !bswap64_p)
     return 0;

and thus generic expansion for 64bit bswap we produce

-       movl    %edx, %edi
-       movl    %ecx, %esi
-       andl    $-16711936, %edi
-       andl    $-16711936, %esi
-       movl    %edi, -36(%ebp)
-       movl    %esi, -40(%ebp)
-       movl    -36(%ebp), %edi
-       movl    -40(%ebp), %esi
-       andl    $16711935, %ecx
-       shrdl   $8, %edi, %esi
-       movl    %ecx, -48(%ebp)
-       movl    %esi, -32(%ebp)
-       shrl    $8, %edi
-       movl    -48(%ebp), %esi
-       movl    %edi, -28(%ebp)
-       andl    $16711935, %edx
-       movl    -28(%ebp), %ecx
-       movl    %edx, -44(%ebp)
-       movl    -32(%ebp), %edx
-       movl    -44(%ebp), %edi
-       shldl   $8, %esi, %edi
-       sall    $8, %esi
-       orl     %edi, %ecx
-       orl     %esi, %edx
-       movzwl  %cx, %esi
-       movzwl  %dx, %edi
-       movl    %esi, -52(%ebp)
-       movl    %edi, -56(%ebp)
-       xorw    %dx, %dx
-       movl    -56(%ebp), %esi
-       movl    %edx, -64(%ebp)
-       movl    -52(%ebp), %edi
-       xorw    %cx, %cx
-       shldl   $16, %esi, %edi
-       movl    %ecx, -60(%ebp)
-       movl    %edi, -28(%ebp)
-       sall    $16, %esi
-       movl    -60(%ebp), %edi
-       movl    %esi, -32(%ebp)
-       movl    -28(%ebp), %ecx
-       movl    -64(%ebp), %esi
-       movl    -32(%ebp), %edx
-       shrdl   $16, %edi, %esi
-       shrl    $16, %edi
-       orl     %esi, %edx
-       orl     %edi, %ecx
-       movl    %edx, (%ebx,%eax,8)
-       movl    %ecx, 4(%ebx,%eax,8)
-       movl    8(%ebp), %edi
-       movl    %edx, (%edi,%eax,8)
-       movl    %ecx, 4(%edi,%eax,8)
+       bswap   %edx
+       bswap   %ecx
+       movl    %edx, 4(%ebx,%eax,8)
+       movl    %ecx, (%ebx,%eax,8)
+       movl    %ecx, (%esi,%eax,8)
+       movl    %edx, 4(%esi,%eax,8)

No idea if it is generally a good idea to do this on all targets though.
At least we'd go through expand_doubleword_bswap which should be pretty
much optimal.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |rguenth at gcc dot gnu dot
                   |dot org                     |org
             Status|WAITING                     |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2010-01-03 11:45:57
               date|                            |


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]