aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorWei Guozhi <carrot@google.com>2009-06-30 06:51:29 +0000
committerWei Guozhi <carrot@gcc.gnu.org>2009-06-30 06:51:29 +0000
commit791b59e35bd36fce29aea0f0f16ec65b1c6ace14 (patch)
treee6e40e470bbb22fbfafc92b65320e222942f2723 /gcc
parent6d984927d5e07a5ecce8a0a029885db94ffdb266 (diff)
downloadgcc-791b59e35bd36fce29aea0f0f16ec65b1c6ace14.zip
gcc-791b59e35bd36fce29aea0f0f16ec65b1c6ace14.tar.gz
gcc-791b59e35bd36fce29aea0f0f16ec65b1c6ace14.tar.bz2
tree-ssa-sink.c (statement_sink_location): Stop sinking expression if the target bb post dominates from bb.
* tree-ssa-sink.c (statement_sink_location): Stop sinking expression if the target bb post dominates from bb. * config/i386/i386.c (memory_address_length): Check existence of base register before using it. * gcc.dg/tree-ssa/ssa-sink-5.c: New testcase. From-SVN: r149082
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/config/i386/i386.c4
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-5.c48
-rw-r--r--gcc/tree-ssa-sink.c10
5 files changed, 73 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d218791..90bed4e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2009-06-30 Wei Guozhi <carrot@google.com>
+
+ PR/40416
+ * tree-ssa-sink.c (statement_sink_location): Stop sinking expression
+ if the target bb post dominates from bb.
+ * config/i386/i386.c (memory_address_length): Check existence of base
+ register before using it.
+
2009-06-29 DJ Delorie <dj@redhat.com>
* doc/install.texi (mep-x-elf): Correct chip's full name.
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 8bb82f3..a6bab1b 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -19389,7 +19389,7 @@ memory_address_length (rtx addr)
len = 4;
}
/* ebp always wants a displacement. Similarly r13. */
- else if (REG_P (base)
+ else if (base && REG_P (base)
&& (REGNO (base) == BP_REG || REGNO (base) == R13_REG))
len = 1;
@@ -19398,7 +19398,7 @@ memory_address_length (rtx addr)
/* ...like esp (or r12), which always wants an index. */
|| base == arg_pointer_rtx
|| base == frame_pointer_rtx
- || (REG_P (base)
+ || (base && REG_P (base)
&& (REGNO (base) == SP_REG || REGNO (base) == R12_REG)))
len += 1;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 03e3a04..42456c8 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2009-06-30 Wei Guozhi <carrot@google.com>
+
+ PR/40416
+ * gcc.dg/tree-ssa/ssa-sink-5.c: New testcase.
+
2009-06-29 Jason Merrill <jason@redhat.com>
PR c++/40274
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-5.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-5.c
new file mode 100644
index 0000000..0454245
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-5.c
@@ -0,0 +1,48 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -Os -fdump-tree-sink-stats" } */
+
+typedef short int16_t;
+typedef unsigned char uint8_t;
+
+void foo(int16_t runs[], uint8_t alpha[], int x, int count)
+{
+ int16_t* next_runs = runs + x;
+ uint8_t* next_alpha = alpha + x;
+
+ while (x > 0)
+ {
+ int n = runs[0];
+
+ if (x < n)
+ {
+ alpha[x] = alpha[0];
+ runs[0] = (int16_t)(x);
+ runs[x] = (int16_t)(n - x);
+ break;
+ }
+ runs += n;
+ alpha += n;
+ x -= n;
+ }
+
+ runs = next_runs;
+ alpha = next_alpha;
+ x = count;
+
+ for (;;)
+ {
+ int n = runs[0];
+
+ if (x < n)
+ {
+ alpha[x] = alpha[0];
+ break;
+ }
+ x -= n;
+ runs += n;
+ }
+}
+
+/* We should not sink the next_runs = runs + x calculation after the loop. */
+/* { dg-final { scan-tree-dump-times "Sunk statements:" 0 "sink" } } */
+/* { dg-final { cleanup-tree-dump "sink" } } */
diff --git a/gcc/tree-ssa-sink.c b/gcc/tree-ssa-sink.c
index 227ad11..4f16add 100644
--- a/gcc/tree-ssa-sink.c
+++ b/gcc/tree-ssa-sink.c
@@ -384,6 +384,11 @@ statement_sink_location (gimple stmt, basic_block frombb,
|| sinkbb->loop_father != frombb->loop_father)
return false;
+ /* Move the expression to a post dominator can't reduce the number of
+ executions. */
+ if (dominated_by_p (CDI_POST_DOMINATORS, frombb, sinkbb))
+ return false;
+
*togsi = gsi_for_stmt (use);
return true;
}
@@ -411,6 +416,11 @@ statement_sink_location (gimple stmt, basic_block frombb,
|| sinkbb->loop_father != frombb->loop_father)
return false;
+ /* Move the expression to a post dominator can't reduce the number of
+ executions. */
+ if (dominated_by_p (CDI_POST_DOMINATORS, frombb, sinkbb))
+ return false;
+
*togsi = gsi_after_labels (sinkbb);
return true;