From 18a5926ed0f72860880f61cb8a876deedaec9308 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Mon, 26 Sep 2016 15:33:32 -0400
Subject: [PATCH 22/43] FIXME: add -froundtrip back in

---
 gcc/rtl/lang.opt                                   |   5 +
 gcc/rtl/notes.rst                                  |  20 +-
 gcc/rtl/rtl-frontend.c                             |  24 +++
 gcc/testsuite/rtl.dg/roundtrip/code-labels.rtl     |   2 +
 gcc/testsuite/rtl.dg/roundtrip/frame-pointer.rtl   |   4 +
 gcc/testsuite/rtl.dg/roundtrip/insn-with-mode.rtl  |   4 +
 gcc/testsuite/rtl.dg/roundtrip/jump-to-label.rtl   |   6 +
 gcc/testsuite/rtl.dg/roundtrip/jump-to-return.rtl  |   6 +
 .../rtl.dg/roundtrip/jump-to-simple-return.rtl     |   6 +
 .../rtl.dg/roundtrip/note-insn-basic-block.rtl     |   1 +
 .../rtl.dg/roundtrip/note-insn-deleted.rtl         |   1 +
 .../rtl.dg/roundtrip/reg-with-orig-regno.rtl       |   4 +
 gcc/testsuite/rtl.dg/roundtrip/roundtrip.exp       |  99 ++++++++++
 .../rtl.dg/roundtrip/test-loop.cleaned.rtl         |  75 ++++++++
 .../rtl.dg/roundtrip/test-switch-after-expand.rtl  | 202 +++++++++++++++++++++
 gcc/testsuite/rtl.dg/rtl.exp                       |   5 +-
 16 files changed, 461 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/rtl.dg/roundtrip/code-labels.rtl
 create mode 100644 gcc/testsuite/rtl.dg/roundtrip/frame-pointer.rtl
 create mode 100644 gcc/testsuite/rtl.dg/roundtrip/insn-with-mode.rtl
 create mode 100644 gcc/testsuite/rtl.dg/roundtrip/jump-to-label.rtl
 create mode 100644 gcc/testsuite/rtl.dg/roundtrip/jump-to-return.rtl
 create mode 100644 gcc/testsuite/rtl.dg/roundtrip/jump-to-simple-return.rtl
 create mode 100644 gcc/testsuite/rtl.dg/roundtrip/note-insn-basic-block.rtl
 create mode 100644 gcc/testsuite/rtl.dg/roundtrip/note-insn-deleted.rtl
 create mode 100644 gcc/testsuite/rtl.dg/roundtrip/reg-with-orig-regno.rtl
 create mode 100644 gcc/testsuite/rtl.dg/roundtrip/roundtrip.exp
 create mode 100644 gcc/testsuite/rtl.dg/roundtrip/test-loop.cleaned.rtl
 create mode 100644 gcc/testsuite/rtl.dg/roundtrip/test-switch-after-expand.rtl

diff --git a/gcc/rtl/lang.opt b/gcc/rtl/lang.opt
index 2515ff3..42adac0 100644
--- a/gcc/rtl/lang.opt
+++ b/gcc/rtl/lang.opt
@@ -25,6 +25,11 @@
 Language
 RTL
 
+froundtrip=
+RTL Joined RejectNegative
+After loading the RTL input file, immediately dump it to the given path,
+for sanity-checking the loader.
+
 fsingle-pass=
 RTL Joined RejectNegative
 After loading the RTL input file, run the specified pass on it.
diff --git a/gcc/rtl/notes.rst b/gcc/rtl/notes.rst
index 6d4ab22..9442ce3 100644
--- a/gcc/rtl/notes.rst
+++ b/gcc/rtl/notes.rst
@@ -65,7 +65,11 @@ enabled at configuration time within ``--enable-languages``.
 If enabled, it builds an ``rtl1`` binary, which is invoked by the
 ``gcc`` driver on files with a ``.rtl`` extension.
 
-The testsuite is below ``gcc/testsuite/rtl.dg``.
+The testsuite is below ``gcc/testsuite/rtl.dg``.  There's also
+a ``roundtrip`` subdirectory below this, in which every ``.rtl``
+file is loaded and then dumped; ``roundtrip.exp`` verifies that
+the dump is identical to the original file, thus ensuring that
+the RTL loaders faithfully rebuild the input dump.
 
 Limitations
 -----------
