I regret that I've been using validate_change() thoughtlessly until now,
and should at least verify whether the RTX changes were successful.

I hope this patch doesn't cause any problems, but if not, I will take some
kind of new action.

gcc/ChangeLog:

        * config/xtensa/xtensa.cc
        (FPreg_neg_scaled_simm12b, convert_SF_const, constantsynth_pass1,
        litpool_set_src_1, litpool_set_src):
        Change each call to validate_change() and apply_change_group() to
        trigger an ICE if the result is not true.
---
 gcc/config/xtensa/xtensa.cc | 34 ++++++++++++++++++++++++----------
 1 file changed, 24 insertions(+), 10 deletions(-)

diff --git a/gcc/config/xtensa/xtensa.cc b/gcc/config/xtensa/xtensa.cc
index 82c0f38f304..0e37aceac17 100644
--- a/gcc/config/xtensa/xtensa.cc
+++ b/gcc/config/xtensa/xtensa.cc
@@ -5910,6 +5910,7 @@ FPreg_neg_scaled_simm12b (rtx_insn *insn)
   int scale;
   rtx_insn *next, *last, *seq;
   REAL_VALUE_TYPE r;
+  bool success;
/* It matches RTL expressions of the following format:
        (set (reg:SF gpr) (const_double:SF cst))
@@ -5965,12 +5966,14 @@ FPreg_neg_scaled_simm12b (rtx_insn *insn)
              dump_insn_slim (dump_file, next);
            }
          remove_reg_equal_equiv_notes (insn);
-         validate_change (insn, &PATTERN (insn),
-                          PATTERN (seq), 0);
+         success = validate_change (insn, &PATTERN (insn),
+                                    PATTERN (seq), 0);
+         gcc_assert (success);
          remove_reg_equal_equiv_notes (next);
          remove_note (next, note);
-         validate_change (next, &PATTERN (next),
-                          PATTERN (last), 0);
+         success = validate_change (next, &PATTERN (next),
+                                    PATTERN (last), 0);
+         gcc_assert (success);
          add_reg_note (next, REG_EQUIV, src);
          add_reg_note (next, REG_DEAD, dest_2);
          if (dump_file)
@@ -6007,6 +6010,7 @@ static bool
 convert_SF_const (rtx_insn *insn)
 {
   rtx pat, dest, src, dest0, src0, src0c;
+  bool success;
/* It is more efficient to assign SFmode literal constants using their
      bit-equivalent SImode ones, thus we convert them so.  */
@@ -6045,7 +6049,9 @@ convert_SF_const (rtx_insn *insn)
       && ! xtensa_simm12b (INTVAL (src0)))
     src0c = src0, src0 = force_const_mem (SImode, src0);
   remove_reg_equal_equiv_notes (insn);
-  validate_change (insn, &PATTERN (insn), gen_rtx_SET (dest0, src0), 0);
+  success = validate_change (insn, &PATTERN (insn),
+                            gen_rtx_SET (dest0, src0), 0);
+  gcc_assert (success);
   if (src0c)
     add_reg_note (insn, REG_EQUIV, copy_rtx (src0c));
   if (dump_file)
@@ -6358,6 +6364,7 @@ constantsynth_pass1 (rtx_insn *insn, constantsynth_info 
&info)
 {
   rtx pat, dest, src;
   int *pcount;
+  bool success;
/* Check whether the insn is an assignment to a constant that is eligible
      for constantsynth.  If a large constant, record the insn and also the
@@ -6375,7 +6382,8 @@ constantsynth_pass1 (rtx_insn *insn, constantsynth_info 
&info)
       if (! rtx_equal_p (src, SET_SRC (pat)))
        {
          remove_reg_equal_equiv_notes (insn);
-         validate_change (insn, &SET_SRC (pat), src, 0);
+         success = validate_change (insn, &SET_SRC (pat), src, 0);
+         gcc_assert (success);
        }
       if (dump_file)
        {
@@ -6548,6 +6556,7 @@ litpool_set_src_1 (rtx_insn *insn, rtx set, bool in_group)
 {
   rtx dest, src;
   enum machine_mode mode;
+  bool success;
if (REG_P (dest = SET_DEST (set)) && CONST_INT_P (src = SET_SRC (set))
       && ((((mode = GET_MODE (dest)) == SImode || mode == HImode)
@@ -6555,8 +6564,9 @@ litpool_set_src_1 (rtx_insn *insn, rtx set, bool in_group)
          || mode == DImode))
     {
       remove_reg_equal_equiv_notes (insn);
-      validate_change (insn, &SET_SRC (set),
-                      force_const_mem (mode, src), in_group);
+      success = validate_change (insn, &SET_SRC (set),
+                                force_const_mem (mode, src), in_group);
+      gcc_assert (success);
       add_reg_note (insn, REG_EQUIV, copy_rtx (src));
       return true;
     }
@@ -6569,7 +6579,7 @@ litpool_set_src (rtx_insn *insn)
 {
   rtx pat = PATTERN (insn);
   int i;
-  bool changed;
+  bool changed, success;
switch (GET_CODE (pat))
     {
@@ -6585,7 +6595,11 @@ litpool_set_src (rtx_insn *insn)
            && litpool_set_src_1 (insn, XVECEXP (pat, 0, i), 1))
          changed = true;
       if (changed)
-       apply_change_group ();
+       {
+         success = apply_change_group ();
+         gcc_assert (success);
+       }
+
       return changed;
default:
--
2.39.5

Reply via email to