The following test case is miscompiled by GCC 3.3.3 and earlier at -O and higher: inline void bar (const int id) { if (id & 0x00008000) abort (); } int main (void) { bar (0x00000001); return 0; } Apparently more or less by accident, this problem was fixed on mainline with the following patches: 2003-07-04 Jeff Law <law@redhat.com> PR c/11428 * expr.c (do_store_flag): Pass in the correct result type when calling fold_single_bit_test. * fold-const.c (fold_single_bit_test): Use result_type for the result when folding a sign bit test. 2003-07-02 Jeff Law <law@redhat.com> * expr.c (do_store_flag): Remove special case folding for single bit tests. Instead call back into the commonized folder routine. * fold-const.c (fold_single_bit_test): New function, mostly extracted from do_store_flag, with an additional case extracted from fold. (fold): Call fold_single_bit_test appropriately. * tree.h (fold_single_bit_test): Prototype. I'd like to backport those for 3.3.4.
Created attachment 6000 [details] Backport two patches from mainline Bootstrapped on amd64, ppc, and i686. Tested on amd64 and i686. I'll post it to gcc-patches this weekend.
Confirmed, already by me on IRC.
Subject: Re: New: Miscompilation of bit test "steven at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes: | The following test case is miscompiled by GCC 3.3.3 and earlier | at -O and higher: | | inline void bar (const int id) { if (id & 0x00008000) abort (); } | int main (void) { bar (0x00000001); return 0; } | | Apparently more or less by accident, this problem was fixed on mainline with | the following patches: | | 2003-07-04 Jeff Law <law@redhat.com> | | PR c/11428 | * expr.c (do_store_flag): Pass in the correct result type | when calling fold_single_bit_test. | * fold-const.c (fold_single_bit_test): Use result_type for the | result when folding a sign bit test. | | 2003-07-02 Jeff Law <law@redhat.com> | | * expr.c (do_store_flag): Remove special case folding for | single bit tests. Instead call back into the commonized folder | routine. | * fold-const.c (fold_single_bit_test): New function, mostly | extracted from do_store_flag, with an additional case extracted | from fold. | (fold): Call fold_single_bit_test appropriately. | * tree.h (fold_single_bit_test): Prototype. | | I'd like to backport those for 3.3.4. It is OK. Thanks for identifying those!. -- Gaby
Subject: Re: Miscompilation of bit test "pinskia at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes: | Confirmed, already by me on IRC. I'm sorry, I can't follow discussions on IRC (e.g. I'm just back from office, reading through mails, approving patches, making a status report before taking a flight to a conference in Europe in about 12 hours, and I don't expect to have regular connections there to be on IRC). I would suggest that discussions by GCC developers that affect GCC be held on GCC mailing lists. Or at least, make an archive of those discussions (even if that means some people would have tp refrain from using some "words"). -- Gaby
Subject: Re: [3.3 Regression] Miscompilation of bit test On Saturday 27 March 2004 02:14, gdr at integrable-solutions dot net wrote: > ------- Additional Comments From gdr at integrable-solutions dot net > 2004-03-27 01:14 ------- Subject: Re: Miscompilation of bit test > > "pinskia at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes: > | Confirmed, already by me on IRC. > > I'm sorry, I can't follow discussions on IRC (e.g. I'm just back from > office, reading through mails, approving patches, making a status > report before taking a flight to a conference in Europe in about 12 > hours, and I don't expect to have regular connections there to be on > IRC). > > I would suggest that discussions by GCC developers that affect GCC be > held on GCC mailing lists. Or at least, make an archive of those > discussions (even if that means some people would have tp refrain > from using some "words"). What discussion? What "words"? I just pasted the test case into an IRC channel so that Andrew Pinski could confirm the bug. I like this kind of direct communication, so if you don't mind, I'll keep doing things that way and post relevant information (ie. results from such "discussions") to gcc mailing lists and/or bugzilla. I don't ask you to follow IRC, and you should not tell us not to use it.
Subject: Re: [3.3 Regression] Miscompilation of bit test "stevenb at suse dot de" <gcc-bugzilla@gcc.gnu.org> writes: | On Saturday 27 March 2004 02:14, gdr at integrable-solutions dot net wrote: | > ------- Additional Comments From gdr at integrable-solutions dot net | > 2004-03-27 01:14 ------- Subject: Re: Miscompilation of bit test | > | > "pinskia at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes: | > | Confirmed, already by me on IRC. | > | > I'm sorry, I can't follow discussions on IRC (e.g. I'm just back from | > office, reading through mails, approving patches, making a status | > report before taking a flight to a conference in Europe in about 12 | > hours, and I don't expect to have regular connections there to be on | > IRC). | > | > I would suggest that discussions by GCC developers that affect GCC be | > held on GCC mailing lists. Or at least, make an archive of those | > discussions (even if that means some people would have tp refrain | > from using some "words"). | | What discussion? What "words"? | | I just pasted the test case into an IRC channel so that Andrew Pinski | could confirm the bug. I like this kind of direct communication, so | if you don't mind, I'll keep doing things that way and post relevant | information (ie. results from such "discussions") to gcc mailing lists | and/or bugzilla. | | I don't ask you to follow IRC, and you should not tell us not to use it. Did you carefully read what I said, you would have noticed that I did not ask you to stop using IRC. Wouldn't you? -- Gaby
Comment on attachment 6000 [details] Backport two patches from mainline The proposed patch caused 14754, so I'll have to withdraw that patch. I'm looking at other ways to fix the issue.
(In reply to comment #7) > (From update of attachment 6000 [details]) > The proposed patch caused 14754, so I'll have to withdraw that patch. I'm > looking at other ways to fix the issue. > Steven -- Did you make a progress on this front? -- Gaby
Subject: RE: [3.3 Regression] Miscompilation of b it test Yes, I have a stop-gap, but I can't get to it until I can revive my machine. I'll send it to you next week. -----Original Message----- From: gdr at gcc dot gnu dot org To: steven@gcc.gnu.org Sent: 4/27/04 9:01 AM Subject: [Bug optimization/14749] [3.3 Regression] Miscompilation of bit test ------- Additional Comments From gdr at gcc dot gnu dot org 2004-04-27 07:01 ------- (In reply to comment #7) > (From update of attachment 6000 [details]) > The proposed patch caused 14754, so I'll have to withdraw that patch. I'm > looking at other ways to fix the issue. > Steven -- Did you make a progress on this front? -- Gaby -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14749 ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee. You reported the bug, or are watching the reporter.
Subject: Bug 14749 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: steven@gcc.gnu.org 2004-05-07 16:26:04 Modified files: gcc : expr.c ChangeLog Log message: PR opt/14749 * expr.c (do_jump): If TREE_CONSTANT_OVERFLOW is set, don't trust integer_zerop. Just expand both branches. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/expr.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.498.2.29&r2=1.498.2.30 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.975&r2=1.16114.2.976
I'm not going to say "fixed". Just "plugged".