@@ -190,13 +194,25 @@ TODO items
 
 * test with other architectures
 
+* roundtrip.exp: strip out comments in source when comparing roundtrip
+
 * example with "-g"
 
 * implement a fuzzer (or use AFL on the existing test cases)
 
 Cross-arch issues
 -----------------
-* unknown modes e.g. this from x86_64::
+* roundtrip.exp fails: different register names so e.g. this from x86_64::
+
+     (reg:SI 5 di [ i ]))
+
+  becomes this after roundtripping on aarch64::
+
+     (reg:SI 5 x5 [ i ]))
+
+  (i.e. ``di`` vs ``x5``).
+
+* rtl.exp failures: unknown modes e.g. this from x86_64::
 
     (reg:CCGC 17 flags)
 
diff --git a/gcc/rtl/rtl-frontend.c b/gcc/rtl/rtl-frontend.c
index 638b104..2fe0939 100644
--- a/gcc/rtl/rtl-frontend.c
+++ b/gcc/rtl/rtl-frontend.c
@@ -136,6 +136,10 @@ rtl_langhook_option_lang_mask (void)
   return CL_RTL;
 }
 
+/* The value of "-froundtrip=", if any.  */
+
+static const char *roundtrip_filename = NULL;
+
 /* The value of "-fsingle-pass=", if any.  */
 
 static const char *single_pass_name = NULL;
@@ -155,6 +159,10 @@ rtl_langhook_handle_option (
 
   switch (code)
     {
+    case OPT_froundtrip_:
+      roundtrip_filename = xstrdup (arg);
+      break;
+
     case OPT_fsingle_pass_:
       single_pass_name =  xstrdup (arg);
       break;
@@ -184,6 +192,22 @@ rtl_langhook_parse_file (void)
 			       NULL))
     return;
 
+  /* If -froundtrip=FILENAME was provided, immediately dump the
+     result, so that the testsuite can compare it against the
+     input dump.  */
+  if (roundtrip_filename)
+    {
+      FILE *out = fopen (roundtrip_filename, "w");
+      if (out)
+	{
+	  print_rtl_with_bb (out, get_insns (), 1024);
+	  fclose (out);
+	}
+      else
+	error_at (UNKNOWN_LOCATION, "unable to open %qs for -froundtrip",
+		  roundtrip_filename);
+    }
+
   /*  If -fsingle-pass=PASS_NAME was provided, locate and run PASS_NAME
       on cfun, as created above.  */
   if (single_pass_name)
