[v2,2/4] tcg/optimize: fix known-zero bits optimization

Submitted by Aurelien Jarno on Sept. 9, 2013, 5:27 p.m.

Details

Message ID 1378747670-25512-3-git-send-email-aurelien@aurel32.net
State New
Headers show

Commit Message

Aurelien Jarno Sept. 9, 2013, 5:27 p.m.
Known-zero bits optimization is a great idea that helps to generate more
optimized code. However the current implementation only works in very few
cases 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(-)

Comments

Richard Henderson Dec. 6, 2013, 5:54 p.m.
On 09/10/2013 05:27 AM, Aurelien Jarno wrote:
> Known-zero bits optimization is a great idea that helps to generate more
> optimized code. However the current implementation only works in very few
> cases 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(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

Patch hide | download patch | download mbox

diff --git a/tcg/optimize.c b/tcg/optimize.c
index c539e39..0ed8983 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) {
@@ -1157,6 +1158,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++) {