]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
xtensa: Eliminate double MEMW insertions for volatile memory
authorTakayuki 'January June' Suwa <jjsuwa_sys3175@yahoo.co.jp>
Wed, 19 Jun 2024 04:59:54 +0000 (13:59 +0900)
committerMax Filippov <jcmvbkbc@gmail.com>
Wed, 19 Jun 2024 17:06:51 +0000 (10:06 -0700)
This patch makes avoid inserting a MEMW instruction before a load/store
nstruction with volatile memory reference if there is already a MEMW
immediately before it.

gcc/ChangeLog:

* config/xtensa/xtensa.cc (print_operand):
When outputting MEMW before the instruction, check if the previous
instruction is already that.

gcc/config/xtensa/xtensa.cc

index bc127997ac6cb938f560782fabec6d4767bca756..e2549de5df0504d80e77e78825ebc61e9badb1d8 100644 (file)
@@ -3078,7 +3078,17 @@ print_operand (FILE *file, rtx x, int letter)
          /* For a volatile memory reference, emit a MEMW before the
             load or store.  */
          if (MEM_VOLATILE_P (x) && TARGET_SERIALIZE_VOLATILE)
-           fprintf (file, "memw\n\t");
+           {
+             rtx_insn *prev_insn
+                       = prev_nonnote_nondebug_insn (current_output_insn);
+             rtx pat, src;
+
+             if (! (prev_insn && NONJUMP_INSN_P (prev_insn)
+                    && GET_CODE (pat = PATTERN (prev_insn)) == SET
+                    && GET_CODE (src = SET_SRC (pat)) == UNSPEC
+                    && XINT (src, 1) == UNSPEC_MEMW))
+               fprintf (file, "memw\n\t");
+           }
        }
       else
        output_operand_lossage ("invalid %%v value");