diff --git a/gcc/testsuite/rtl.dg/roundtrip/code-labels.rtl b/gcc/testsuite/rtl.dg/roundtrip/code-labels.rtl
new file mode 100644
index 0000000..7c7fa4a
--- /dev/null
+++ b/gcc/testsuite/rtl.dg/roundtrip/code-labels.rtl
@@ -0,0 +1,2 @@
+(code_label 1 0 2 6 3 (nil) [0 uses])
+(code_label 2 1 0 6 3 ("some_label_name") [57 uses])
diff --git a/gcc/testsuite/rtl.dg/roundtrip/frame-pointer.rtl b/gcc/testsuite/rtl.dg/roundtrip/frame-pointer.rtl
new file mode 100644
index 0000000..50e9e88
--- /dev/null
+++ b/gcc/testsuite/rtl.dg/roundtrip/frame-pointer.rtl
@@ -0,0 +1,4 @@
+(insn 1 0 0 2 (set (mem/c:SI (plus:DI (reg/f:DI 20 frame)
+                (const_int -4 [0xfffffffffffffffc])) [1 i+0 S4 A32])
+        (reg:SI 5 di [ i ])) ../../src/gcc/testsuite/rtl.dg/test.c:2 -1
+     (nil))
diff --git a/gcc/testsuite/rtl.dg/roundtrip/insn-with-mode.rtl b/gcc/testsuite/rtl.dg/roundtrip/insn-with-mode.rtl
new file mode 100644
index 0000000..1dd4c92
--- /dev/null
+++ b/gcc/testsuite/rtl.dg/roundtrip/insn-with-mode.rtl
@@ -0,0 +1,4 @@
+(insn:TI 31 0 0 2 (set (reg:SI 0 ax [93])
+        (plus:SI (reg/v:SI 1 dx [orig:90 k ] [90])
+            (const_int 4 [0x4]))) ../../src/gcc/testsuite/rtl.dg/test.c:4 -1
+     (nil))
diff --git a/gcc/testsuite/rtl.dg/roundtrip/jump-to-label.rtl b/gcc/testsuite/rtl.dg/roundtrip/jump-to-label.rtl
new file mode 100644
index 0000000..0ecd62a
--- /dev/null
+++ b/gcc/testsuite/rtl.dg/roundtrip/jump-to-label.rtl
@@ -0,0 +1,6 @@
+(jump_insn 1 0 2 4 (set (pc)
+        (label_ref 3)) ../../src/gcc/testsuite/rtl.dg/test.c:4 -1
+     (nil)
+ -> 3)
+(barrier 2 1 3)
+(code_label 3 2 0 5 2 (nil) [1 uses])
diff --git a/gcc/testsuite/rtl.dg/roundtrip/jump-to-return.rtl b/gcc/testsuite/rtl.dg/roundtrip/jump-to-return.rtl
new file mode 100644
index 0000000..d7802da
--- /dev/null
+++ b/gcc/testsuite/rtl.dg/roundtrip/jump-to-return.rtl
@@ -0,0 +1,6 @@
+(jump_insn 1 0 2 4 (set (pc)
+        (label_ref 3)) ../../src/gcc/testsuite/rtl.dg/test.c:4 -1
+     (nil)
+ -> return)
+(barrier 2 1 3)
+(code_label 3 2 0 5 2 (nil) [1 uses])
diff --git a/gcc/testsuite/rtl.dg/roundtrip/jump-to-simple-return.rtl b/gcc/testsuite/rtl.dg/roundtrip/jump-to-simple-return.rtl
new file mode 100644
index 0000000..541dd4b
--- /dev/null
+++ b/gcc/testsuite/rtl.dg/roundtrip/jump-to-simple-return.rtl
@@ -0,0 +1,6 @@
+(jump_insn 1 0 2 4 (set (pc)
+        (label_ref 3)) ../../src/gcc/testsuite/rtl.dg/test.c:4 -1
+     (nil)
+ -> simple_return)
+(barrier 2 1 3)
+(code_label 3 2 0 5 2 (nil) [1 uses])
diff --git a/gcc/testsuite/rtl.dg/roundtrip/note-insn-basic-block.rtl b/gcc/testsuite/rtl.dg/roundtrip/note-insn-basic-block.rtl
new file mode 100644
index 0000000..8e535a1
--- /dev/null
+++ b/gcc/testsuite/rtl.dg/roundtrip/note-insn-basic-block.rtl
@@ -0,0 +1 @@
+(note 1 0 0 2 [bb 2] NOTE_INSN_BASIC_BLOCK)
diff --git a/gcc/testsuite/rtl.dg/roundtrip/note-insn-deleted.rtl b/gcc/testsuite/rtl.dg/roundtrip/note-insn-deleted.rtl
new file mode 100644
index 0000000..e63997f
--- /dev/null
+++ b/gcc/testsuite/rtl.dg/roundtrip/note-insn-deleted.rtl
@@ -0,0 +1 @@
+(note 1 0 0 (nil) NOTE_INSN_DELETED)
diff --git a/gcc/testsuite/rtl.dg/roundtrip/reg-with-orig-regno.rtl b/gcc/testsuite/rtl.dg/roundtrip/reg-with-orig-regno.rtl
new file mode 100644
index 0000000..f75d984
--- /dev/null
+++ b/gcc/testsuite/rtl.dg/roundtrip/reg-with-orig-regno.rtl
@@ -0,0 +1,4 @@
+(insn 31 0 0 2 (set (reg:SI 0 ax [93])
+        (plus:SI (reg/v:SI 1 dx [orig:90 k ] [90])
+            (const_int 4 [0x4]))) ../../src/gcc/testsuite/rtl.dg/test.c:4 -1
+     (nil))
diff --git a/gcc/testsuite/rtl.dg/roundtrip/roundtrip.exp b/gcc/testsuite/rtl.dg/roundtrip/roundtrip.exp
new file mode 100644
index 0000000..fbc7963
--- /dev/null
+++ b/gcc/testsuite/rtl.dg/roundtrip/roundtrip.exp
@@ -0,0 +1,99 @@
+# Copyright (C) 2016 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+# Verify that all of the .rtl files in this directory
+# "round trip" i.e. that loading and then dumping them leads to
+# identical content.
+
+load_lib rtl-dg.exp
+
+# If a testcase doesn't have special options, use these.
+global DEFAULT_RTLFLAGS
+if ![info exists DEFAULT_RTLFLAGS] then {
+    set DEFAULT_RTLFLAGS ""
+    # -fdump-tree-rtl-raw
+}
+
+# Compare INPUT_FILE and OUTPUT_FILE, and issue pass/fail
+# results if they have equal/non-equal content.
+
+proc verify-roundtrip { input_file output_file } {
+    verbose "verify-roundtrip:" 3
+    verbose "  input_file: $input_file" 3
+    verbose "  output_file: $output_file" 3
+    # Use "diff" from DejaGnu's utils.exp
+    set diff_result [diff $input_file $output_file]
+    if { $diff_result == 1 } then {
+	pass "$input_file and $output_file are identical"
+    } else {
+	if { $diff_result == -1 } then {
+	    fail "$input_file and $output_file are non-identical"
+	} else {
+	    fail "problem comparing $input_file with $output_file"
+	}
+    }
+}
+
+# Override the default implementation of rtl-dg-test:
+
+rename rtl-dg-test saved-rtl-dg-test
+
+# Alternate implementation of rtl-dg-test which adds a -froundtrip=
+# argument, and verifies that the output is identical to the input.
+
+proc rtl-dg-test { prog do_what extra_tool_flags } {
+    verbose "rtl-dg-test (roundtrip.exp):" 3
+    verbose "  prog: $prog" 3
+    verbose "  do_what: $do_what" 3
+    verbose "  extra_tool_flags: $extra_tool_flags" 3
+
+    # Generate an output filename by stripping off the path from
+    # $prog, and adding a ".roundtrip.rtl" suffix.
+    set output_file [file tail $prog]
+    set output_file "$output_file.roundtrip.rtl"
+
+    # Use it with -froundtrip=.
+    set options \
+	"$extra_tool_flags -froundtrip=$output_file"
+    verbose "options=$options" 3
+
+    set result [gcc-dg-test-1 rtl_target_compile $prog $do_what $options]
+
+    # Verify that the output file is identical to the input file.
+    verify-roundtrip $prog $output_file
+    remote_file build delete $output_file
+    return $result
+}
+
+
+# Initialize `dg'.
+dg-init
+
+# Gather a list of all tests, with the exception of those in directories
+# that are handled specially.
+set tests [lsort [find $srcdir/$subdir *.rtl]]
+
+verbose "roundtrip.exp tests: $tests" 1
+
+# Main loop.
+dg-runtest $tests "" $DEFAULT_RTLFLAGS
+
+# Restore the default implementation of rtl-dg-test:
+rename rtl-dg-test ""
+rename saved-rtl-dg-test rtl-dg-test
+
+# All done.
+dg-finish
diff --git a/gcc/testsuite/rtl.dg/roundtrip/test-loop.cleaned.rtl b/gcc/testsuite/rtl.dg/roundtrip/test-loop.cleaned.rtl
new file mode 100644
index 0000000..c2930b9
--- /dev/null
+++ b/gcc/testsuite/rtl.dg/roundtrip/test-loop.cleaned.rtl
@@ -0,0 +1,75 @@
+(note 1 0 6 (nil) NOTE_INSN_DELETED)
+(note 6 1 2 2 [bb 2] NOTE_INSN_BASIC_BLOCK)
+(insn 2 6 3 2 (set (mem/c:SI (plus:DI (reg/f:DI 82 virtual-stack-vars)
+                (const_int -4 [0xfffffffffffffffc])) [1 i+0 S4 A32])
+        (reg:SI 5 di [ i ])) ../../src/gcc/testsuite/rtl.dg/test.c:2 -1
+     (nil))
+(insn 3 2 4 2 (set (mem/c:SI (plus:DI (reg/f:DI 82 virtual-stack-vars)
+                (const_int -8 [0xfffffffffffffff8])) [1 j+0 S4 A32])
+        (reg:SI 4 si [ j ])) ../../src/gcc/testsuite/rtl.dg/test.c:2 -1
+     (nil))
+(insn 4 3 5 2 (set (mem/c:SI (plus:DI (reg/f:DI 82 virtual-stack-vars)
+                (const_int -12 [0xfffffffffffffff4])) [1 k+0 S4 A32])
+        (reg:SI 1 dx [ k ])) ../../src/gcc/testsuite/rtl.dg/test.c:2 -1
+     (nil))
+(note 5 4 8 2 NOTE_INSN_FUNCTION_BEG)
+(insn 8 5 9 2 (set (reg:SI 89)
+        (mem/c:SI (plus:DI (reg/f:DI 82 virtual-stack-vars)
+                (const_int -4 [0xfffffffffffffffc])) [1 i+0 S4 A32])) ../../src/gcc/testsuite/rtl.dg/test.c:3 -1
+     (nil))
+(insn 9 8 10 2 (set (reg:CCGC 17 flags)
+        (compare:CCGC (reg:SI 89)
+            (mem/c:SI (plus:DI (reg/f:DI 82 virtual-stack-vars)
+                    (const_int -8 [0xfffffffffffffff8])) [1 j+0 S4 A32]))) ../../src/gcc/testsuite/rtl.dg/test.c:3 -1
+     (nil))
+(jump_insn 10 9 11 2 (set (pc)
+        (if_then_else (ge (reg:CCGC 17 flags)
+                (const_int 0 [0]))
+            (label_ref 16)
+            (pc))) ../../src/gcc/testsuite/rtl.dg/test.c:3 -1
+     (nil)
+ -> 16)
+(note 11 10 12 4 [bb 4] NOTE_INSN_BASIC_BLOCK)
+(insn 12 11 13 4 (set (reg:SI 90)
+        (mem/c:SI (plus:DI (reg/f:DI 82 virtual-stack-vars)
+                (const_int -12 [0xfffffffffffffff4])) [1 k+0 S4 A32])) ../../src/gcc/testsuite/rtl.dg/test.c:4 -1
+     (nil))
+(insn 13 12 14 4 (parallel [
+            (set (reg:SI 87 [ _1 ])
+                (plus:SI (reg:SI 90)
+                    (const_int 4 [0x4])))
+            (clobber (reg:CC 17 flags))
+        ]) ../../src/gcc/testsuite/rtl.dg/test.c:4 -1
+     (expr_list:REG_EQUAL (plus:SI (mem/c:SI (plus:DI (reg/f:DI 82 virtual-stack-vars)
+                    (const_int -12 [0xfffffffffffffff4])) [1 k+0 S4 A32])
+            (const_int 4 [0x4]))
+        (nil)))
+(jump_insn 14 13 15 4 (set (pc)
+        (label_ref 20)) ../../src/gcc/testsuite/rtl.dg/test.c:4 -1
+     (nil)
+ -> 20)
+(barrier 15 14 16)
+(code_label 16 15 17 5 2 (nil) [1 uses])
+(note 17 16 18 5 [bb 5] NOTE_INSN_BASIC_BLOCK)
+(insn 18 17 19 5 (set (reg:SI 91)
+        (mem/c:SI (plus:DI (reg/f:DI 82 virtual-stack-vars)
+                (const_int -12 [0xfffffffffffffff4])) [1 k+0 S4 A32])) ../../src/gcc/testsuite/rtl.dg/test.c:6 -1
+     (nil))
+(insn 19 18 20 5 (parallel [
+            (set (reg:SI 87 [ _1 ])
+                (neg:SI (reg:SI 91)))
+            (clobber (reg:CC 17 flags))
+        ]) ../../src/gcc/testsuite/rtl.dg/test.c:6 -1
+     (expr_list:REG_EQUAL (neg:SI (mem/c:SI (plus:DI (reg/f:DI 82 virtual-stack-vars)
+                    (const_int -12 [0xfffffffffffffff4])) [1 k+0 S4 A32]))
+        (nil)))
+(code_label 20 19 21 6 3 (nil) [1 uses])
+(note 21 20 22 6 [bb 6] NOTE_INSN_BASIC_BLOCK)
+(insn 22 21 26 6 (set (reg:SI 88 [ <retval> ])
+        (reg:SI 87 [ _1 ])) -1
+     (nil))
+(insn 26 22 27 6 (set (reg/i:SI 0 ax)
+        (reg:SI 88 [ <retval> ])) ../../src/gcc/testsuite/rtl.dg/test.c:7 -1
+     (nil))
+(insn 27 26 0 6 (use (reg/i:SI 0 ax)) ../../src/gcc/testsuite/rtl.dg/test.c:7 -1
+     (nil))
diff --git a/gcc/testsuite/rtl.dg/roundtrip/test-switch-after-expand.rtl b/gcc/testsuite/rtl.dg/roundtrip/test-switch-after-expand.rtl
new file mode 100644
index 0000000..497e671
--- /dev/null
+++ b/gcc/testsuite/rtl.dg/roundtrip/test-switch-after-expand.rtl
@@ -0,0 +1,202 @@
+(note 1 0 7 (nil) NOTE_INSN_DELETED)
+(note 7 1 2 2 [bb 2] NOTE_INSN_BASIC_BLOCK)
+(insn 2 7 3 2 (set (reg/v:SI 88 [ i ])
+        (reg:SI 5 di [ i ])) ../../src/test-switch.c:2 -1
+     (nil))
+(insn 3 2 4 2 (set (reg/v:SI 89 [ j ])
+        (reg:SI 4 si [ j ])) ../../src/test-switch.c:2 -1
+     (nil))
+(insn 4 3 5 2 (set (reg/v:SI 90 [ k ])
+        (reg:SI 1 dx [ k ])) ../../src/test-switch.c:2 -1
+     (nil))
+(note 5 4 9 2 NOTE_INSN_FUNCTION_BEG)
+(insn 9 5 10 2 (parallel [
+            (set (reg:SI 91)
+                (plus:SI (reg/v:SI 88 [ i ])
+                    (const_int 1 [0x1])))
+            (clobber (reg:CC 17 flags))
+        ]) ../../src/test-switch.c:3 -1
+     (nil))
+(insn 10 9 11 2 (set (reg:CC 17 flags)
+        (compare:CC (reg:SI 91)
+            (const_int 25 [0x19]))) ../../src/test-switch.c:3 -1
+     (nil))
+(jump_insn 11 10 67 2 (set (pc)
+        (if_then_else (gtu (reg:CC 17 flags)
+                (const_int 0 [0]))
+            (label_ref 52)
+            (pc))) ../../src/test-switch.c:3 -1
+     (int_list:REG_BR_PROB 625 (nil))
+ -> 52)
+(note 67 11 12 4 [bb 4] NOTE_INSN_BASIC_BLOCK)
+(insn 12 67 13 4 (set (reg:DI 92)
+        (zero_extend:DI (reg:SI 91))) ../../src/test-switch.c:3 -1
+     (nil))
+(insn 13 12 14 4 (set (reg/f:DI 93)
+        (label_ref:DI 17)) ../../src/test-switch.c:3 -1
+     (insn_list:REG_LABEL_OPERAND 17 (nil)))
+(insn 14 13 15 4 (set (reg:DI 94)
+        (mem/u/c:DI (plus:DI (ashift:DI (reg:DI 92)
+                    (const_int 3 [0x3]))
+                (reg/f:DI 93)) [0  S8 A8])) ../../src/test-switch.c:3 -1
+     (nil))
+(jump_insn 15 14 16 4 (parallel [
+            (set (pc)
+                (reg:DI 94))
+            (use (label_ref 17))
+        ]) ../../src/test-switch.c:3 -1
+     (nil)
+ -> 17)
+(barrier 16 15 17)
+(code_label 17 16 18 (nil) 4 (nil) [2 uses])
+(jump_table_data 18 17 19 (nil) (addr_vec:DI [
+            (label_ref:DI 66)
+            (label_ref:DI 20)
+            (label_ref:DI 20)
+            (label_ref:DI 20)
+            (label_ref:DI 20)
+            (label_ref:DI 20)
+            (label_ref:DI 20)
+            (label_ref:DI 20)
+            (label_ref:DI 20)
+            (label_ref:DI 20)
+            (label_ref:DI 20)
+            (label_ref:DI 35)
+            (label_ref:DI 40)
+            (label_ref:DI 46)
+            (label_ref:DI 52)
+            (label_ref:DI 52)
+            (label_ref:DI 52)
+            (label_ref:DI 52)
+            (label_ref:DI 52)
+            (label_ref:DI 52)
+            (label_ref:DI 52)
+            (label_ref:DI 52)
+            (label_ref:DI 52)
+            (label_ref:DI 52)
+            (label_ref:DI 25)
+            (label_ref:DI 30)
+        ]))
+(barrier 19 18 20)
+(code_label 20 19 21 5 5 (nil) [10 uses])
+(note 21 20 22 5 [bb 5] NOTE_INSN_BASIC_BLOCK)
+(insn 22 21 23 5 (parallel [
+            (set (reg:SI 87 [ <retval> ])
+                (ashift:SI (reg/v:SI 88 [ i ])
+                    (const_int 1 [0x1])))
+            (clobber (reg:CC 17 flags))
+        ]) ../../src/test-switch.c:8 -1
+     (nil))
+(jump_insn 23 22 24 5 (set (pc)
+        (label_ref:DI 59)) ../../src/test-switch.c:8 -1
+     (nil)
+ -> 59)
+(barrier 24 23 25)
+(code_label 25 24 26 6 9 (nil) [1 uses])
+(note 26 25 27 6 [bb 6] NOTE_INSN_BASIC_BLOCK)
+(insn 27 26 28 6 (parallel [
+            (set (reg:SI 87 [ <retval> ])
+                (plus:SI (reg/v:SI 89 [ j ])
+                    (reg/v:SI 90 [ k ])))
+            (clobber (reg:CC 17 flags))
+        ]) ../../src/test-switch.c:10 -1
+     (nil))
+(jump_insn 28 27 29 6 (set (pc)
+        (label_ref:DI 59)) ../../src/test-switch.c:10 -1
+     (nil)
+ -> 59)
+(barrier 29 28 30)
+(code_label 30 29 31 7 10 (nil) [1 uses])
+(note 31 30 32 7 [bb 7] NOTE_INSN_BASIC_BLOCK)
+(insn 32 31 33 7 (parallel [
+            (set (reg:SI 87 [ <retval> ])
+                (minus:SI (reg/v:SI 89 [ j ])
+                    (reg/v:SI 90 [ k ])))
+            (clobber (reg:CC 17 flags))
+        ]) ../../src/test-switch.c:12 -1
+     (nil))
+(jump_insn 33 32 34 7 (set (pc)
+        (label_ref:DI 59)) ../../src/test-switch.c:12 -1
+     (nil)
+ -> 59)
+(barrier 34 33 35)
+(code_label 35 34 36 8 6 (nil) [1 uses])
+(note 36 35 37 8 [bb 8] NOTE_INSN_BASIC_BLOCK)
+(insn 37 36 38 8 (parallel [
+            (set (reg:SI 87 [ <retval> ])
+                (mult:SI (reg/v:SI 89 [ j ])
+                    (reg/v:SI 90 [ k ])))
+            (clobber (reg:CC 17 flags))
+        ]) ../../src/test-switch.c:14 -1
+     (nil))
+(jump_insn 38 37 39 8 (set (pc)
+        (label_ref:DI 59)) ../../src/test-switch.c:14 -1
+     (nil)
+ -> 59)
+(barrier 39 38 40)
+(code_label 40 39 41 9 7 (nil) [1 uses])
+(note 41 40 42 9 [bb 9] NOTE_INSN_BASIC_BLOCK)
+(insn 42 41 43 9 (parallel [
+            (set (reg:SI 95)
+                (div:SI (reg/v:SI 89 [ j ])
+                    (reg/v:SI 90 [ k ])))
+            (set (reg:SI 96)
+                (mod:SI (reg/v:SI 89 [ j ])
+                    (reg/v:SI 90 [ k ])))
+            (clobber (reg:CC 17 flags))
+        ]) ../../src/test-switch.c:16 -1
+     (nil))
+(insn 43 42 44 9 (set (reg:SI 87 [ <retval> ])
+        (reg:SI 95)) ../../src/test-switch.c:16 -1
+     (nil))
+(jump_insn 44 43 45 9 (set (pc)
+        (label_ref:DI 59)) ../../src/test-switch.c:16 -1
+     (nil)
+ -> 59)
+(barrier 45 44 46)
+(code_label 46 45 47 10 8 (nil) [1 uses])
+(note 47 46 48 10 [bb 10] NOTE_INSN_BASIC_BLOCK)
+(insn 48 47 49 10 (parallel [
+            (set (reg:SI 98)
+                (div:SI (reg/v:SI 89 [ j ])
+                    (reg/v:SI 90 [ k ])))
+            (set (reg:SI 97)
+                (mod:SI (reg/v:SI 89 [ j ])
+                    (reg/v:SI 90 [ k ])))
+            (clobber (reg:CC 17 flags))
+        ]) ../../src/test-switch.c:18 -1
+     (nil))
+(insn 49 48 50 10 (set (reg:SI 87 [ <retval> ])
+        (reg:SI 97)) ../../src/test-switch.c:18 -1
+     (nil))
+(jump_insn 50 49 51 10 (set (pc)
+        (label_ref:DI 59)) ../../src/test-switch.c:18 -1
+     (nil)
+ -> 59)
+(barrier 51 50 52)
+(code_label 52 51 53 11 2 (nil) [11 uses])
+(note 53 52 54 11 [bb 11] NOTE_INSN_BASIC_BLOCK)
+(insn 54 53 63 11 (parallel [
+            (set (reg:SI 87 [ <retval> ])
+                (plus:SI (reg/v:SI 89 [ j ])
+                    (reg/v:SI 90 [ k ])))
+            (clobber (reg:CC 17 flags))
+        ]) ../../src/test-switch.c:20 -1
+     (nil))
+(jump_insn 63 54 64 11 (set (pc)
+        (label_ref:DI 59)) ../../src/test-switch.c:20 -1
+     (nil)
+ -> 59)
+(barrier 64 63 66)
+(code_label 66 64 65 12 11 (nil) [1 uses])
+(note 65 66 6 12 [bb 12] NOTE_INSN_BASIC_BLOCK)
+(insn 6 65 59 12 (set (reg:SI 87 [ <retval> ])
+        (const_int 34 [0x22])) ../../src/test-switch.c:6 -1
+     (nil))
+(code_label 59 6 62 14 1 (nil) [7 uses])
+(note 62 59 60 14 [bb 14] NOTE_INSN_BASIC_BLOCK)
+(insn 60 62 61 14 (set (reg/i:SI 0 ax)
+        (reg:SI 87 [ <retval> ])) ../../src/test-switch.c:22 -1
+     (nil))
+(insn 61 60 0 14 (use (reg/i:SI 0 ax)) ../../src/test-switch.c:22 -1
+     (nil))
diff --git a/gcc/testsuite/rtl.dg/rtl.exp b/gcc/testsuite/rtl.dg/rtl.exp
index 6c7c7f4..f494834 100644
--- a/gcc/testsuite/rtl.dg/rtl.exp
+++ b/gcc/testsuite/rtl.dg/rtl.exp
@@ -30,10 +30,13 @@ if ![info exists DEFAULT_RTLFLAGS] then {
 dg-init
 
 # Gather a list of all tests: both .rtl tests for use with rtl1, and .c tests
-# for use with cc1.
+# for use with cc1
 set tests [lsort [find $srcdir/$subdir *.rtl]]
 set tests [concat $tests [lsort [find $srcdir/$subdir *.c]]]
 
+# Remove tests in directories that are handled specially.
+set tests [prune $tests $srcdir/$subdir/roundtrip/*]
+
 verbose "rtl.exp tests: $tests" 1
 
 # Main loop.
-- 
1.8.5.3

