dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dotgnu-pnet-commits] libjit ChangeLog jit/jit-live.c


From: Aleksey Demakov
Subject: [dotgnu-pnet-commits] libjit ChangeLog jit/jit-live.c
Date: Mon, 28 May 2007 09:00:55 +0000

CVSROOT:        /sources/dotgnu-pnet
Module name:    libjit
Changes by:     Aleksey Demakov <avd>   07/05/28 09:00:55

Modified files:
        .              : ChangeLog 
        jit            : jit-live.c 

Log message:
        do not use copy propagation for addressable and volatile values

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libjit/ChangeLog?cvsroot=dotgnu-pnet&r1=1.315&r2=1.316
http://cvs.savannah.gnu.org/viewcvs/libjit/jit/jit-live.c?cvsroot=dotgnu-pnet&r1=1.4&r2=1.5

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/dotgnu-pnet/libjit/ChangeLog,v
retrieving revision 1.315
retrieving revision 1.316
diff -u -b -r1.315 -r1.316
--- ChangeLog   28 May 2007 02:41:28 -0000      1.315
+++ ChangeLog   28 May 2007 09:00:54 -0000      1.316
@@ -1,5 +1,10 @@
 2007-05-28  Aleksey Demakov  <address@hidden>
 
+       * jit/jit-live.c (forward_propagation, backward_propagation): do not
+       optimize addressable and volatile values.
+
+2007-05-28  Aleksey Demakov  <address@hidden>
+
        * jit/jit-live.c (_jit_function_compute_liveness)
        (forward_propagation, backward_propagation): add simple copy
        propagation that works only within basic blocks.

Index: jit/jit-live.c
===================================================================
RCS file: /sources/dotgnu-pnet/libjit/jit/jit-live.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- jit/jit-live.c      28 May 2007 02:41:28 -0000      1.4
+++ jit/jit-live.c      28 May 2007 09:00:54 -0000      1.5
@@ -19,6 +19,7 @@
  */
 
 #include "jit-internal.h"
+#include <jit/jit-dump.h>
 
 #define USE_FORWARD_PROPAGATION 1
 #define USE_BACKWARD_PROPAGATION 1
@@ -134,6 +135,11 @@
                                        /* There is no next use of this value 
and it is not
                                           live on exit from the block.  So we 
can discard
                                           the entire instruction as it will 
have no effect */
+#ifdef _JIT_COMPILE_DEBUG
+                                       printf("liveness analysis: optimize 
away instruction '");
+                                       jit_dump_insn(stdout, block->func, 
insn);
+                                       printf("'\n");
+#endif
                                        insn->opcode = (short)JIT_OP_NOP;
                                        continue;
                                }
@@ -163,7 +169,7 @@
        }
 }
 
-#if USE_FORWARD_PROPAGATION || USE_BACKWARD_PROPAGATION
+#if defined(USE_FORWARD_PROPAGATION) || defined(USE_BACKWARD_PROPAGATION)
 static int
 is_copy_opcode(int opcode)
 {
@@ -237,26 +243,43 @@
                        continue;
                }
 
