From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19719 invoked by alias); 14 Mar 2014 15:45:19 -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 19667 invoked by uid 48); 14 Mar 2014 15:45:14 -0000 From: "hjl.tools at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/60520] stack adjustment are not merged anymore Date: Fri, 14 Mar 2014 15:45: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.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hjl.tools at gmail dot com X-Bugzilla-Status: RESOLVED 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: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-03/txt/msg01170.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D60520 --- Comment #9 from H.J. Lu --- (In reply to Uro=C5=A1 Bizjak from comment #8) > However, using "-O2 -m32 -fno-omit-frame-pointer" an unnecessary stack > adjustment remains, even after r208551: >=20 > test: > movl bar, %eax > movl (%eax), %edx > testl %edx, %edx > jne .L7 > ret > .p2align 4,,10 > .p2align 3 > pushl %ebp > movl %esp, %ebp > subl $20, %esp > pushl %eax > call foo > addl $16, %esp <<<< > leave > ret ix86_expand_epilogue restores SP and BP: (insn 12 11 29 3 (parallel [ (set (reg/f:SI 7 sp) (plus:SI (reg/f:SI 7 sp) (const_int 16 [0x10]))) (clobber (reg:CC 17 flags)) ]) /tmp/p.i:7 253 {*addsi_1} (expr_list:REG_ARGS_SIZE (const_int 0 [0]) (nil))) (note 29 12 30 3 NOTE_INSN_EPILOGUE_BEG) (insn/f 30 29 34 3 (parallel [ (set (reg/f:SI 7 sp) (plus:SI (reg/f:SI 6 bp) (const_int 4 [0x4]))) (set (reg/f:SI 6 bp) (mem:SI (reg/f:SI 6 bp) [0 S4 A8])) (clobber (mem:BLK (scratch) [0 A8])) ]) /tmp/p.i:8 -1 (expr_list:REG_CFA_RESTORE (reg/f:SI 6 bp) (expr_list:REG_CFA_DEF_CFA (plus:SI (reg/f:SI 7 sp) (const_int 4 [0x4])) (nil)))) But none of the passes after it kill insn 12. >>From gcc-bugs-return-446302-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Mar 14 15:51:15 2014 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 24048 invoked by alias); 14 Mar 2014 15:51:14 -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 24009 invoked by uid 48); 14 Mar 2014 15:51:11 -0000 From: "nicklas.ekstrand at sonymobile dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/60527] New: Incorrectly removed if statement while doing int arithmetics Date: Fri, 14 Mar 2014 15:51:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 4.6.3 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: nicklas.ekstrand at sonymobile dot com X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: 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-03/txt/msg01171.txt.bz2 Content-length: 1081 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60527 Bug ID: 60527 Summary: Incorrectly removed if statement while doing int arithmetics Product: gcc Version: 4.6.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: nicklas.ekstrand at sonymobile dot com Created attachment 32349 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32349&action=edit Test program modtest.c In the following code: static int getZ() { int tmp; Z = Z * A + B; tmp = Z; if (tmp == INT_MIN) tmp++; if (tmp < 0) tmp = -tmp; return tmp % MEMSIZE; } The if-statement tmp==INT_MIN is optimized away when using -O2 or higher, e.g., $ gcc -Wall -Wextra -g -O2 modtest.c -o pc_modtest -lrt $ ./pc_modtest arr=0x7fc1608be010 i=0 A=945 B=411 z1=231029 z2=-7483648 Segmentation fault When using -O0 the problem doesn't happen and the program will not cause a segmentation fault.