Patchwork [1/4] tcg/optimize: fix know-zero bits optimization

login
register
mail settings
Submitter Aurelien Jarno
Date Sept. 3, 2013, 6:27 a.m.
Message ID <1378189680-11987-2-git-send-email-aurelien@aurel32.net>
Download mbox | patch
Permalink /patch/272123/
State New
Headers show

Comments

Aurelien Jarno - Sept. 3, 2013, 6:27 a.m.
Known-zero bits optimization is a great idea that helps to generate more
optimized code. However the current implementation is basically useless
as the computed mask is not saved.

Fix this to make it really working.

Cc: Richard Henderson <rth@twiddle.net>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
---
 tcg/optimize.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
Andreas Färber - Sept. 3, 2013, 9:50 a.m.
FWIW $subject has a typo. While at it...

Am 03.09.2013 08:27, schrieb Aurelien Jarno:
> Known-zero bits optimization is a great idea that helps to generate more
> optimized code. However the current implementation is basically useless
> as the computed mask is not saved.
> 
> Fix this to make it really working.
> 
> Cc: Richard Henderson <rth@twiddle.net>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
> ---
>  tcg/optimize.c |    8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/tcg/optimize.c b/tcg/optimize.c
> index b29bf25..41f2906 100644
> --- a/tcg/optimize.c
> +++ b/tcg/optimize.c
> @@ -695,7 +695,8 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
>              break;
>          }
>  
> -        /* Simplify using known-zero bits */
> +        /* Simplify using known-zero bits. Currently only ops with a single
> +           output argument is supported. */

"ops ... are"?

Cheers,
Andreas

>          mask = -1;
>          affected = -1;
>          switch (op) {
> @@ -1144,6 +1145,11 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
>              } else {
>                  for (i = 0; i < def->nb_oargs; i++) {
>                      reset_temp(args[i]);
> +                    /* Save the corresponding known-zero bits mask for the
> +                       first output argument (only one supported so far). */
> +                    if (i == 0) {
> +                        temps[args[i]].mask = mask;
> +                    }
>                  }
>              }
>              for (i = 0; i < def->nb_args; i++) {
>

Patch

diff --git a/tcg/optimize.c b/tcg/optimize.c
index b29bf25..41f2906 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -695,7 +695,8 @@  static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
             break;
         }
 
-        /* Simplify using known-zero bits */
+        /* Simplify using known-zero bits. Currently only ops with a single
+           output argument is supported. */
         mask = -1;
         affected = -1;
         switch (op) {
@@ -1144,6 +1145,11 @@  static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
             } else {
                 for (i = 0; i < def->nb_oargs; i++) {
                     reset_temp(args[i]);
+                    /* Save the corresponding known-zero bits mask for the
+                       first output argument (only one supported so far). */
+                    if (i == 0) {
+                        temps[args[i]].mask = mask;
+                    }
                 }
             }
             for (i = 0; i < def->nb_args; i++) {