From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24550 invoked by alias); 22 Nov 2014 11:07:01 -0000 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 Received: (qmail 24498 invoked by uid 48); 22 Nov 2014 11:06:55 -0000 From: "gcc-bugzilla at mkarcher dot dialup.fu-berlin.de" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/63783] [4.9/5 Regression] [SH] Miscompilation of boolean negation on SH4 using -O2 Date: Sat, 22 Nov 2014 11:07:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 4.9.1 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: gcc-bugzilla at mkarcher dot dialup.fu-berlin.de X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.9.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-11/txt/msg02522.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63783 --- Comment #20 from Michael Karcher --- (In reply to Oleg Endo from comment #19) > > The or-then-SImode-compare optimization has an adverse effect on the test > > coverage, it seems. In both cases, GET_MODE(src_reg) and GET_MODE(dst_reg) > > are SImode, so the DImode output branch is not tested by any of your two > > example source files. > That is true as it stands now. However, we already anticipate that there > might be something going on with DImode stuff, so just adding the test might > help debugging in the future. Even if it doesn't add any value now, it > doesn't hurt anyone either. The test case is not a problem - but it would be helpful to have a testcase that actually tests the DImode output case. I understand that it likely is not possible with today's gcc to reach that branch, so it seems this has to stay the way it is now. I am fine with it. > > Furthermore, it looks like make_not_reg_insn will > > actually produce bad code if it were ever called with GET_MODE(src_reg) == > > DImode. > Please do explain. Of course. The instructions involving src_reg in make_not_reg_insn dealing with src_reg are completely quoted here: + // On SH we can do only SImode and DImode comparisons. + if (! (GET_MODE (src_reg) == SImode || GET_MODE (src_reg) == DImode)) + return NULL; In this fragment, you accept DImode source operands. So that code may be used to replace a DImode compare. + emit_insn (gen_rtx_SET (VOIDmode, m_ccreg, + gen_rtx_fmt_ee (EQ, SImode, src_reg, const0_rtx))); In this fragment, you are generating the replacement instruction, which is always an SImode compare. Maybe I miss the point, but I fail to undestand how an SImode compare might be acceptable on an DImode operand. Possibly, this even ICEs, I don't know enough about gcc internals to know what happens if src_reg is DImode which is passed to EQ in SImode.