From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31388 invoked by alias); 18 Dec 2011 19:02:15 -0000 Received: (qmail 31379 invoked by uid 22791); 18 Dec 2011 19:02:14 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_GJ X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 18 Dec 2011 19:02:01 +0000 From: "gjl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/51374] [avr] insn combine reorders volatile memory accesses Date: Sun, 18 Dec 2011 20:11:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: major X-Bugzilla-Who: gjl at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.6.3 X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-12/txt/msg02006.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51374 --- Comment #6 from Georg-Johann Lay 2011-12-18 19:01:56 UTC --- In combine.c:try_combine, just after the "Trying..." dump output, there is: i0 = 0 i1 = 0 i2 = (set (reg/v:QI 43 [ status ]) (mem/v:QI (const_int 43 [0x2b]))) i3 = (set (pc) (if_then_else (eq (zero_extract:QI (reg/v:QI 43 [ status ]) (const_int 1) (const_int 4)) (const_int 0)) (label_ref:HI 16) (pc))) where the potential insertion is i2 into i3. These insns are fed into can_combine_p with src = (mem/v:QI (const_int 43)) dest = (reg/v:QI 43) and then there is this part of an if-clause: /* Make sure that the value that is to be substituted for the register does not use any registers whose values alter in between. However, If the insns are adjacent, a use can't cross a set even though we think it might (this can happen for a sequence of insns each setting the same destination; last_set of that register might point to a NOTE). If INSN has a REG_EQUIV note, the register is always equivalent to the memory so the substitution is valid even if there are intervening stores. Also, don't move a volatile asm or UNSPEC_VOLATILE across any other insns. */ || (! all_adjacent && (((!MEM_P (src) || ! find_reg_note (insn, REG_EQUIV, src)) && use_crosses_set_p (src, DF_INSN_LUID (insn))) || (GET_CODE (src) == ASM_OPERANDS && MEM_VOLATILE_P (src)) || GET_CODE (src) == UNSPEC_VOLATILE)) In addition to these tests, the following must be disallowed: If src contains volatile memory, then disallow moving it across: * volatile memory * unspec_volatile * asm volatile As far as I can see, use_crosses_set_p (src,...) returns 0 (false) which is incorrect. So either use_crosses_set_p is incorrect or it relies on incorrect data from data flow analysis or from wherever.