Patchwork {patch tree-ssa-math-opts]: Change searching direction for bswap

login
register
mail settings
Submitter Kai Tietz
Date June 28, 2011, 9:29 a.m.
Message ID <557542071.809365.1309253346481.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com>
Download mbox | patch
Permalink /patch/102343/
State New
Headers show

Comments

Kai Tietz - June 28, 2011, 9:29 a.m.
Oh, missed to fill comment.

Thanks,
Kai
Richard Guenther - June 28, 2011, 9:44 a.m.
On Tue, Jun 28, 2011 at 11:29 AM, Kai Tietz <ktietz@redhat.com> wrote:
> Oh, missed to fill comment.



> Thanks,
> Kai
>
> Index: gcc-head/gcc/tree-ssa-math-opts.c
> ===================================================================
> --- gcc-head.orig/gcc/tree-ssa-math-opts.c
> +++ gcc-head/gcc/tree-ssa-math-opts.c
> @@ -1821,7 +1821,11 @@ execute_optimize_bswap (void)
>     {
>       gimple_stmt_iterator gsi;
>
> -      for (gsi = gsi_after_labels (bb); !gsi_end_p (gsi); gsi_next (&gsi))
> +      /* We scan for bswap patterns reverse for making sure we get

We do a reverse scan for bswap patterns to make sure we get the widest match.

Ok with that change.

Richard.

> +        widest match.  As bswap pattern matching doesn't handle
> +        previously inserted smaller bswap replacements as sub-
> +        patterns, the wider variant wouldn't be detected.  */
> +      for (gsi = gsi_last_bb (bb); !gsi_end_p (gsi); gsi_prev (&gsi))
>         {
>          gimple stmt = gsi_stmt (gsi);
>          tree bswap_src, bswap_type;
>

Patch

Index: gcc-head/gcc/tree-ssa-math-opts.c
===================================================================
--- gcc-head.orig/gcc/tree-ssa-math-opts.c
+++ gcc-head/gcc/tree-ssa-math-opts.c
@@ -1821,7 +1821,11 @@  execute_optimize_bswap (void)
     {
       gimple_stmt_iterator gsi;

-      for (gsi = gsi_after_labels (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+      /* We scan for bswap patterns reverse for making sure we get
+        widest match.  As bswap pattern matching doesn't handle
+        previously inserted smaller bswap replacements as sub-
+        patterns, the wider variant wouldn't be detected.  */
+      for (gsi = gsi_last_bb (bb); !gsi_end_p (gsi); gsi_prev (&gsi))
         {
          gimple stmt = gsi_stmt (gsi);
          tree bswap_src, bswap_type;