From 121b72cf942a05648a7fe6db4403861e2fef8373 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Wed, 7 Sep 2016 16:36:15 -0400 Subject: [PATCH 29/44] FIXME: undo fixups for combine.c --- gcc/combine.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/gcc/combine.c b/gcc/combine.c index ad1655e..33d8f07 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -14495,10 +14495,25 @@ test_combining_shifts () rtx_insn *insn_9 = get_insn_by_uid (9); ASSERT_TRUE (insn_9); +#if 1 int rebuild_jump_labels_after_combine = combine_instructions (get_insns (), max_reg_num ()); ASSERT_FALSE (rebuild_jump_labels_after_combine); +#else + /* Other state we'd have to set up to run try_combine directly: + - uid_insn_cost + - anything else? */ + rtl_hooks = combine_rtl_hooks; + + reg_stat.safe_grow_cleared (max_reg_num ()); + + this_basic_block = BLOCK_FOR_INSN (insn_8); + + rtx_insn *result = try_combine (insn_9, insn_8, NULL, NULL, NULL, NULL); + ASSERT_EQ (insn_9, result); + rtl_hooks = general_rtl_hooks; +#endif /* Verify that insns 8 and 9 were combined. */ ASSERT_EQ (1, combine_merges); @@ -14536,10 +14551,25 @@ test_non_combinable_shifts () rtx_insn *insn_9 = get_insn_by_uid (9); ASSERT_TRUE (insn_9); +#if 1 int rebuild_jump_labels_after_combine = combine_instructions (get_insns (), max_reg_num ()); ASSERT_FALSE (rebuild_jump_labels_after_combine); +#else + /* Other state we'd have to set up to run try_combine directly: + - uid_insn_cost + - anything else? */ + rtl_hooks = combine_rtl_hooks; + reg_stat.safe_grow_cleared (max_reg_num ()); + + this_basic_block = BLOCK_FOR_INSN (insn_8); + + rtx_insn *result = try_combine (insn_9, insn_8, NULL, NULL, NULL, NULL); + ASSERT_EQ (insn_9, result); + + rtl_hooks = general_rtl_hooks; +#endif /* Verify that no insns were combined. */ ASSERT_EQ (0, combine_merges); @@ -14547,6 +14577,69 @@ test_non_combinable_shifts () ASSERT_EQ (INSN, GET_CODE (insn_8)); } +#if 0 +/* FIXME: Verify that try_combine works. */ + +static void +test_combining_additions () +{ + /* Hand-written dump. */ + // TODO: filter on target? + /* This is effectively: + R100 = R101 + 1; + R102 = R100 + 1; + FIXME. */ + const char *input_dump = ( + "(insn 1 0 2 2 (set (reg:SI 100)\n" + " (plus (reg:SI 101)\n" + " (const_int 1 [0x1]))) -1 (nil))\n" + "(insn 2 1 0 2 (set (reg:SI 102)\n" + " (plus (reg:SI 100)\n" + " (const_int 1 [0x1]))) -1 (nil))\n"); + combine_test t (input_dump, 100); + +#if 1 + int rebuild_jump_labels_after_combine + = combine_instructions (get_insns (), max_reg_num ()); + ASSERT_FALSE (rebuild_jump_labels_after_combine); +#else + /* Other state we'd have to set up to run try_combine directly: + - uid_insn_cost + - anything else? */ + rtl_hooks = combine_rtl_hooks; + + reg_stat.safe_grow_cleared (max_reg_num ()); + + this_basic_block = BLOCK_FOR_INSN (insn_8); + + rtx_insn *result = try_combine (insn_9, insn_8, NULL, NULL, NULL, NULL); + ASSERT_EQ (insn_9, result); + + rtl_hooks = general_rtl_hooks; +#endif + /* Verify that insns 8 and 9 were combined. */ + ASSERT_EQ (1, combine_merges); + +#if 0 + /* insn 8 should now be deleted. */ + ASSERT_EQ (NOTE, GET_CODE (insn_8)); + ASSERT_EQ (NOTE_INSN_DELETED, NOTE_KIND (insn_8)); + + /* insn 9 should now be a shift of 35. + On aarch64 it's a set; on x86_64 it's a parallel of a set and a clobber + of CC. */ + rtx set_in_9 = single_set (insn_9); + ASSERT_TRUE (set_in_9); + rtx src_of_9 = SET_SRC (set_in_9); + ASSERT_EQ (ASHIFTRT, GET_CODE (src_of_9)); + rtx amt = XEXP (src_of_9, 1); + ASSERT_TRUE (CONST_INT_P (amt)); + ASSERT_EQ (35, INTVAL (amt)); +#endif +} +#endif + + /* Run all of the selftests within this file. */ void @@ -14559,6 +14652,7 @@ combine_c_tests () test_combining_shifts (); test_non_combinable_shifts (); + //test_combining_additions (); } } // namespace selftest -- 1.8.5.3