diff --git a/tcg/tcg.c b/tcg/tcg.c
index d2e720f..8613bf2 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -26,7 +26,7 @@
 #define NDEBUG
 
 /* define it to use liveness analysis (better code) */
-#define USE_LIVENESS_ANALYSIS
+//#define USE_LIVENESS_ANALYSIS
 
 #include <assert.h>
 #include <stdarg.h>
@@ -1196,9 +1196,6 @@ static void tcg_liveness_analysis(TCGContext *s)
                 /* if end of basic block, update */
                 if (def->flags & TCG_OPF_BB_END) {
                     tcg_la_bb_end(s, dead_temps);
-                } else if (def->flags & TCG_OPF_CALL_CLOBBER) {
-                    /* globals are live */
-                    memset(dead_temps, 0, s->nb_globals);
                 }
 
                 /* input args are live */
@@ -1602,12 +1599,6 @@ static void tcg_reg_alloc_op(TCGContext *s,
                     tcg_reg_free(s, reg);
                 }
             }
-            /* XXX: for load/store we could do that only for the slow path
-               (i.e. when a memory callback is called) */
-            
-            /* store globals and free associated registers (we assume the insn
-               can modify any global. */
-            save_globals(s, allocated_regs);
         }
         
         /* satisfy the output constraints */
diff --git a/tcg/x86_64/tcg-target.c b/tcg/x86_64/tcg-target.c
index 5378e85..a6058e1 100644
--- a/tcg/x86_64/tcg-target.c
+++ b/tcg/x86_64/tcg-target.c
@@ -504,6 +504,28 @@ static void *qemu_st_helpers[4] = {
 };
 #endif
 
+static void save_globals_slow_path(TCGContext *s, int reg)
+{
+    int i;
+
+    for(i = 0; i < s->nb_globals; i++) {
+        TCGTemp *ts;
+
+        ts = &s->temps[i];
+        if (!ts->fixed_reg) {
+            switch(ts->val_type) {
+            case TEMP_VAL_REG:
+                tcg_out_st(s, ts->type, ts->reg, ts->mem_reg, ts->mem_offset);
+                break;
+            case TEMP_VAL_CONST:
+                tcg_out_movi(s, ts->type, reg, ts->val);
+                tcg_out_st(s, ts->type, reg, ts->mem_reg, ts->mem_offset);
+                break;
+            }
+        }
+    }
+}
+
 static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args,
                             int opc)
 {
@@ -556,6 +578,7 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args,
     label1_ptr = s->code_ptr;
     s->code_ptr++;
 
+    save_globals_slow_path(s, TCG_REG_RSI);
     /* XXX: move that code at the end of the TB */
     tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_RSI, mem_index);
     tcg_out8(s, 0xe8);
@@ -759,6 +782,8 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args,
         tcg_out_mov(s, TCG_REG_RSI, data_reg);
         break;
     }
+
+    save_globals_slow_path(s, TCG_REG_RDX);
     tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_RDX, mem_index);
     tcg_out8(s, 0xe8);
     tcg_out32(s, (tcg_target_long)qemu_st_helpers[s_bits] - 