-               /* Copy to itself could be safely discarded */
+               /* Discard copy to itself */
                if(dest == value)
                {
+#ifdef _JIT_COMPILE_DEBUG
+                       printf("forward copy propagation: optimize away copy to 
itself in '");
+                       jit_dump_insn(stdout, block->func, insn);
+                       printf("'\n");
+#endif
                        insn->opcode = (short)JIT_OP_NOP;
                        optimized = 1;
                        continue;
                }
 
                /* Not smart enough to tell when it is safe to optimize copying
-                  to a value used in other basic block. So just give up. */
+                  to a value that is used in other basic blocks or may be
+                  aliased. */
                if(!dest->is_temporary)
                {
                        continue;
                }
+               if(dest->is_addressable || dest->is_volatile)
+               {
+                       continue;
+               }
 
                iter2 = iter;
                while((insn2 = jit_insn_iter_next(&iter2)) != 0)
                {
-                       flags2 = insn2->flags;
+                       /* Skip NOP instructions, which may have arguments left
+                          over from when the instruction was replaced, but 
which
+                          are not relevant to our analysis */
+                       if(insn->opcode == JIT_OP_NOP)
+                       {
+                               continue;
+                       }
 
+                       flags2 = insn2->flags;
                        if((flags2 & JIT_INSN_DEST_OTHER_FLAGS) == 0)
                        {
                                if((flags2 & JIT_INSN_DEST_IS_VALUE) == 0)
@@ -268,6 +291,15 @@
                                }
                                else if(insn2->dest == dest)
                                {
+#ifdef _JIT_COMPILE_DEBUG
+                                       printf("forward copy propagation: in 
'");
+                                       jit_dump_insn(stdout, block->func, 
insn2);
+                                       printf("' replace ");
+                                       jit_dump_value(stdout, block->func, 
insn2->dest, 0);
+                                       printf(" with ");
+                                       jit_dump_value(stdout, block->func, 
value, 0);
+                                       printf("'\n");
+#endif
                                        insn2->dest = value;
                                        optimized = 1;
                                }
@@ -276,6 +308,15 @@
                        {
                                if(insn2->value1 == dest)
                                {
+#ifdef _JIT_COMPILE_DEBUG
+                                       printf("forward copy propagation: in 
'");
+                                       jit_dump_insn(stdout, block->func, 
insn2);
+                                       printf("' replace ");
+                                       jit_dump_value(stdout, block->func, 
insn2->value1, 0);
+                                       printf(" with ");
+                                       jit_dump_value(stdout, block->func, 
value, 0);
+                                       printf("'\n");
+#endif
                                        insn2->value1 = value;
                                        optimized = 1;
                                }
@@ -284,6 +325,15 @@
                        {
                                if(insn2->value2 == dest)
                                {
+#ifdef _JIT_COMPILE_DEBUG
+                                       printf("forward copy propagation: in 
'");
+                                       jit_dump_insn(stdout, block->func, 
insn2);
+                                       printf("' replace ");
+                                       jit_dump_value(stdout, block->func, 
insn2->value2, 0);
+                                       printf(" with ");
+                                       jit_dump_value(stdout, block->func, 
value, 0);
+                                       printf("'\n");
+#endif
                                        insn2->value2 = value;
                                        optimized = 1;
                                }
@@ -295,7 +345,7 @@
 }
 #endif
 
-#if USE_BACKWARD_PROPAGATION
+#ifdef USE_BACKWARD_PROPAGATION
 /*
  * Perform simple copy propagation within basic block for the case when a
  * temporary value is stored to another value. This replaces instructions
@@ -338,16 +388,29 @@
                {
                        continue;
                }
+               if(dest->is_addressable || dest->is_volatile)
+               {
+                       continue;
+               }
 
                value = insn->value1;
                if(value == 0)
                {
                        continue;
                }
+               if(value->is_addressable || value->is_volatile)
+               {
+                       continue;
+               }
 
-               /* Copy to itself could be safely discarded */
+               /* Discard copy to itself */
                if(dest == value)
                {
+#ifdef _JIT_COMPILE_DEBUG
+                       printf("backward copy propagation: optimize away copy 
to itself in '");
+                       jit_dump_insn(stdout, block->func, insn);
+                       printf("'\n");
+#endif
                        insn->opcode = (short)JIT_OP_NOP;
                        optimized = 1;
                        continue;
@@ -362,8 +425,15 @@
                iter2 = iter;
                while((insn2 = jit_insn_iter_previous(&iter2)) != 0)
                {
-                       flags2 = insn2->flags;
+                       /* Skip NOP instructions, which may have arguments left
+                          over from when the instruction was replaced, but 
which
+                          are not relevant to our analysis */
+                       if(insn->opcode == JIT_OP_NOP)
+                       {
+                               continue;
+                       }
 
+                       flags2 = insn2->flags;
                        if((flags2 & JIT_INSN_DEST_OTHER_FLAGS) == 0)
                        {
                                if(insn2->dest == dest)
@@ -374,6 +444,17 @@
                                {
                                        if((flags2 & JIT_INSN_DEST_IS_VALUE) == 
0)
                                        {
+#ifdef _JIT_COMPILE_DEBUG
+                                               printf("backward copy 
propagation: in '");
+                                               jit_dump_insn(stdout, 
block->func, insn2);
+                                               printf("' replace ");
+                                               jit_dump_value(stdout, 
block->func, insn2->dest, 0);
+                                               printf(" with ");
+                                               jit_dump_value(stdout, 
block->func, dest, 0);
+                                               printf(" and optimize away '");
+                                               jit_dump_insn(stdout, 
block->func, insn);
+                                               printf("'\n");
+#endif
                                                insn->opcode = 
(short)JIT_OP_NOP;
                                                insn2->dest = dest;
                                                optimized = 1;
@@ -470,7 +551,7 @@
                /* Perform peephole optimization on branches to branches */
                _jit_block_peephole_branch(block);
 
-#if USE_FORWARD_PROPAGATION
+#ifdef USE_FORWARD_PROPAGATION
                /* Perform forward copy propagation for the block */
                forward_propagation(block);
 #endif
@@ -481,7 +562,7 @@
                /* Compute the liveness flags for the block */
                compute_liveness_for_block(block);
 
-#if USE_BACKWARD_PROPAGATION
+#ifdef USE_BACKWARD_PROPAGATION
                /* Perform backward copy propagation for the block */
                if(backward_propagation(block))
                {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]