https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61871 --- Comment #5 from UroÅ¡ Bizjak --- The testcase now fails also on i686-linux-gnu (Fedora 20, x86_64 with -m32): runtime: memory allocated by OS (0xef4f1000) not in usable range [0x18200000,0x98200000) runtime: out of memory: cannot allocate 72744960-byte block (496762880 in use) fatal error: out of memory goroutine 32 [running]: runtime_dopanic /home/uros/gcc-svn/trunk/libgo/runtime/panic.c:131 runtime_throw /home/uros/gcc-svn/trunk/libgo/runtime/panic.c:193 largealloc /home/uros/gcc-svn/trunk/libgo/runtime/malloc.goc:288 runtime_mallocgc /home/uros/gcc-svn/trunk/libgo/runtime/malloc.goc:234 __go_alloc /home/uros/gcc-svn/trunk/libgo/runtime/malloc.goc:332 __go_append /home/uros/gcc-svn/trunk/libgo/runtime/go-append.c:63 regexp.onePassCopy /ssd/uros/gcc-build/x86_64-unknown-linux-gnu/32/libgo/gotest24887/test/onepass.go:227 regexp.compileOnePass /ssd/uros/gcc-build/x86_64-unknown-linux-gnu/32/libgo/gotest24887/test/onepass.go:573 regexp.compile /ssd/uros/gcc-build/x86_64-unknown-linux-gnu/32/libgo/gotest24887/test/regexp.go:168 regexp.Compile /ssd/uros/gcc-build/x86_64-unknown-linux-gnu/32/libgo/gotest24887/test/regexp.go:118 regexp.MustCompile /ssd/uros/gcc-build/x86_64-unknown-linux-gnu/32/libgo/gotest24887/test/regexp.go:219 regexp.TestOnePassCutoff /ssd/uros/gcc-build/x86_64-unknown-linux-gnu/32/libgo/gotest24887/test/all_test.go:478 testing.tRunner /home/uros/gcc-svn/trunk/libgo/go/testing/testing.go:422 kickoff /home/uros/gcc-svn/trunk/libgo/runtime/proc.c:212 panic during panic goroutine 32 [running]: runtime_dopanic /home/uros/gcc-svn/trunk/libgo/runtime/panic.c:131 runtime_startpanic /home/uros/gcc-svn/trunk/libgo/runtime/panic.c:100 runtime_throw /home/uros/gcc-svn/trunk/libgo/runtime/panic.c:191 runtime_mallocgc /home/uros/gcc-svn/trunk/libgo/runtime/malloc.goc:121 __go_alloc /home/uros/gcc-svn/trunk/libgo/runtime/malloc.goc:332 callback /home/uros/gcc-svn/trunk/libgo/runtime/go-caller.c:50 dwarf_lookup_pc /home/uros/gcc-svn/trunk/libbacktrace/dwarf.c:2838 dwarf_fileline /home/uros/gcc-svn/trunk/libbacktrace/dwarf.c:2877 backtrace_pcinfo /home/uros/gcc-svn/trunk/libbacktrace/fileline.c:176 __go_file_line /home/uros/gcc-svn/trunk/libgo/runtime/go-caller.c:137 runtime_printcreatedby /home/uros/gcc-svn/trunk/libgo/runtime/proc.c:595 runtime_dopanic /home/uros/gcc-svn/trunk/libgo/runtime/panic.c:132 runtime_throw /home/uros/gcc-svn/trunk/libgo/runtime/panic.c:193 largealloc /home/uros/gcc-svn/trunk/libgo/runtime/malloc.goc:288 runtime_mallocgc /home/uros/gcc-svn/trunk/libgo/runtime/malloc.goc:234 __go_alloc /home/uros/gcc-svn/trunk/libgo/runtime/malloc.goc:332 __go_append /home/uros/gcc-svn/trunk/libgo/runtime/go-append.c:63 regexp.onePassCopy /ssd/uros/gcc-build/x86_64-unknown-linux-gnu/32/libgo/gotest24887/test/onepass.go:227 regexp.compileOnePass /ssd/uros/gcc-build/x86_64-unknown-linux-gnu/32/libgo/gotest24887/test/onepass.go:573 regexp.compile /ssd/uros/gcc-build/x86_64-unknown-linux-gnu/32/libgo/gotest24887/test/regexp.go:168 regexp.Compile /ssd/uros/gcc-build/x86_64-unknown-linux-gnu/32/libgo/gotest24887/test/regexp.go:118 regexp.MustCompile /ssd/uros/gcc-build/x86_64-unknown-linux-gnu/32/libgo/gotest24887/test/regexp.go:219 regexp.TestOnePassCutoff /ssd/uros/gcc-build/x86_64-unknown-linux-gnu/32/libgo/gotest24887/test/all_test.go:478 testing.tRunner /home/uros/gcc-svn/trunk/libgo/go/testing/testing.go:422 kickoff /home/uros/gcc-svn/trunk/libgo/runtime/proc.c:212 stack trace unavailable FAIL: regexp >From gcc-bugs-return-466947-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sun Nov 16 12:20:11 2014 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 29763 invoked by alias); 16 Nov 2014 12:20:10 -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 Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 29689 invoked by uid 48); 16 Nov 2014 12:20:04 -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: Sun, 16 Nov 2014 12:20: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: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: attachments.created 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/msg01419.txt.bz2 Content-length: 2164 https://gcc.gnu.org/bugzilla/show_bug.cgi?idc783 --- Comment #10 from Michael Karcher --- Created attachment 33991 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id3991&actioníit Fix logical negation of registers, SImode only In fact, it turns out, you were right. I implemented the solution you suggest (quite hacky, as I only implemented it for SImode, I was too lazy to look up whether there are nice patterns for testing DImode operands into T), and compared assembler outputs. In fact, the duplicate test instruction is NOT eliminated in my first patch, but it is with your code after fixing. So the approach of special-casing compare-to-zero seems to have a positive effect. Assembler output: buggy: tst r4,r4 bf .L2 ; initial if, jumps if "flag" is nonzero ; Branch for zero "flag" mov.l .L10,r1 ; loads address of val mov.l @r1,r1 ; loads value of val ; Common code for zero or non-zero flag .L3: tst r1,r1 ; combined test bt .L8 ; if zero, skip increment mov.l .L11,r2 ; load address of true_count mov.l @r2,r1 ; load, increment, store true_count add #1,r1 mov.l r1,@r2 ; Label for skipping increment of true_count .L8: rts .align 1 ; branch for non-zero "flag" .L2: mov.l .L12,r1 ; load address of decision_result mov.l @r1,r1 ; load data of decision_result tst r1,r1 ; tst/movt logical negation before bra .L3 ; jumping to common code movt r1 With my earlier patch removing the "compare-to-zero" logic completely, the assembler output changes as following (CAPS comments on changes): ... mov.l @r1,r1 ; loads value of val tst r1,r1 ; TEST ONLY FOR FLAG == 0 ; Common code for zero or non-zero flag .L3: bt .L8 ; if zero, skip increment ... tst r1,r1 ; tst/movt logical negation before movt r1 bra .L3 ; jumping to common code tst r1,r1 ; TEST ONLY FOR FLAG != 0