public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/31136]  New: FRE ignores bit-field truncation
@ 2007-03-11 18:48 TabonyEE at austin dot rr dot com
  2007-03-19 23:19 ` [Bug tree-optimization/31136] " TabonyEE at austin dot rr dot com
                   ` (18 more replies)
  0 siblings, 19 replies; 22+ messages in thread
From: TabonyEE at austin dot rr dot com @ 2007-03-11 18:48 UTC (permalink / raw)
  To: gcc-bugs

With the tip of the 4.2 branch, the following program returns 1.  Mainline
returns 0.  Is this defined behavior?  I could not find anything on the
subject.

struct S {
  unsigned b4:4;
  unsigned b6:6;
} s;

int main(void){
  s.b6 = 31;
  s.b4 = s.b6;
  s.b6 = s.b4;
  return s.b6 == 15 ? 0 : 1;
}


before FRE (-fdump-tree-ccp):

;; Function main (main)

main ()
{
  short unsigned int D.1882;
  short unsigned int D.1881;
  int D.1880;
  <unnamed type> D.1879;
  <unnamed type> D.1878;
  <unnamed type> D.1877;
  <unnamed type> D.1876;

<bb 2>:
  s.b6 = 31;
  D.1876_3 = s.b6;
  D.1877_4 = (<unnamed type>) D.1876_3;
  s.b4 = D.1877_4;
  D.1878_7 = s.b4;
  D.1879_8 = (<unnamed type>) D.1878_7;
  s.b6 = D.1879_8;
  D.1881_10 = BIT_FIELD_REF <s, 16, 0>;
  D.1882_11 = D.1881_10 & 1008;
  D.1880_12 = D.1882_11 != 240;
  return D.1880_12;

}


after FRE (-fdump-tree-fre):

;; Function main (main)

main ()
{
  short unsigned int D.1882;
  short unsigned int D.1881;
  int D.1880;
  <unnamed type> D.1879;
  <unnamed type> D.1878;
  <unnamed type> D.1877;
  <unnamed type> D.1876;

<bb 2>:
  s.b6 = 31;
  D.1876_3 = 31;
  D.1877_4 = (<unnamed type>) D.1876_3;
  s.b4 = D.1877_4;
  D.1878_7 = D.1877_4;
  D.1879_8 = 31;
  s.b6 = D.1879_8;
  D.1881_10 = BIT_FIELD_REF <s, 16, 0>;
  D.1882_11 = D.1881_10 & 1008;
  D.1880_12 = D.1882_11 != 240;
  return D.1880_12;

}


D.1879_8 was replaced by 31, ignoring the fact that the value should have been
truncated to 15 when assigned to s.b4.


-- 
           Summary: FRE ignores bit-field truncation
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: TabonyEE at austin dot rr dot com
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31136


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2007-04-21 17:53 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-11 18:48 [Bug tree-optimization/31136] New: FRE ignores bit-field truncation TabonyEE at austin dot rr dot com
2007-03-19 23:19 ` [Bug tree-optimization/31136] " TabonyEE at austin dot rr dot com
2007-03-20  0:24 ` pinskia at gcc dot gnu dot org
2007-03-20  0:39 ` TabonyEE at austin dot rr dot com
2007-03-20  6:41 ` [Bug c/31136] " pinskia at gcc dot gnu dot org
2007-03-20 10:00 ` [Bug c/31136] [4.2 Regression] " rguenth at gcc dot gnu dot org
2007-03-22 23:14 ` [Bug c/31136] [4.2 Regression] FRE ignores bit-field truncation (C and C++ front-end don't produce " mmitchel at gcc dot gnu dot org
2007-03-23  3:45 ` [Bug tree-optimization/31136] " jsm28 at gcc dot gnu dot org
2007-03-23  5:01 ` spark at gcc dot gnu dot org
2007-03-23  7:57   ` Andrew Pinski
2007-03-23  8:01     ` Andrew Pinski
2007-03-23  7:57 ` pinskia at gmail dot com
2007-03-23  8:01 ` pinskia at gmail dot com
2007-03-23  8:18 ` pinskia at gcc dot gnu dot org
2007-03-23 13:41 ` joseph at codesourcery dot com
2007-03-26  4:43 ` mmitchel at gcc dot gnu dot org
2007-04-21 15:37 ` rguenth at gcc dot gnu dot org
2007-04-21 15:56 ` rguenth at gcc dot gnu dot org
2007-04-21 15:58 ` rguenth at gcc dot gnu dot org
2007-04-21 17:44 ` rguenth at gcc dot gnu dot org
2007-04-21 17:47 ` rguenth at gcc dot gnu dot org
2007-04-21 17:53 ` rguenth at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).