Bug 95210 - internal compiler error: in prepare_copy_insn, at gcse.c:1988
Summary: internal compiler error: in prepare_copy_insn, at gcse.c:1988
Status: RESOLVED DUPLICATE of bug 95267
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 9.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2020-05-19 14:01 UTC by Allen
Modified: 2020-05-22 06:12 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Allen 2020-05-19 14:01:01 UTC
rtx_insn *
prepare_copy_insn (rtx reg, rtx exp)
{
  ... 
  else
    {
      rtx_insn *insn = emit_insn (gen_rtx_SET (reg, exp));

      if (insn_invalid_p (insn, false))
	gcc_unreachable ();  // here is the ICE ...
    }

  pat = get_insns ();
  end_sequence ();  

  return pat;
}

As the function can_assign_to_reg_without_clobbers_p, we try to check an temporary insn with regno 'FIRST_PSEUDO_REGISTER * 2'. So in some corner case, such as a pattern with inout operand, the regno 'FIRST_PSEUDO_REGISTER * 2' is just equal to the the regno in the REG_EQUAL (FIRST_PSEUDO_REGISTER = 117), then the temporary insn is valid, but it come fail when alloc another regno for it, here is this issue.

(set (reg/v:V8HF16 236 )
  (unspec: V8HF18 [ (reg: V8HF18 150)
                    (reg: V8HF18 236)] UNSPEC_MOVTVFM)) 
   (expr_list:REG_EQUAL (unspec: V8HF18 [ (reg: V8HF18 150)
                                          (reg: V8HF18 234)] UNSPEC_MOVTVFM ))

bool
can_assign_to_reg_without_clobbers_p (rtx x, machine_mode mode)
{
  .... 

  /* Otherwise, check if we can make a valid insn from it.  First initialize
     our test insn if we haven't already.  */
  if (test_insn == 0)
    {
      test_insn
	= make_insn_raw (gen_rtx_SET (gen_rtx_REG (word_mode,
						   FIRST_PSEUDO_REGISTER * 2),
				      const0_rtx));
      SET_NEXT_INSN (test_insn) = SET_PREV_INSN (test_insn) = 0;
      INSN_LOCATION (test_insn) = UNKNOWN_LOCATION;
    }

  /* Now make an insn like the one we would make when GCSE'ing and see if
     valid.  */
  PUT_MODE (SET_DEST (PATTERN (test_insn)), mode);
  SET_SRC (PATTERN (test_insn)) = x;

  icode = recog (PATTERN (test_insn), test_insn, &num_clobbers);
Comment 1 Allen 2020-05-19 14:49:18 UTC
patch for this issue.

@ linux-9z2e in ~/software/gcc/gcc on git:master o [23:02:26] 
$ git diff
diff --git a/gcc/gcse.c b/gcc/gcse.c
index 8b9518e..65982ec 100644
--- a/gcc/gcse.c
+++ b/gcc/gcse.c
@@ -853,7 +853,7 @@ can_assign_to_reg_without_clobbers_p (rtx x, machine_mode mode)
     {
       test_insn
        = make_insn_raw (gen_rtx_SET (gen_rtx_REG (word_mode,
-                                              FIRST_PSEUDO_REGISTER * 2),
+                                              max_regno + 1),
                                      const0_rtx));
Comment 2 Richard Biener 2020-05-19 17:15:45 UTC
testcase?
Comment 3 Allen 2020-05-22 06:12:24 UTC
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95267

*** This bug has been marked as a duplicate of bug 95267 ***