From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1909) id E2BA1385740A; Thu, 16 Sep 2021 11:08:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E2BA1385740A MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Daniel Hellstrom To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-3574] sparc: Skip all empty assembly statements X-Act-Checkin: gcc X-Git-Author: Daniel Cederman X-Git-Refname: refs/heads/master X-Git-Oldrev: b4bbb373dfad830e8daa43e880e4f6536c868a53 X-Git-Newrev: 6d0c97b19a306cf192ef9e8d0222635192dbc710 Message-Id: <20210916110841.E2BA1385740A@sourceware.org> Date: Thu, 16 Sep 2021 11:08:41 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Sep 2021 11:08:42 -0000 https://gcc.gnu.org/g:6d0c97b19a306cf192ef9e8d0222635192dbc710 commit r12-3574-g6d0c97b19a306cf192ef9e8d0222635192dbc710 Author: Daniel Cederman Date: Fri Oct 16 09:12:30 2020 +0200 sparc: Skip all empty assembly statements This version detects multiple empty assembly statements in a row and also detects non-memory barrier empty assembly statements (__asm__("")). It can be used instead of next_active_insn(). gcc/ChangeLog: * config/sparc/sparc.c (next_active_non_empty_insn): New function that returns next active non empty assembly instruction. (sparc_do_work_around_errata): Use new function. Diff: --- gcc/config/sparc/sparc.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c index 49cee356a83..94061e111bd 100644 --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -1094,6 +1094,24 @@ load_insn_p (rtx_insn *insn) && GET_CODE (PATTERN (INSN)) != USE \ && GET_CODE (PATTERN (INSN)) != CLOBBER) +rtx_insn * +next_active_non_empty_insn (rtx_insn *insn) +{ + insn = next_active_insn (insn); + + while (insn + && (GET_CODE (PATTERN (insn)) == UNSPEC_VOLATILE + || GET_CODE (PATTERN (insn)) == ASM_INPUT + || (USEFUL_INSN_P (insn) + && (asm_noperands (PATTERN (insn)) >= 0) + && !strcmp (decode_asm_operands (PATTERN (insn), + NULL, NULL, NULL, + NULL, NULL), "")))) + insn = next_active_insn (insn); + + return insn; +} + static unsigned int sparc_do_work_around_errata (void) { @@ -1151,7 +1169,7 @@ sparc_do_work_around_errata (void) emit_insn_before (gen_nop (), target); } - next = next_active_insn (insn); + next = next_active_non_empty_insn (insn); if (!next) break; @@ -1254,23 +1272,12 @@ sparc_do_work_around_errata (void) rtx_insn *after; int i; - next = next_active_insn (insn); + next = next_active_non_empty_insn (insn); if (!next) break; for (after = next, i = 0; i < 2; i++) { - /* Skip empty assembly statements. */ - if ((GET_CODE (PATTERN (after)) == UNSPEC_VOLATILE) - || (USEFUL_INSN_P (after) - && (asm_noperands (PATTERN (after))>=0) - && !strcmp (decode_asm_operands (PATTERN (after), - NULL, NULL, NULL, - NULL, NULL), ""))) - after = next_active_insn (after); - if (!after) - break; - /* If the insn is a branch, then it cannot be problematic. */ if (!NONJUMP_INSN_P (after) || GET_CODE (PATTERN (after)) == SEQUENCE) @@ -1295,7 +1302,7 @@ sparc_do_work_around_errata (void) && (MEM_P (SET_DEST (set)) || mem_ref (SET_SRC (set)))) break; - after = next_active_insn (after); + after = next_active_non_empty_insn (after); if (!after) break; }