2010-01-03 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 3 Jan 2010 15:23:29 +0000 (15:23 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 3 Jan 2010 15:23:29 +0000 (15:23 +0000)
PR tree-optimization/42589
* tree-ssa-math-opts.c (execute_optimize_bswap): Allow
double-word expansion of bswap32.

* gcc.target/i386/pr42589.c: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@155588 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr42589.c [new file with mode: 0644]
gcc/tree-ssa-math-opts.c

index 01769cc..cb0ecfa 100644 (file)
@@ -1,3 +1,9 @@
+2010-01-03  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/42589
+       * tree-ssa-math-opts.c (execute_optimize_bswap): Allow
+       double-word expansion of bswap32.
+
 2010-01-03  Steven Bosscher  <steven@gcc.gnu.org>
 
        * postreload-gcse.c (insert_expr_in_table): Replace BLOCK_NUM
index 609589c..bbf9638 100644 (file)
@@ -1,5 +1,10 @@
 2010-01-03  Richard Guenther  <rguenther@suse.de>
 
+       PR tree-optimization/42589
+       * gcc.target/i386/pr42589.c: New testcase.
+
+2010-01-03  Richard Guenther  <rguenther@suse.de>
+
        PR tree-optimization/42438
        * gcc.dg/tree-ssa/ssa-pre-27.c: New testcase.
 
diff --git a/gcc/testsuite/gcc.target/i386/pr42589.c b/gcc/testsuite/gcc.target/i386/pr42589.c
new file mode 100644 (file)
index 0000000..04e419a
--- /dev/null
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target ilp32 } */
+/* { dg-options "-O2 -march=i486" } */
+
+void
+foo (unsigned long long *p)
+{
+  unsigned long long tmp;
+  tmp = *p;
+  tmp = (tmp >> 32) | (tmp << 32);
+  tmp = (((tmp & 0xff00ff00ff00ff00ULL) >> 8)
+        | ((tmp & 71777214294589695ULL) << 8));
+  *p = (((tmp & 0xffff0000ffff0000ULL) >> 16)
+       | ((tmp & 281470681808895ULL) << 16));
+}
+
+/* { dg-final { scan-assembler-times "bswap" 2 } } */
index 2a984a1..c46a57f 100644 (file)
@@ -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 && word_mode == SImode)));
 
   if (!bswap32_p && !bswap64_p)
     return 0;