Bug 14749 - [3.3 Regression] Miscompilation of bit test
Summary: [3.3 Regression] Miscompilation of bit test
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 3.3.3
: P1 normal
Target Milestone: 3.3.4
Assignee: Steven Bosscher
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2004-03-27 00:17 UTC by Steven Bosscher
Modified: 2004-10-30 21:10 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.0.4 2.95.3 3.4.0 4.0.0
Known to fail: 3.2.3 3.3.3
Last reconfirmed: 2004-03-27 00:24:05


Attachments
Backport two patches from mainline (2.95 KB, patch)
2004-03-27 00:19 UTC, Steven Bosscher
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Steven Bosscher 2004-03-27 00:17:38 UTC
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.
Comment 1 Steven Bosscher 2004-03-27 00:19:42 UTC
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.
Comment 2 Andrew Pinski 2004-03-27 00:24:05 UTC
Confirmed, already by me on IRC.
Comment 3 Gabriel Dos Reis 2004-03-27 00:47:42 UTC
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
Comment 4 Gabriel Dos Reis 2004-03-27 01:14:40 UTC
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
Comment 5 Steven Bosscher 2004-03-27 01:28:39 UTC
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.

Comment 6 Gabriel Dos Reis 2004-03-27 02:09:18 UTC
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 7 Steven Bosscher 2004-03-27 22:36:59 UTC
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.
Comment 8 Gabriel Dos Reis 2004-04-27 07:01:11 UTC
(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
Comment 9 s.bosscher 2004-04-27 08:22:23 UTC
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.



Comment 10 GCC Commits 2004-05-07 16:26:15 UTC
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

Comment 11 Steven Bosscher 2004-05-07 16:26:44 UTC
I'm not going to say "fixed".  Just "plugged".