aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2012-10-26 17:19:35 +0000
committerTeresa Johnson <tejohnson@gcc.gnu.org>2012-10-26 17:19:35 +0000
commitca3f371f1246db1bf2b71abfdf844a08e0f5dc31 (patch)
treea2eaa87b296b3829f298c857f1de301049610cf6 /gcc
parent8256d5ca7870ab4aa5f74b9cb9183393b1024d0b (diff)
downloadgcc-ca3f371f1246db1bf2b71abfdf844a08e0f5dc31.zip
gcc-ca3f371f1246db1bf2b71abfdf844a08e0f5dc31.tar.gz
gcc-ca3f371f1246db1bf2b71abfdf844a08e0f5dc31.tar.bz2
Avoid conservative behavior in REE by allowing removal of redundant extends when...
Avoid conservative behavior in REE by allowing removal of redundant extends when the def feeds another extend with a different mode. This works because in merge_def_and_ext only calls combine_set_extension if the candidate for removal has a wider mode than the def extend's mode, otherwise the def extend mode is preserved. In combine_set_extension the def is modified to use the wider candidate's mode. 2012-10-26 Teresa Johnson <tejohnson@google.com> * ree.c (add_removable_extension): Remove unnecessary mode check with other extension. * testsuite/gcc.c-torture/execute/20111227-2.c: New test. * testsuite/gcc.c-torture/execute/20111227-3.c: Ditto. From-SVN: r192850
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/ree.c2
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/20111227-2.c44
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/20111227-3.c45
4 files changed, 97 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 768f530..db8c352 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2012-10-26 Teresa Johnson <tejohnson@google.com>
+
+ * ree.c (add_removable_extension): Remove unnecessary
+ mode check with other extension.
+ * testsuite/gcc.c-torture/execute/20111227-2.c: New test.
+ * testsuite/gcc.c-torture/execute/20111227-3.c: Ditto.
+
2012-10-26 Jan Hubicka <jh@suse.cz>
* ipa-inline-transform.c (inline_call): Only account size changes
diff --git a/gcc/ree.c b/gcc/ree.c
index 167efa3..a2ede97 100644
--- a/gcc/ree.c
+++ b/gcc/ree.c
@@ -803,7 +803,7 @@ add_removable_extension (const_rtx expr, rtx insn,
for (def = defs; def; def = def->next)
if ((idx = def_map[INSN_UID(DF_REF_INSN (def->ref))])
&& (cand = &VEC_index (ext_cand, *insn_list, idx - 1))
- && (cand->code != code || cand->mode != mode))
+ && cand->code != code)
{
if (dump_file)
{
diff --git a/gcc/testsuite/gcc.c-torture/execute/20111227-2.c b/gcc/testsuite/gcc.c-torture/execute/20111227-2.c
new file mode 100644
index 0000000..692c947
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/20111227-2.c
@@ -0,0 +1,44 @@
+/* Testcase derived from 20111227-1.c to ensure that REE is combining
+ redundant zero extends with zero extend to wider mode. */
+/* { dg-options "-fdump-rtl-ree -O" } */
+extern void abort (void);
+
+unsigned short s;
+unsigned int i;
+unsigned long l;
+unsigned char v = -1;
+
+void __attribute__((noinline,noclone))
+bar (int t)
+{
+ if (t == 2 && s != 0xff)
+ abort ();
+ if (t == 1 && i != 0xff)
+ abort ();
+ if (t == 0 && l != 0xff)
+ abort ();
+}
+
+void __attribute__((noinline,noclone))
+foo (unsigned char *a, int t)
+{
+ unsigned char r = v;
+
+ if (t == 2)
+ s = (unsigned short) r;
+ else if (t == 1)
+ i = (unsigned int) r;
+ else if (t == 0)
+ l = (unsigned long) r;
+ bar (t);
+}
+
+int main(void)
+{
+ foo (&v, 0);
+ foo (&v, 1);
+ foo (&v, 2);
+ return 0;
+}
+/* { dg-final { scan-rtl-dump "Elimination opportunities = 3 realized = 3" "ree" } } */
+/* { dg-final { cleanup-rtl-dump "ree" } } */
diff --git a/gcc/testsuite/gcc.c-torture/execute/20111227-3.c b/gcc/testsuite/gcc.c-torture/execute/20111227-3.c
new file mode 100644
index 0000000..d6726c4
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/20111227-3.c
@@ -0,0 +1,45 @@
+/* Testcase derived from 20111227-1.c to ensure that REE is combining
+ redundant sign extends with sign extend to wider mode. */
+/* { dg-options "-fdump-rtl-ree -O" } */
+
+extern void abort (void);
+
+signed short s;
+signed int i;
+signed long l;
+signed char v = -1;
+
+void __attribute__((noinline,noclone))
+bar (int t)
+{
+ if (t == 2 && s != -1)
+ abort ();
+ if (t == 1 && i != -1)
+ abort ();
+ if (t == 0 && l != -1)
+ abort ();
+}
+
+void __attribute__((noinline,noclone))
+foo (signed char *a, int t)
+{
+ signed char r = v;
+
+ if (t == 2)
+ s = (signed short) r;
+ else if (t == 1)
+ i = (signed int) r;
+ else if (t == 0)
+ l = (signed long) r;
+ bar (t);
+}
+
+int main(void)
+{
+ foo (&v, 0);
+ foo (&v, 1);
+ foo (&v, 2);
+ return 0;
+}
+/* { dg-final { scan-rtl-dump "Elimination opportunities = 3 realized = 3" "ree" } } */
+/* { dg-final { cleanup-rtl-dump "ree" } } */